@@ -236,7 +236,9 @@ def get_author(self, name):
236
236
return self .mapping_cache [name ]
237
237
else :
238
238
author = self .opencti .identity .create (
239
- type = "Organization" , name = name , description = "" ,
239
+ type = "Organization" ,
240
+ name = name ,
241
+ description = "" ,
240
242
)
241
243
self .mapping_cache [name ] = author
242
244
return author
@@ -350,8 +352,10 @@ def extract_embedded_relationships(self, stix_object, types=None) -> dict:
350
352
"type" : object_ref_result ["entity_type" ],
351
353
}
352
354
elif "observed-data" not in object_ref :
353
- object_ref_result = self .opencti .opencti_stix_object_or_stix_relationship .read (
354
- id = object_ref
355
+ object_ref_result = (
356
+ self .opencti .opencti_stix_object_or_stix_relationship .read (
357
+ id = object_ref
358
+ )
355
359
)
356
360
if object_ref_result is not None :
357
361
self .mapping_cache [object_ref ] = {
@@ -390,14 +394,18 @@ def extract_embedded_relationships(self, stix_object, types=None) -> dict:
390
394
self .mapping_cache [url ] = {"id" : external_reference_id }
391
395
external_references_ids .append (external_reference_id )
392
396
393
- if stix_object ["type" ] in [
394
- "threat-actor" ,
395
- "intrusion-set" ,
396
- "campaign" ,
397
- "x-opencti-incident" ,
398
- "malware" ,
399
- "relationship" ,
400
- ] and (types is None or "report" in types ):
397
+ if (
398
+ stix_object ["type" ]
399
+ in [
400
+ "threat-actor" ,
401
+ "intrusion-set" ,
402
+ "campaign" ,
403
+ "x-opencti-incident" ,
404
+ "malware" ,
405
+ "relationship" ,
406
+ ]
407
+ and (types is None or "report" in types )
408
+ ):
401
409
# Add a corresponding report
402
410
# Extract date
403
411
try :
@@ -443,11 +451,13 @@ def extract_embedded_relationships(self, stix_object, types=None) -> dict:
443
451
"marking_tlpwhite"
444
452
]
445
453
else :
446
- object_marking_ref_result = self .opencti .marking_definition .read (
447
- filters = [
448
- {"key" : "definition_type" , "values" : ["TLP" ]},
449
- {"key" : "definition" , "values" : ["TLP:WHITE" ]},
450
- ]
454
+ object_marking_ref_result = (
455
+ self .opencti .marking_definition .read (
456
+ filters = [
457
+ {"key" : "definition_type" , "values" : ["TLP" ]},
458
+ {"key" : "definition" , "values" : ["TLP:WHITE" ]},
459
+ ]
460
+ )
451
461
)
452
462
self .mapping_cache ["marking_tlpwhite" ] = {
453
463
"id" : object_marking_ref_result ["id" ]
@@ -551,7 +561,8 @@ def import_object(self, stix_object, update=False, types=None) -> list:
551
561
stix_object ["type" ] = "location"
552
562
553
563
do_import = importer .get (
554
- stix_object ["type" ], lambda ** kwargs : self .unknown_type (stix_object ),
564
+ stix_object ["type" ],
565
+ lambda ** kwargs : self .unknown_type (stix_object ),
555
566
)
556
567
stix_object_results = do_import (
557
568
stixObject = stix_object , extras = extras , update = update
@@ -802,14 +813,15 @@ def import_sighting(self, stix_sighting, from_id, to_id, update=False, types=Non
802
813
if from_id in self .mapping_cache :
803
814
final_from_id = self .mapping_cache [from_id ]["id" ]
804
815
else :
805
- stix_object_result = self . opencti . opencti_stix_object_or_stix_relationship . read (
806
- id = from_id
816
+ stix_object_result = (
817
+ self . opencti . opencti_stix_object_or_stix_relationship . read ( id = from_id )
807
818
)
808
819
if stix_object_result is not None :
809
820
final_from_id = stix_object_result ["id" ]
810
821
else :
811
822
self .opencti .log (
812
- "error" , "From ref of the sithing not found, doing nothing..." ,
823
+ "error" ,
824
+ "From ref of the sithing not found, doing nothing..." ,
813
825
)
814
826
return None
815
827
@@ -819,14 +831,15 @@ def import_sighting(self, stix_sighting, from_id, to_id, update=False, types=Non
819
831
if to_id in self .mapping_cache :
820
832
final_to_id = self .mapping_cache [to_id ]["id" ]
821
833
else :
822
- stix_object_result = self . opencti . opencti_stix_object_or_stix_relationship . read (
823
- id = to_id
834
+ stix_object_result = (
835
+ self . opencti . opencti_stix_object_or_stix_relationship . read ( id = to_id )
824
836
)
825
837
if stix_object_result is not None :
826
838
final_to_id = stix_object_result ["id" ]
827
839
else :
828
840
self .opencti .log (
829
- "error" , "To ref of the sithing not found, doing nothing..." ,
841
+ "error" ,
842
+ "To ref of the sithing not found, doing nothing..." ,
830
843
)
831
844
return None
832
845
date = datetime .datetime .today ().strftime ("%Y-%m-%dT%H:%M:%SZ" )
0 commit comments