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

Commit 17d3030

Browse files
author
Samuel Hassine
committed
[client] Add indicator score at creation (#69)
1 parent 37b2204 commit 17d3030

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pycti/entities/opencti_indicator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def create(self, **kwargs):
338338
pattern_type = kwargs.get("pattern_type", None)
339339
valid_from = kwargs.get("valid_from", None)
340340
valid_until = kwargs.get("valid_until", None)
341+
score = kwargs.get("score", None)
341342
id = kwargs.get("id", None)
342343
stix_id_key = kwargs.get("stix_id_key", None)
343344
created = kwargs.get("created", None)
@@ -396,6 +397,12 @@ def create(self, **kwargs):
396397
id=object_result["id"], key="description", value=description
397398
)
398399
object_result["description"] = description
400+
# score
401+
if object_result["score"] != score:
402+
self.opencti.stix_domain_entity.update_field(
403+
id=object_result["id"], key="score", value=score
404+
)
405+
object_result["score"] = score
399406
return object_result
400407
else:
401408
return self.create_raw(
@@ -406,6 +413,7 @@ def create(self, **kwargs):
406413
pattern_type=pattern_type,
407414
valid_from=valid_from,
408415
valid_until=valid_until,
416+
score=score,
409417
id=id,
410418
stix_id_key=stix_id_key,
411419
created=created,
@@ -518,6 +526,8 @@ def to_stix2(self, **kwargs):
518526
indicator["modified"] = self.opencti.stix2.format_date(entity["modified"])
519527
if self.opencti.not_empty(entity["alias"]):
520528
indicator[CustomProperties.ALIASES] = entity["alias"]
529+
if self.opencti.not_empty(entity["score"]):
530+
indicator[CustomProperties.SCORE] = entity["score"]
521531
indicator[CustomProperties.ID] = entity["id"]
522532
return self.opencti.stix2.prepare_export(
523533
entity, indicator, mode, max_marking_definition_entity

0 commit comments

Comments
 (0)