@@ -2418,6 +2418,9 @@ def apply_patch_files(self, item):
24182418 field_patch_files = next (
24192419 (op for op in field_patch if op ["key" ] == "x_opencti_files" ), None
24202420 )
2421+ item_id = self .opencti .get_attribute_in_extension ("id" , item )
2422+ if item_id is None :
2423+ item_id = item ["id" ]
24212424 do_add_file = self .opencti .stix_domain_object .add_file
24222425 if StixCyberObservableTypes .has_value (item ["type" ]):
24232426 do_add_file = self .opencti .stix_cyber_observable .add_file
@@ -2427,7 +2430,7 @@ def apply_patch_files(self, item):
24272430 for file in field_patch_files ["value" ]:
24282431 if "data" in file :
24292432 do_add_file (
2430- id = item [ "id" ] ,
2433+ id = item_id ,
24312434 file_name = file ["name" ],
24322435 version = file .get ("version" , None ),
24332436 data = base64 .b64decode (file ["data" ]),
@@ -2445,26 +2448,29 @@ def apply_patch(self, item):
24452448 field_patch_without_files = [
24462449 op for op in field_patch if op ["key" ] != "x_opencti_files"
24472450 ]
2451+ item_id = self .opencti .get_attribute_in_extension ("id" , item )
2452+ if item_id is None :
2453+ item_id = item ["id" ]
24482454 if len (field_patch_without_files ) > 0 :
24492455 if item ["type" ] == "relationship" :
24502456 self .opencti .stix_core_relationship .update_field (
2451- id = item [ "id" ] , input = field_patch_without_files
2457+ id = item_id , input = field_patch_without_files
24522458 )
24532459 elif item ["type" ] == "sighting" :
24542460 self .opencti .stix_sighting_relationship .update_field (
2455- id = item [ "id" ] , input = field_patch_without_files
2461+ id = item_id , input = field_patch_without_files
24562462 )
24572463 elif StixCyberObservableTypes .has_value (item ["type" ]):
24582464 self .opencti .stix_cyber_observable .update_field (
2459- id = item [ "id" ] , input = field_patch_without_files
2465+ id = item_id , input = field_patch_without_files
24602466 )
24612467 elif item ["type" ] == "external-reference" :
24622468 self .opencti .external_reference .update_field (
2463- id = item [ "id" ] , input = field_patch_without_files
2469+ id = item_id , input = field_patch_without_files
24642470 )
24652471 else :
24662472 self .opencti .stix_domain_object .update_field (
2467- id = item [ "id" ] , input = field_patch_without_files
2473+ id = item_id , input = field_patch_without_files
24682474 )
24692475 self .apply_patch_files (item )
24702476
0 commit comments