7
7
import logging
8
8
from pydantic import BaseModel , Field
9
9
from dataclasses import field
10
- from typing import Annotated
10
+ from typing import Annotated , Any
11
11
from contentctl .objects .mitre_attack_enrichment import MitreAttackEnrichment
12
12
from contentctl .objects .config import validate
13
13
logging .getLogger ('taxii2client' ).setLevel (logging .CRITICAL )
@@ -34,20 +34,21 @@ def getEnrichmentByMitreID(self, mitre_id:Annotated[str, Field(pattern=r"^T\d{4}
34
34
raise Exception (f"Error, Unable to find Mitre Enrichment for MitreID { mitre_id } " )
35
35
36
36
37
- def addMitreID (self , technique :dict , tactics :list [str ], groups :list [str ])-> None :
37
+ def addMitreID (self , technique :dict , tactics :list [str ], groups :list [dict [ str , Any ] ])-> None :
38
38
39
39
technique_id = technique ['technique_id' ]
40
40
technique_obj = technique ['technique' ]
41
41
tactics .sort ()
42
- groups .sort ()
42
+ group_names_only :list [str ] = sorted ([group ['group' ] for group in groups ])
43
+
43
44
44
45
if technique_id in self .data :
45
46
raise Exception (f"Error, trying to redefine MITRE ID '{ technique_id } '" )
46
-
47
47
self .data [technique_id ] = MitreAttackEnrichment (mitre_attack_id = technique_id ,
48
48
mitre_attack_technique = technique_obj ,
49
49
mitre_attack_tactics = tactics ,
50
- mitre_attack_groups = groups )
50
+ mitre_attack_groups = group_names_only ,
51
+ mitre_attack_group_objects = groups )
51
52
52
53
53
54
def get_attack_lookup (self , input_path : str , store_csv : bool = False , force_cached_or_offline : bool = False , skip_enrichment :bool = False ) -> dict :
@@ -86,12 +87,13 @@ def get_attack_lookup(self, input_path: str, store_csv: bool = False, force_cach
86
87
progress_percent = ((index + 1 )/ len (all_enterprise_techniques )) * 100
87
88
if (sys .stdout .isatty () and sys .stdin .isatty () and sys .stderr .isatty ()):
88
89
print (f"\r \t { 'MITRE Technique Progress' .rjust (23 )} : [{ progress_percent :3.0f} %]..." , end = "" , flush = True )
89
- apt_groups = []
90
+ apt_groups : list [ dict [ str , Any ]] = []
90
91
for relationship in enterprise_relationships :
91
92
if (relationship ['target_object' ] == technique ['id' ]) and relationship ['source_object' ].startswith ('intrusion-set' ):
92
93
for group in enterprise_groups :
93
94
if relationship ['source_object' ] == group ['id' ]:
94
- apt_groups .append (group ['group' ])
95
+ apt_groups .append (group )
96
+ #apt_groups.append(group['group'])
95
97
96
98
tactics = []
97
99
if ('tactic' in technique ):
0 commit comments