@@ -1315,9 +1315,45 @@ def import_sighting(
13151315
13161316 # Create the sighting
13171317
1318- final_from_id = from_id
1319- final_to_id = to_id
1318+ ### Get the FROM
1319+ if from_id in self .mapping_cache :
1320+ final_from_id = self .mapping_cache [from_id ]["id" ]
1321+ else :
1322+ stix_object_result = (
1323+ self .opencti .opencti_stix_object_or_stix_relationship .read (id = from_id )
1324+ )
1325+ if stix_object_result is not None :
1326+ final_from_id = stix_object_result ["id" ]
1327+ self .mapping_cache [from_id ] = {
1328+ "id" : stix_object_result ["id" ],
1329+ "entity_type" : stix_object_result ["entity_type" ],
1330+ }
1331+ else :
1332+ self .opencti .app_logger .error (
1333+ "From ref of the sighting not found, doing nothing..."
1334+ )
1335+ return None
13201336
1337+ ### Get the TO
1338+ final_to_id = None
1339+ if to_id :
1340+ if to_id in self .mapping_cache :
1341+ final_to_id = self .mapping_cache [to_id ]["id" ]
1342+ else :
1343+ stix_object_result = (
1344+ self .opencti .opencti_stix_object_or_stix_relationship .read (id = to_id )
1345+ )
1346+ if stix_object_result is not None :
1347+ final_to_id = stix_object_result ["id" ]
1348+ self .mapping_cache [to_id ] = {
1349+ "id" : stix_object_result ["id" ],
1350+ "entity_type" : stix_object_result ["entity_type" ],
1351+ }
1352+ else :
1353+ self .opencti .app_logger .error (
1354+ "To ref of the sighting not found, doing nothing..."
1355+ )
1356+ return None
13211357 if (
13221358 "x_opencti_negative" not in stix_sighting
13231359 and self .opencti .get_attribute_in_extension ("negative" , stix_sighting )
0 commit comments