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

Commit d94be96

Browse files
author
Samuel Hassine
committed
[client] Add sightings
1 parent 6fa7421 commit d94be96

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pycti/entities/opencti_note.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,20 @@ def import_from_stix2(self, **kwargs):
587587
extras = kwargs.get("extras", {})
588588
update = kwargs.get("update", False)
589589
if stix_object is not None:
590+
if CustomProperties.NAME in stix_object:
591+
name = stix_object[CustomProperties.NAME]
592+
elif "abstract" in stix_object:
593+
name = stix_object["abstract"]
594+
else:
595+
name = ""
590596
return self.create(
591597
description=self.opencti.stix2.convert_markdown(stix_object["abstract"])
592598
if "abstract" in stix_object
593599
else "",
594600
content=self.opencti.stix2.convert_markdown(stix_object["content"])
595601
if "content" in stix_object
596602
else "",
597-
name=stix_object[CustomProperties.NAME]
598-
if CustomProperties.NAME in stix_object
599-
else "",
603+
name=name,
600604
graph_data=stix_object[CustomProperties.GRAPH_DATA]
601605
if CustomProperties.GRAPH_DATA in stix_object
602606
else "",
@@ -647,6 +651,8 @@ def to_stix2(self, **kwargs):
647651
note["labels"] = ["note"]
648652
if self.opencti.not_empty(entity["description"]):
649653
note["abstract"] = entity["description"]
654+
elif self.opencti.not_empty(entity["name"]):
655+
note["abstract"] = entity["name"]
650656
note["created"] = self.opencti.stix2.format_date(entity["created"])
651657
note["modified"] = self.opencti.stix2.format_date(entity["modified"])
652658
if self.opencti.not_empty(entity["alias"]):

pycti/entities/opencti_stix_sighting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def create(self, **kwargs):
357357
stix_sighting_result = self.read(
358358
id=stix_id_key, customAttributes=custom_attributes
359359
)
360-
if stix_sighting_result is None:
360+
if stix_sighting_result is None and to_id is not None:
361361
if (
362362
ignore_dates is False
363363
and first_seen is not None

0 commit comments

Comments
 (0)