Skip to content

Commit 125752c

Browse files
author
Samuel Hassine
committed
[client] Enhance reports resolving
1 parent b991e2f commit 125752c

File tree

4 files changed

+85
-15
lines changed

4 files changed

+85
-15
lines changed

pycti/entities/opencti_report.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,12 @@ def create(self, **kwargs):
344344
value=graph_data
345345
)
346346
object_result['graph_data'] = graph_data
347-
if external_reference_id is not None:
348-
self.opencti.stix_entity.add_external_reference(
349-
id=object_result['id'],
350-
entity=object_result,
351-
external_reference_id=external_reference_id
352-
)
347+
if external_reference_id is not None:
348+
self.opencti.stix_entity.add_external_reference(
349+
id=object_result['id'],
350+
entity=object_result,
351+
external_reference_id=external_reference_id
352+
)
353353
return object_result
354354
else:
355355
report = self.create_raw(

pycti/entities/opencti_stix_domain_entity.py

+35
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,41 @@ def __init__(self, opencti):
142142
published
143143
object_status
144144
source_confidence_level
145+
objectRefs {
146+
edges {
147+
node {
148+
id
149+
stix_id_key
150+
entity_type
151+
}
152+
relation {
153+
id
154+
}
155+
}
156+
}
157+
observableRefs {
158+
edges {
159+
node {
160+
id
161+
stix_id_key
162+
entity_type
163+
}
164+
relation {
165+
id
166+
}
167+
}
168+
}
169+
relationRefs {
170+
edges {
171+
node {
172+
id
173+
stix_id_key
174+
}
175+
relation {
176+
id
177+
}
178+
}
179+
}
145180
}
146181
"""
147182

pycti/entities/opencti_stix_entity.py

+41
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,47 @@ def __init__(self, opencti):
133133
}
134134
}
135135
}
136+
... on Report {
137+
report_class
138+
published
139+
object_status
140+
source_confidence_level
141+
objectRefs {
142+
edges {
143+
node {
144+
id
145+
stix_id_key
146+
entity_type
147+
}
148+
relation {
149+
id
150+
}
151+
}
152+
}
153+
observableRefs {
154+
edges {
155+
node {
156+
id
157+
stix_id_key
158+
entity_type
159+
}
160+
relation {
161+
id
162+
}
163+
}
164+
}
165+
relationRefs {
166+
edges {
167+
node {
168+
id
169+
stix_id_key
170+
}
171+
relation {
172+
id
173+
}
174+
}
175+
}
176+
}
136177
... on StixRelation {
137178
killChainPhases {
138179
edges {

pycti/utils/opencti_stix2.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -261,24 +261,18 @@ def extract_embedded_relationships(self, stix_object, types=None):
261261

262262
if 'external_id' in external_reference:
263263
title = title + ' (' + external_reference['external_id'] + ')'
264+
265+
author = self.resolve_author(title)
264266
report = self.opencti.report.create(
265267
name=title,
266268
external_reference_id=external_reference_id,
267269
description=external_reference['description'] if 'description' in external_reference else '',
268270
published=published,
269271
report_class='Threat Report',
270272
object_status=2,
273+
createdByRef=author,
271274
update=True
272275
)
273-
# Resolve author
274-
author = self.resolve_author(title)
275-
if author is not None:
276-
self.opencti.stix_entity.update_created_by_ref(
277-
id=report['id'],
278-
entity=report,
279-
identity_id=author['id']
280-
)
281-
282276
# Add marking
283277
if 'marking_tlpwhite' in self.mapping_cache:
284278
object_marking_ref_result = self.mapping_cache['marking_tlpwhite']

0 commit comments

Comments
 (0)