Skip to content

Commit 314dc94

Browse files
[client-python] Report Full export (STIX/JSON) doesn't include relationships (#669)
1 parent c0c2665 commit 314dc94

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

pycti/entities/opencti_stix_core_relationship.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ def read(self, **kwargs):
521521
start_time_stop = kwargs.get("startTimeStop", None)
522522
stop_time_start = kwargs.get("stopTimeStart", None)
523523
stop_time_stop = kwargs.get("stopTimeStop", None)
524+
filters = kwargs.get("filters", None)
524525
custom_attributes = kwargs.get("customAttributes", None)
525526
if id is not None:
526527
self.opencti.app_logger.info("Reading stix_core_relationship", {"id": id})
@@ -543,6 +544,12 @@ def read(self, **kwargs):
543544
return self.opencti.process_multiple_fields(
544545
result["data"]["stixCoreRelationship"]
545546
)
547+
elif filters is not None:
548+
result = self.list(filters=filters, customAttributes=custom_attributes)
549+
if len(result) > 0:
550+
return result[0]
551+
else:
552+
return None
546553
elif from_id is not None and to_id is not None:
547554
result = self.list(
548555
fromOrToId=from_or_to_id,

pycti/entities/opencti_stix_nested_ref_relationship.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def read(self, **kwargs):
178178
stop_time_start = kwargs.get("stopTimeStart", None)
179179
stop_time_stop = kwargs.get("stopTimeStop", None)
180180
custom_attributes = kwargs.get("customAttributes", None)
181+
filters = kwargs.get("filters", None)
181182
if id is not None:
182183
self.opencti.app_logger.info(
183184
"Reading stix_observable_relationship", {"id": id}
@@ -201,6 +202,12 @@ def read(self, **kwargs):
201202
return self.opencti.process_multiple_fields(
202203
result["data"]["stixRefRelationship"]
203204
)
205+
elif filters is not None:
206+
result = self.list(filters=filters, customAttributes=custom_attributes)
207+
if len(result) > 0:
208+
return result[0]
209+
else:
210+
return None
204211
else:
205212
result = self.list(
206213
fromOrToId=from_or_to_id,

pycti/entities/opencti_stix_object_or_stix_relationship.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ def __init__(self, opencti):
481481
def read(self, **kwargs):
482482
id = kwargs.get("id", None)
483483
custom_attributes = kwargs.get("customAttributes", None)
484+
filters = kwargs.get("filters", None)
484485
if id is not None:
485486
self.opencti.app_logger.info(
486487
"Reading StixObjectOrStixRelationship", {"id": id}
@@ -504,6 +505,12 @@ def read(self, **kwargs):
504505
return self.opencti.process_multiple_fields(
505506
result["data"]["stixObjectOrStixRelationship"]
506507
)
508+
elif filters is not None:
509+
result = self.list(filters=filters)
510+
if len(result) > 0:
511+
return result[0]
512+
else:
513+
return None
507514
else:
508515
self.opencti.app_logger.error("Missing parameters: id")
509516
return None

pycti/entities/opencti_stix_sighting_relationship.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ def read(self, **kwargs):
431431
last_seen_start = kwargs.get("lastSeenStart", None)
432432
last_seen_stop = kwargs.get("lastSeenStop", None)
433433
custom_attributes = kwargs.get("customAttributes", None)
434+
filters = kwargs.get("filters", None)
434435
if id is not None:
435436
self.opencti.app_logger.info("Reading stix_sighting", {"id": id})
436437
query = (
@@ -452,6 +453,12 @@ def read(self, **kwargs):
452453
return self.opencti.process_multiple_fields(
453454
result["data"]["stixSightingRelationship"]
454455
)
456+
elif filters is not None:
457+
result = self.list(filters=filters)
458+
if len(result) > 0:
459+
return result[0]
460+
else:
461+
return None
455462
elif from_id is not None and to_id is not None:
456463
result = self.list(
457464
fromOrToId=from_or_to_id,

0 commit comments

Comments
 (0)