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

Commit eae0609

Browse files
authored
[client] add reliability in Report (#opencti/2362)
1 parent 8c6390c commit eae0609

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

pycti/entities/opencti_identity.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(self, opencti):
3333
roles
3434
contact_information
3535
x_opencti_aliases
36+
x_opencti_reliability
3637
created
3738
modified
3839
objectLabel {
@@ -47,7 +48,6 @@ def __init__(self, opencti):
4748
}
4849
... on Organization {
4950
x_opencti_organization_type
50-
x_opencti_reliability
5151
}
5252
... on Individual {
5353
x_opencti_firstname
@@ -115,14 +115,14 @@ def __init__(self, opencti):
115115
name
116116
description
117117
x_opencti_aliases
118+
x_opencti_reliability
118119
contact_information
119120
... on Individual {
120121
x_opencti_firstname
121122
x_opencti_lastname
122123
}
123124
... on Organization {
124125
x_opencti_organization_type
125-
x_opencti_reliability
126126
}
127127
importFiles {
128128
edges {
@@ -355,7 +355,23 @@ def create(self, **kwargs):
355355
"""
356356
input_variables["x_opencti_firstname"] = x_opencti_firstname
357357
input_variables["x_opencti_lastname"] = x_opencti_lastname
358+
input_variables["x_opencti_reliability"] = x_opencti_reliability
358359
result_data_field = "individualAdd"
360+
elif type == IdentityTypes.SYSTEM.value:
361+
query = """
362+
mutation SystemAdd($input: SystemAddInput!) {
363+
systemAdd(input: $input) {
364+
id
365+
standard_id
366+
entity_type
367+
parent_types
368+
}
369+
}
370+
"""
371+
input_variables["x_opencti_firstname"] = x_opencti_firstname
372+
input_variables["x_opencti_lastname"] = x_opencti_lastname
373+
input_variables["x_opencti_reliability"] = x_opencti_reliability
374+
result_data_field = "systemAdd"
359375
else:
360376
query = """
361377
mutation IdentityAdd($input: IdentityAddInput!) {

pycti/entities/opencti_report.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, opencti):
3434
roles
3535
contact_information
3636
x_opencti_aliases
37+
x_opencti_reliability
3738
created
3839
modified
3940
objectLabel {
@@ -48,7 +49,6 @@ def __init__(self, opencti):
4849
}
4950
... on Organization {
5051
x_opencti_organization_type
51-
x_opencti_reliability
5252
}
5353
... on Individual {
5454
x_opencti_firstname
@@ -109,6 +109,7 @@ def __init__(self, opencti):
109109
}
110110
}
111111
revoked
112+
x_opencti_reliability
112113
confidence
113114
created
114115
modified
@@ -465,6 +466,7 @@ def create(self, **kwargs):
465466
description = kwargs.get("description", None)
466467
report_types = kwargs.get("report_types", None)
467468
published = kwargs.get("published", None)
469+
x_opencti_reliability = kwargs.get("x_opencti_reliability", None)
468470
x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None)
469471
granted_refs = kwargs.get("objectOrganization", None)
470472
update = kwargs.get("update", False)
@@ -501,6 +503,7 @@ def create(self, **kwargs):
501503
"description": description,
502504
"report_types": report_types,
503505
"published": published,
506+
"x_opencti_reliability": x_opencti_reliability,
504507
"x_opencti_stix_ids": x_opencti_stix_ids,
505508
"update": update,
506509
}
@@ -620,6 +623,10 @@ def import_from_stix2(self, **kwargs):
620623
stix_object["granted_refs"] = self.opencti.get_attribute_in_extension(
621624
"granted_refs", stix_object
622625
)
626+
if "x_opencti_reliability" not in stix_object:
627+
stix_object[
628+
"x_opencti_reliability"
629+
] = self.opencti.get_attribute_in_extension("reliability", stix_object)
623630

624631
return self.create(
625632
stix_id=stix_object["id"],
@@ -658,6 +665,9 @@ def import_from_stix2(self, **kwargs):
658665
x_opencti_stix_ids=stix_object["x_opencti_stix_ids"]
659666
if "x_opencti_stix_ids" in stix_object
660667
else None,
668+
x_opencti_reliability=stix_object["x_opencti_reliability"]
669+
if "x_opencti_reliability" in stix_object
670+
else None,
661671
objectOrganization=stix_object["x_opencti_granted_refs"]
662672
if "x_opencti_granted_refs" in stix_object
663673
else None,

tests/cases/entities.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def case_identity_individual(api_client):
3535
def case_identity_sector(api_client):
3636
return IdentitySectorTest(api_client)
3737

38+
@staticmethod
39+
def case_identity_system(api_client):
40+
return IdentitySystemTest(api_client)
41+
3842
@staticmethod
3943
def case_incident(api_client):
4044
return IncidentTest(api_client)
@@ -238,6 +242,15 @@ def data(self) -> Dict:
238242
}
239243

240244

245+
class IdentitySystemTest(IdentityTest):
246+
def data(self) -> Dict:
247+
return {
248+
"type": IdentityTypes.SYSTEM.value,
249+
"name": "System A",
250+
"description": "The system A",
251+
}
252+
253+
241254
class IndicatorTest(EntityTest):
242255
def setup(self):
243256
self.marking_definition_green = self.api_client.marking_definition.read(

0 commit comments

Comments
 (0)