Skip to content

Commit 8e92fd8

Browse files
committed
Remove redundant code
1 parent 421c2ea commit 8e92fd8

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

contentctl/objects/detection_tags.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ def addAttackEnrichment(self, info: ValidationInfo):
134134

135135
if len(missing_tactics) > 0:
136136
raise ValueError(f"Missing Mitre Attack IDs. {missing_tactics} not found.")
137-
else:
138-
try:
139-
MitreAttackEnrichment.checkParentTypeNotDefinedWhenSubtypeDefined(
140-
mitre_enrichments
141-
)
142-
except Exception as e:
143-
raise ValueError(e)
144-
self.mitre_attack_enrichments = mitre_enrichments
145137

146138
return self
147139

@@ -193,7 +185,8 @@ def sameTypeAndSubtypeNotPresent(
193185
str(e) for e in subtype_and_parent_exist_exceptions
194186
)
195187
raise ValueError(
196-
f"Overlapping MITRE Attack ID Tactics and Subtactics may not be defined:\n{error_string}"
188+
"Overlapping MITRE Attack ID Tactics and Subtactics may not be defined. "
189+
f"Remove the tactic and keep the subtactic:\n{error_string}"
197190
)
198191

199192
return mitre_ids

contentctl/objects/mitre_attack_enrichment.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -115,40 +115,3 @@ def getUniqueGroups(
115115
for enrichment in enrichments:
116116
group_set.update(set(enrichment.mitre_attack_group_objects))
117117
return sorted(group_set)
118-
119-
@staticmethod
120-
def checkParentTypeNotDefinedWhenSubtypeDefined(
121-
enrichments: list[MitreAttackEnrichment],
122-
) -> None:
123-
# Get all the mitre_attack_ids
124-
mitre_attack_ids = [enrichment.mitre_attack_id for enrichment in enrichments]
125-
# Split these into two groups - one that just has parents and one which has subtypes as well
126-
mitre_attack_id_parents = [
127-
mitre_attack_id
128-
for mitre_attack_id in mitre_attack_ids
129-
if "." not in mitre_attack_id
130-
]
131-
mitre_attack_id_subtypes = [
132-
mitre_attack_id
133-
for mitre_attack_id in mitre_attack_ids
134-
if "." in mitre_attack_id
135-
]
136-
137-
subtype_and_parent_exist_exceptions: list[Exception] = []
138-
139-
for mitre_attack_id in mitre_attack_id_subtypes:
140-
parent_id = mitre_attack_id.split(".")[0]
141-
if parent_id in mitre_attack_id_parents:
142-
subtype_and_parent_exist_exceptions.append(
143-
Exception(
144-
f"Overlapping parent and subtype tactic: [Parent: '{parent_id}', Subtype: '{mitre_attack_id}']"
145-
)
146-
)
147-
if len(subtype_and_parent_exist_exceptions):
148-
raise ExceptionGroup(
149-
"Error: both MITRE Attack ID Subtype and Parent are defined. "
150-
"A parent tactic OR a subtype tactic may be defined, but not both",
151-
subtype_and_parent_exist_exceptions,
152-
)
153-
154-
return None

0 commit comments

Comments
 (0)