Skip to content

Commit 4a487d5

Browse files
author
Samuel Hassine
committed
[client] Fix the export, notes/observables (OpenCTI-Platform#79)
1 parent 68fdde0 commit 4a487d5

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

examples/export_report_stix2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
opencti_api_client = OpenCTIApiClient(api_url, api_token)
1212

1313
# Get the report
14-
report = opencti_api_client.report.read(id="c5577c45-533e-4bc5-8428-6cc6274f2a01")
14+
report = opencti_api_client.report.read(id="5a3878d7-2949-4fd9-87c7-2a38c65bfa59")
1515

1616
# Create the bundle
1717
bundle = opencti_api_client.stix2.export_entity("report", report["id"], "full")

pycti/entities/opencti_stix_entity.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,10 @@ def reports(self, **kwargs):
845845
processed_result = self.opencti.process_multiple_fields(
846846
result["data"]["stixEntity"]
847847
)
848-
return processed_result["reports"]
848+
if processed_result:
849+
return processed_result["reports"]
850+
else:
851+
return []
849852
else:
850853
self.opencti.log("error", "Missing parameters: id")
851854
return None
@@ -995,7 +998,10 @@ def notes(self, **kwargs):
995998
processed_result = self.opencti.process_multiple_fields(
996999
result["data"]["stixEntity"]
9971000
)
998-
return processed_result["notes"]
1001+
if processed_result:
1002+
return processed_result["notes"]
1003+
else:
1004+
return []
9991005
else:
10001006
self.opencti.log("error", "Missing parameters: id")
10011007
return None

pycti/utils/opencti_stix2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def extract_embedded_relationships(self, stix_object, types=None):
327327
title = source_name
328328

329329
if "external_id" in external_reference:
330-
title = title + " (" + external_reference["external_id"] + ")"
330+
title = title + " (" + str(external_reference["external_id"]) + ")"
331331

332332
author = self.resolve_author(title)
333333
report = self.opencti.report.create(

0 commit comments

Comments
 (0)