Skip to content

Commit 5e64db6

Browse files
author
Samuel Hassine
committed
[client] Get all possible attributes in generic requests
1 parent 8c2d7e9 commit 5e64db6

File tree

4 files changed

+109
-12
lines changed

4 files changed

+109
-12
lines changed

pycti/entities/opencti_identity.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,20 @@ def create(self, **kwargs):
230230
)
231231
if object_result is not None:
232232
if update:
233-
self.opencti.stix_domain_entity.update_field(id=object_result['id'], key='name', value=name)
234-
object_result['name'] = name
235-
self.opencti.stix_domain_entity.update_field(
236-
id=object_result['id'],
237-
key='description',
238-
value=description
239-
)
240-
object_result['description'] = description
241-
if alias is not None:
233+
# name
234+
if object_result['name'] != name:
235+
self.opencti.stix_domain_entity.update_field(id=object_result['id'], key='name', value=name)
236+
object_result['name'] = name
237+
# description
238+
if object_result['description'] != description:
239+
self.opencti.stix_domain_entity.update_field(
240+
id=object_result['id'],
241+
key='description',
242+
value=description
243+
)
244+
object_result['description'] = description
245+
# alias
246+
if alias is not None and object_result['alias'] != alias:
242247
if 'alias' in object_result:
243248
new_aliases = object_result['alias'] + list(set(alias) - set(object_result['alias']))
244249
else:

pycti/entities/opencti_report.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,6 @@ def add_stix_entity(self, **kwargs):
387387
report = kwargs.get('report', None)
388388
entity_id = kwargs.get('entity_id', None)
389389
if id is not None and entity_id is not None:
390-
self.opencti.log('info',
391-
'Adding Stix-Entity {' + entity_id + '} to Report {' + id + '}')
392390
if report is None:
393391
report = self.read(id=id)
394392
if report is None:
@@ -404,6 +402,10 @@ def add_stix_entity(self, **kwargs):
404402
if entity_id in refs_ids:
405403
return True
406404
else:
405+
self.opencti.log(
406+
'info',
407+
'Adding Stix-Entity {' + entity_id + '} to Report {' + id + '}'
408+
)
407409
query = """
408410
mutation ReportEdit($id: ID!, $input: RelationAddInput) {
409411
reportEdit(id: $id) {

pycti/entities/opencti_stix_domain_entity.py

+61-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,67 @@ def __init__(self, opencti):
8282
id
8383
}
8484
}
85-
}
85+
}
86+
... on AttackPattern {
87+
platform
88+
required_permission
89+
external_id
90+
}
91+
... on ThreatActor {
92+
goal
93+
sophistication
94+
resource_level
95+
primary_motivation
96+
secondary_motivation
97+
personal_motivation
98+
}
99+
... on IntrusionSet {
100+
first_seen
101+
last_seen
102+
goal
103+
sophistication
104+
resource_level
105+
primary_motivation
106+
secondary_motivation
107+
}
108+
... on Campaign {
109+
objective
110+
first_seen
111+
last_seen
112+
}
113+
... on Incident {
114+
objective
115+
first_seen
116+
last_seen
117+
}
118+
... on Malware {
119+
killChainPhases {
120+
edges {
121+
node {
122+
id
123+
entity_type
124+
stix_id_key
125+
kill_chain_name
126+
phase_name
127+
phase_order
128+
created
129+
modified
130+
}
131+
relation {
132+
id
133+
}
134+
}
135+
}
136+
}
137+
... on Tool {
138+
tool_version
139+
}
140+
... on Report {
141+
report_class
142+
published
143+
object_status
144+
source_confidence_level
145+
}
86146
"""
87147

88148
"""

pycti/entities/opencti_stix_entity.py

+30
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ def __init__(self, opencti):
6969
}
7070
}
7171
... on AttackPattern {
72+
platform
73+
required_permission
74+
external_id
7275
killChainPhases {
7376
edges {
7477
node {
@@ -87,6 +90,33 @@ def __init__(self, opencti):
8790
}
8891
}
8992
}
93+
... on ThreatActor {
94+
goal
95+
sophistication
96+
resource_level
97+
primary_motivation
98+
secondary_motivation
99+
personal_motivation
100+
}
101+
... on IntrusionSet {
102+
first_seen
103+
last_seen
104+
goal
105+
sophistication
106+
resource_level
107+
primary_motivation
108+
secondary_motivation
109+
}
110+
... on Campaign {
111+
objective
112+
first_seen
113+
last_seen
114+
}
115+
... on Incident {
116+
objective
117+
first_seen
118+
last_seen
119+
}
90120
... on Malware {
91121
killChainPhases {
92122
edges {

0 commit comments

Comments
 (0)