Skip to content

Commit 458861d

Browse files
committed
add a property to get sorted, deduped groups for a detection. this is particularly useful in site gen.
1 parent 8e92fd8 commit 458861d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

contentctl/objects/detection_tags.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
SecurityContentProductName,
3434
SecurityDomain,
3535
)
36-
from contentctl.objects.mitre_attack_enrichment import MitreAttackEnrichment
36+
from contentctl.objects.mitre_attack_enrichment import MitreAttackEnrichment, MitreAttackGroup
3737

3838

3939
class DetectionTags(BaseModel):
@@ -68,6 +68,13 @@ def kill_chain_phases(self) -> list[KillChainPhase]:
6868
phases.add(phase)
6969
return sorted(list(phases))
7070

71+
@property
72+
def unique_mitre_attack_groups(self)->list[MitreAttackGroup]:
73+
group_set: set[MitreAttackGroup] = set()
74+
for enrichment in self.enrichments:
75+
group_set.update(set(enrichment.mitre_attack_group_objects))
76+
return sorted(group_set, lambda k: k.group)
77+
7178
# enum is intentionally Cis18 even though field is named cis20 for legacy reasons
7279
@computed_field
7380
@property

contentctl/objects/mitre_attack_enrichment.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,3 @@ class MitreAttackEnrichment(BaseModel):
106106

107107
def __hash__(self) -> int:
108108
return id(self)
109-
110-
@staticmethod
111-
def getUniqueGroups(
112-
enrichments: list[MitreAttackEnrichment],
113-
) -> list[MitreAttackGroup]:
114-
group_set: set[MitreAttackGroup] = set()
115-
for enrichment in enrichments:
116-
group_set.update(set(enrichment.mitre_attack_group_objects))
117-
return sorted(group_set)

0 commit comments

Comments
 (0)