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

Commit 48e0797

Browse files
committed
[client] Fix IDs of generated report from external refs
1 parent 65794bb commit 48e0797

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pycti/entities/opencti_report.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,19 @@ def generate_id(name, published):
466466
id = str(uuid.uuid5(uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7"), data))
467467
return "report--" + id
468468

469+
@staticmethod
470+
def generate_fixed_fake_id(name, published=None):
471+
name = name.lower().strip()
472+
if isinstance(published, datetime.datetime):
473+
published = published.isoformat()
474+
if published is not None:
475+
data = {"name": name, "published": published, "fake": "fake"}
476+
else:
477+
data = {"name": name, "fake": "fake"}
478+
data = canonicalize(data, utf8=False)
479+
id = str(uuid.uuid5(uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7"), data))
480+
return "report--" + id
481+
469482
"""
470483
List Report objects
471484

pycti/utils/opencti_stix2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ def extract_embedded_relationships(
680680

681681
author = self.resolve_author(title)
682682
report = self.opencti.report.create(
683+
id=self.opencti.report.generate_fixed_fake_id(
684+
title, published
685+
),
683686
name=title,
684687
createdBy=author["id"] if author is not None else None,
685688
objectMarking=[object_marking_ref_result["id"]],

0 commit comments

Comments
 (0)