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

Commit 1e0d9d9

Browse files
committed
[client] Fix notes/reports helper in SDOs and SCOs
1 parent d8af928 commit 1e0d9d9

File tree

3 files changed

+350
-450
lines changed

3 files changed

+350
-450
lines changed

pycti/entities/opencti_stix_core_object.py

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,143 @@ def list_files(self, **kwargs):
8383
result = self.opencti.query(query, {"id": id})
8484
entity = self.opencti.process_multiple_fields(result["data"]["stixCoreObject"])
8585
return entity["importFiles"]
86+
87+
"""
88+
Get the reports about a Stix-Core-Object object
89+
90+
:param id: the id of the Stix-Core-Object
91+
:return List of reports
92+
"""
93+
94+
def reports(self, **kwargs):
95+
id = kwargs.get("id", None)
96+
if id is not None:
97+
self.opencti.log(
98+
"info",
99+
"Getting reports of the Stix-Core-Object {" + id + "}.",
100+
)
101+
query = """
102+
query StixCoreObject($id: String!) {
103+
stixCoreObject(id: $id) {
104+
reports {
105+
edges {
106+
node {
107+
id
108+
standard_id
109+
entity_type
110+
parent_types
111+
spec_version
112+
created_at
113+
updated_at
114+
createdBy {
115+
... on Identity {
116+
id
117+
standard_id
118+
entity_type
119+
parent_types
120+
spec_version
121+
identity_class
122+
name
123+
description
124+
roles
125+
contact_information
126+
x_opencti_aliases
127+
created
128+
modified
129+
objectLabel {
130+
edges {
131+
node {
132+
id
133+
value
134+
color
135+
}
136+
}
137+
}
138+
}
139+
... on Organization {
140+
x_opencti_organization_type
141+
x_opencti_reliability
142+
}
143+
... on Individual {
144+
x_opencti_firstname
145+
x_opencti_lastname
146+
}
147+
}
148+
objectMarking {
149+
edges {
150+
node {
151+
id
152+
standard_id
153+
entity_type
154+
definition_type
155+
definition
156+
created
157+
modified
158+
x_opencti_order
159+
x_opencti_color
160+
}
161+
}
162+
}
163+
objectLabel {
164+
edges {
165+
node {
166+
id
167+
value
168+
color
169+
}
170+
}
171+
}
172+
externalReferences {
173+
edges {
174+
node {
175+
id
176+
standard_id
177+
entity_type
178+
source_name
179+
description
180+
url
181+
hash
182+
external_id
183+
created
184+
modified
185+
importFiles {
186+
edges {
187+
node {
188+
id
189+
name
190+
size
191+
metaData {
192+
mimetype
193+
version
194+
}
195+
}
196+
}
197+
}
198+
}
199+
}
200+
}
201+
revoked
202+
confidence
203+
created
204+
modified
205+
name
206+
description
207+
report_types
208+
published
209+
}
210+
}
211+
}
212+
}
213+
}
214+
"""
215+
result = self.opencti.query(query, {"id": id})
216+
processed_result = self.opencti.process_multiple_fields(
217+
result["data"]["stixCoreObject"]
218+
)
219+
if processed_result:
220+
return processed_result["reports"]
221+
else:
222+
return []
223+
else:
224+
self.opencti.log("error", "Missing parameters: id")
225+
return None

0 commit comments

Comments
 (0)