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

Commit 0523161

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

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

pycti/entities/opencti_indicator.py

Lines changed: 16 additions & 2 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)
@@ -350,6 +351,7 @@ def create(self, **kwargs):
350351
entity_type
351352
name
352353
description
354+
score
353355
... on Indicator {
354356
observableRefs {
355357
edges {
@@ -385,17 +387,26 @@ def create(self, **kwargs):
385387
if object_result is not None:
386388
if update:
387389
# name
388-
if object_result["name"] != name:
390+
if name is not None and object_result["name"] != name:
389391
self.opencti.stix_domain_entity.update_field(
390392
id=object_result["id"], key="name", value=name
391393
)
392394
object_result["name"] = name
393395
# description
394-
if object_result["description"] != description:
396+
if (
397+
description is not None
398+
and object_result["description"] != description
399+
):
395400
self.opencti.stix_domain_entity.update_field(
396401
id=object_result["id"], key="description", value=description
397402
)
398403
object_result["description"] = description
404+
# score
405+
if score is not None and object_result["score"] != score:
406+
self.opencti.stix_domain_entity.update_field(
407+
id=object_result["id"], key="score", value=score
408+
)
409+
object_result["score"] = score
399410
return object_result
400411
else:
401412
return self.create_raw(
@@ -406,6 +417,7 @@ def create(self, **kwargs):
406417
pattern_type=pattern_type,
407418
valid_from=valid_from,
408419
valid_until=valid_until,
420+
score=score,
409421
id=id,
410422
stix_id_key=stix_id_key,
411423
created=created,
@@ -518,6 +530,8 @@ def to_stix2(self, **kwargs):
518530
indicator["modified"] = self.opencti.stix2.format_date(entity["modified"])
519531
if self.opencti.not_empty(entity["alias"]):
520532
indicator[CustomProperties.ALIASES] = entity["alias"]
533+
if self.opencti.not_empty(entity["score"]):
534+
indicator[CustomProperties.SCORE] = entity["score"]
521535
indicator[CustomProperties.ID] = entity["id"]
522536
return self.opencti.stix2.prepare_export(
523537
entity, indicator, mode, max_marking_definition_entity

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ setuptools==46.1.3
44
python-dateutil==2.8.1
55
datefinder==0.7.0
66
stix2==1.4.0
7-
pytz==2019.3
7+
pytz==2020.1
88
pika==1.1.0
99
stix2-validator==1.1.2
1010
black==19.10b0

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from setuptools import setup
66
from setuptools.command.install import install
77

8-
VERSION = "3.2.1"
8+
VERSION = "3.2.2"
99

1010
with open("README.md", "r") as fh:
1111
long_description = fh.read()
@@ -56,7 +56,7 @@ def run(self):
5656
"datefinder==0.7.0",
5757
"stix2==1.4.0",
5858
"stix2-validator==1.1.2",
59-
"pytz==2019.3",
59+
"pytz==2020.1",
6060
"pika==1.1.0",
6161
"python-magic==0.4.15;sys.platform=='linux' or sys.platform=='darwin'",
6262
"python-magic-bin==0.4.14;sys.platform=='win32'",

0 commit comments

Comments
 (0)