Skip to content

Commit 4e088f8

Browse files
committed
Fix naming of tactics to techniques
1 parent 9c8722a commit 4e088f8

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

contentctl/objects/detection_tags.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,27 @@ def addAttackEnrichments(cls, v:list[MitreAttackEnrichment], info:ValidationInfo
174174
@field_validator("mitre_attack_id", mode="after")
175175
@classmethod
176176
def sameTypeAndSubtypeNotPresent(
177-
cls, mitre_ids: list[MITRE_ATTACK_ID_TYPE]
177+
cls, techniques_and_subtechniques: list[MITRE_ATTACK_ID_TYPE]
178178
) -> list[MITRE_ATTACK_ID_TYPE]:
179-
id_types: list[str] = [
180-
f"{mitre_id}." for mitre_id in mitre_ids if "." not in mitre_id
179+
techniques: list[str] = [
180+
f"{unknown_technique}."
181+
for unknown_technique in techniques_and_subtechniques
182+
if "." not in unknown_technique
181183
]
182-
id_subtypes: list[MITRE_ATTACK_ID_TYPE] = [
183-
mitre_id for mitre_id in mitre_ids if "." in mitre_id
184+
subtechniques: list[MITRE_ATTACK_ID_TYPE] = [
185+
unknown_technique
186+
for unknown_technique in techniques_and_subtechniques
187+
if "." in unknown_technique
184188
]
185189
subtype_and_parent_exist_exceptions: list[ValueError] = []
186190

187-
for id_subtype in id_subtypes:
188-
for id_type in id_types:
189-
if id_subtype.startswith(id_type):
191+
for subtechnique in subtechniques:
192+
for technique in techniques:
193+
if subtechnique.startswith(technique):
190194
subtype_and_parent_exist_exceptions.append(
191195
ValueError(
192-
f" Tactic : {id_type.split('.')[0]}\n"
193-
f" Subtactic: {id_subtype}\n"
196+
f" Technique : {technique.split('.')[0]}\n"
197+
f" SubTechnique: {subtechnique}\n"
194198
)
195199
)
196200

@@ -199,11 +203,11 @@ def sameTypeAndSubtypeNotPresent(
199203
str(e) for e in subtype_and_parent_exist_exceptions
200204
)
201205
raise ValueError(
202-
"Overlapping MITRE Attack ID Tactics and Subtactics may not be defined. "
203-
f"Remove the tactic and keep the subtactic:\n{error_string}"
206+
"Overlapping MITRE Attack ID Techniques and Subtechniques may not be defined. "
207+
f"Remove the Technique and keep the Subtechnique:\n{error_string}"
204208
)
205209

206-
return mitre_ids
210+
return techniques_and_subtechniques
207211

208212
@field_validator("analytic_story", mode="before")
209213
@classmethod

0 commit comments

Comments
 (0)