3
3
import logging
4
4
from dataclasses import field
5
5
from pathlib import Path
6
- from typing import Any , Dict , List , TypedDict , cast
6
+ from typing import Any , TypedDict , cast
7
7
8
8
from attackcti import attack_client # type: ignore[reportMissingTypeStubs]
9
9
from pydantic import BaseModel
@@ -24,7 +24,7 @@ class AttackPattern(TypedDict):
24
24
id : str
25
25
technique_id : str
26
26
technique : str
27
- tactic : List [str ]
27
+ tactic : list [str ]
28
28
29
29
30
30
class IntrusionSet (TypedDict ):
@@ -38,7 +38,7 @@ class Relationship(TypedDict):
38
38
39
39
40
40
class AttackEnrichment (BaseModel ):
41
- data : Dict [str , MitreAttackEnrichment ] = field (default_factory = dict )
41
+ data : dict [str , MitreAttackEnrichment ] = field (default_factory = dict )
42
42
use_enrichment : bool = True
43
43
44
44
@staticmethod
@@ -64,7 +64,7 @@ def getEnrichmentByMitreID(
64
64
)
65
65
66
66
def addMitreIDViaGroupNames (
67
- self , technique : Dict [str , Any ], tactics : List [str ], groupNames : List [str ]
67
+ self , technique : dict [str , Any ], tactics : list [str ], groupNames : list [str ]
68
68
) -> None :
69
69
technique_id = technique ["technique_id" ]
70
70
technique_obj = technique ["technique" ]
@@ -84,15 +84,15 @@ def addMitreIDViaGroupNames(
84
84
85
85
def addMitreIDViaGroupObjects (
86
86
self ,
87
- technique : Dict [str , Any ],
88
- tactics : List [MitreTactics ],
89
- groupDicts : List [ Dict [str , Any ]],
87
+ technique : dict [str , Any ],
88
+ tactics : list [MitreTactics ],
89
+ groupDicts : list [ dict [str , Any ]],
90
90
) -> None :
91
91
technique_id = technique ["technique_id" ]
92
92
technique_obj = technique ["technique" ]
93
93
tactics .sort ()
94
94
95
- groupNames : List [str ] = sorted ([group ["group" ] for group in groupDicts ])
95
+ groupNames : list [str ] = sorted ([group ["group" ] for group in groupDicts ])
96
96
97
97
if technique_id in self .data :
98
98
raise Exception (f"Error, trying to redefine MITRE ID '{ technique_id } '" )
@@ -109,8 +109,8 @@ def addMitreIDViaGroupObjects(
109
109
110
110
def get_attack_lookup (
111
111
self , input_path : Path , enrichments : bool = False
112
- ) -> Dict [str , MitreAttackEnrichment ]:
113
- attack_lookup : Dict [str , MitreAttackEnrichment ] = {}
112
+ ) -> dict [str , MitreAttackEnrichment ]:
113
+ attack_lookup : dict [str , MitreAttackEnrichment ] = {}
114
114
if not enrichments :
115
115
return attack_lookup
116
116
@@ -141,17 +141,17 @@ def get_attack_lookup(
141
141
)
142
142
143
143
all_enterprise_techniques = cast (
144
- List [AttackPattern ], lift .get_enterprise_techniques (stix_format = False )
144
+ list [AttackPattern ], lift .get_enterprise_techniques (stix_format = False )
145
145
)
146
146
enterprise_relationships = cast (
147
- List [Relationship ], lift .get_enterprise_relationships (stix_format = False )
147
+ list [Relationship ], lift .get_enterprise_relationships (stix_format = False )
148
148
)
149
149
enterprise_groups = cast (
150
- List [IntrusionSet ], lift .get_enterprise_groups (stix_format = False )
150
+ list [IntrusionSet ], lift .get_enterprise_groups (stix_format = False )
151
151
)
152
152
153
153
for technique in all_enterprise_techniques :
154
- apt_groups : List [ Dict [str , Any ]] = []
154
+ apt_groups : list [ dict [str , Any ]] = []
155
155
for relationship in enterprise_relationships :
156
156
if relationship ["target_object" ] == technique [
157
157
"id"
@@ -160,7 +160,7 @@ def get_attack_lookup(
160
160
if relationship ["source_object" ] == group ["id" ]:
161
161
apt_groups .append (dict (group ))
162
162
163
- tactics : List [MitreTactics ] = []
163
+ tactics : list [MitreTactics ] = []
164
164
if "tactic" in technique :
165
165
for tactic in technique ["tactic" ]:
166
166
tactics .append (
0 commit comments