@@ -151,14 +151,6 @@ def translate_stix_objects(self, stix_objects):
151151 "name" : "identity" ,
152152 "identity_class" : "identity_class"
153153 }
154- attack_stix_mapping = {
155- "attack-pattern" : "technique" ,
156- "course-of-action" : "mitigation" ,
157- "intrusion-set" : "group" ,
158- "malware" : "software" ,
159- "tool" : "software" ,
160- "relationship" : "relationship"
161- }
162154
163155 # ******** Helper Functions ********
164156 def handle_list (list_object , object_type ):
@@ -182,7 +174,10 @@ def handle_list(list_object, object_type):
182174 elif obj_dict ['type' ] == 'matrix' :
183175 obj_dict ['matrix_id' ] = list_object [0 ]['external_id' ]
184176 elif object_type == "kill_chain_phases" :
185- obj_dict ['tactic' ] = list_object [0 ]['phase_name' ]
177+ tactic_list = list ()
178+ for phase in list_object :
179+ tactic_list .append (phase ['phase_name' ])
180+ obj_dict ['tactic' ] = tactic_list
186181
187182 stix_objects_list = list ()
188183 for obj in stix_objects :
@@ -193,8 +188,7 @@ def handle_list(list_object, object_type):
193188 dict_keys = list (obj_dict .keys ())
194189 for key in dict_keys :
195190 if obj ['type' ] == "attack-pattern" :
196- if obj ['revoked' ] == False :
197- stix_mapping = technique_stix_mapping
191+ stix_mapping = technique_stix_mapping
198192 elif obj ['type' ] == "course-of-action" :
199193 stix_mapping = mitigation_stix_mapping
200194 elif obj ['type' ] == "intrusion-set" :
@@ -223,6 +217,20 @@ def handle_list(list_object, object_type):
223217 stix_objects_list .append (obj_dict )
224218 return stix_objects_list
225219
220+ def remove_revoked (self , stix_objects ):
221+ no_revoked = list ()
222+ for obj in stix_objects :
223+ if 'revoked' not in obj .keys ():
224+ no_revoked .append (obj )
225+ return no_revoked
226+
227+ def extract_revoked (self , stix_objects ):
228+ extract_revoked = list ()
229+ for obj in stix_objects :
230+ if 'revoked' in obj .keys ():
231+ extract_revoked .append (obj )
232+ return extract_revoked
233+
226234 # ******** Enterprise ATT&CK Technology Domain *******
227235 def get_all_enterprise (self , stix_format = True ):
228236 enterprise_filter_objects = {
@@ -239,7 +247,7 @@ def get_all_enterprise(self, stix_format=True):
239247 }
240248 enterprise_stix_objects = {}
241249 for key in enterprise_filter_objects :
242- enterprise_stix_objects [key ] = self .TC_ENTERPRISE_SOURCE .query (enterprise_filter_objects [key ])
250+ enterprise_stix_objects [key ] = ( self .TC_ENTERPRISE_SOURCE .query (enterprise_filter_objects [key ]) )
243251 if not stix_format :
244252 enterprise_stix_objects [key ] = self .translate_stix_objects (enterprise_stix_objects [key ])
245253 return enterprise_stix_objects
@@ -393,21 +401,22 @@ def get_all_mobile_tactics(self, stix_format=True):
393401
394402 # ******** Get All Functions ********
395403 def get_all_stix_objects (self , stix_format = True ):
396- techniques_pre_keys = {"techniques" ,"groups" ,"relationships" }
397- techniques_mobile_keys = {"techniques" ,"mitigations" ,"groups" ,"malware" ,"tools" ,"relationships" }
398404 enterprise_objects = self .get_all_enterprise ()
399405 pre_objects = self .get_all_pre ()
400406 mobile_objects = self .get_all_mobile ()
401- for key in techniques_pre_keys :
402- for pre in pre_objects [key ]:
403- if pre not in enterprise_objects [key ]:
404- enterprise_objects [key ].append (pre )
405- for key in techniques_mobile_keys :
406- for m in mobile_objects [key ]:
407- if m not in enterprise_objects [key ]:
408- enterprise_objects [key ].append (m )
409- if not stix_format :
410- enterprise_objects = self .translate_stix_objects (enterprise_objects )
407+ for keypre in pre_objects .keys ():
408+ for preobj in pre_objects [keypre ]:
409+ if keypre in enterprise_objects .keys ():
410+ if preobj not in enterprise_objects [keypre ]:
411+ enterprise_objects [keypre ].append (preobj )
412+ for keymob in mobile_objects .keys ():
413+ for mobobj in mobile_objects [keymob ]:
414+ if keymob in enterprise_objects .keys ():
415+ if mobobj not in enterprise_objects [keymob ]:
416+ enterprise_objects [keymob ].append (mobobj )
417+ if not stix_format :
418+ for enterkey in enterprise_objects .keys ():
419+ enterprise_objects [enterkey ] = self .translate_stix_objects (enterprise_objects [enterkey ])
411420 return enterprise_objects
412421
413422 def get_all_techniques (self , stix_format = True ):
0 commit comments