Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit fe78f85

Browse files
author
Samuel Hassine
committed
[client] Fix relation direction in STIX2 export
1 parent 7b94713 commit fe78f85

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,14 +1299,18 @@ def prepare_export(
12991299
return result
13001300
elif mode == "full":
13011301
# Get extra relations
1302-
stix_relations = self.opencti.stix_relation.list(fromId=entity["id"])
1302+
stix_relations = self.opencti.stix_relation.list(fromId=entity["id"], forceNatural=True)
13031303
for stix_relation in stix_relations:
13041304
if self.check_max_marking_definition(
13051305
max_marking_definition_entity, stix_relation["markingDefinitions"]
13061306
):
1307-
objects_to_get.append(stix_relation["to"])
1308-
if stix_relation["to"]["stix_id_key"] in observables_stix_ids:
1309-
stix_relation["to"]["stix_id_key"] = observable_object_data[
1307+
if stix_relation["to"]["id"] == entity["id"]:
1308+
other_side_entity = stix_relation["from"]
1309+
else:
1310+
other_side_entity = stix_relation["to"]
1311+
objects_to_get.append(other_side_entity)
1312+
if other_side_entity["stix_id_key"] in observables_stix_ids:
1313+
other_side_entity["stix_id_key"] = observable_object_data[
13101314
"observedData"
13111315
]["id"]
13121316
relation_object_data = self.opencti.stix_relation.to_stix2(

0 commit comments

Comments
 (0)