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

Commit 37fe03b

Browse files
author
Samuel Hassine
committed
[client] Migrate incident to native STIX
1 parent 33beeee commit 37fe03b

13 files changed

+33
-36
lines changed

pycti/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from .entities.opencti_intrusion_set import IntrusionSet
3131
from .entities.opencti_infrastructure import Infrastructure
3232
from .entities.opencti_campaign import Campaign
33-
from .entities.opencti_x_opencti_incident import XOpenCTIIncident
33+
from .entities.opencti_incident import Incident
3434
from .entities.opencti_malware import Malware
3535
from .entities.opencti_tool import Tool
3636
from .entities.opencti_vulnerability import Vulnerability
@@ -48,7 +48,7 @@
4848
from .utils.opencti_stix2_utils import (
4949
OpenCTIStix2Utils,
5050
SimpleObservable,
51-
StixXOpenCTIIncident,
51+
StixIncident,
5252
)
5353
from .utils.constants import StixCyberObservableTypes
5454

@@ -76,7 +76,7 @@
7676
"IntrusionSet",
7777
"Infrastructure",
7878
"Campaign",
79-
"XOpenCTIIncident",
79+
"Incident",
8080
"Malware",
8181
"Tool",
8282
"Vulnerability",
@@ -93,5 +93,5 @@
9393
"OpenCTIStix2Utils",
9494
"StixCyberObservableTypes",
9595
"SimpleObservable",
96-
"StixXOpenCTIIncident",
96+
"StixIncident",
9797
]

pycti/api/opencti_api_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from pycti.entities.opencti_intrusion_set import IntrusionSet
3535
from pycti.entities.opencti_infrastructure import Infrastructure
3636
from pycti.entities.opencti_campaign import Campaign
37-
from pycti.entities.opencti_x_opencti_incident import XOpenCTIIncident
37+
from pycti.entities.opencti_incident import Incident
3838
from pycti.entities.opencti_malware import Malware
3939
from pycti.entities.opencti_tool import Tool
4040
from pycti.entities.opencti_vulnerability import Vulnerability
@@ -127,7 +127,7 @@ def __init__(self, url, token, log_level="info", ssl_verify=False, proxies={}):
127127
self.intrusion_set = IntrusionSet(self)
128128
self.infrastructure = Infrastructure(self)
129129
self.campaign = Campaign(self)
130-
self.x_opencti_incident = XOpenCTIIncident(self)
130+
self.incident = Incident(self)
131131
self.malware = Malware(self)
132132
self.tool = Tool(self)
133133
self.vulnerability = Vulnerability(self)

pycti/entities/opencti_x_opencti_incident.py renamed to pycti/entities/opencti_incident.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44

55

6-
class XOpenCTIIncident:
6+
class Incident:
77
def __init__(self, opencti):
88
self.opencti = opencti
99
self.properties = """
@@ -127,8 +127,8 @@ def list(self, **kwargs):
127127
)
128128
query = (
129129
"""
130-
query XOpenCTIIncidents($filters: [XOpenCTIIncidentsFiltering], $search: String, $first: Int, $after: ID, $orderBy: XOpenCTIIncidentsOrdering, $orderMode: OrderingMode) {
131-
xOpenCTIIncidents(filters: $filters, search: $search, first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode) {
130+
query Incidents($filters: [IncidentsFiltering], $search: String, $first: Int, $after: ID, $orderBy: IncidentsOrdering, $orderMode: OrderingMode) {
131+
incidents(filters: $filters, search: $search, first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode) {
132132
edges {
133133
node {
134134
"""
@@ -159,7 +159,7 @@ def list(self, **kwargs):
159159
},
160160
)
161161
return self.opencti.process_multiple(
162-
result["data"]["xOpenCTIIncidents"], with_pagination
162+
result["data"]["incidents"], with_pagination
163163
)
164164

165165
"""
@@ -178,8 +178,8 @@ def read(self, **kwargs):
178178
self.opencti.log("info", "Reading Incident {" + id + "}.")
179179
query = (
180180
"""
181-
query XOpenCTIIncident($id: String!) {
182-
xOpenCTIIncident(id: $id) {
181+
query Incident($id: String!) {
182+
incident(id: $id) {
183183
"""
184184
+ (
185185
custom_attributes
@@ -192,9 +192,7 @@ def read(self, **kwargs):
192192
"""
193193
)
194194
result = self.opencti.query(query, {"id": id})
195-
return self.opencti.process_multiple_fields(
196-
result["data"]["xOpenCTIIncident"]
197-
)
195+
return self.opencti.process_multiple_fields(result["data"]["incident"])
198196
elif filters is not None:
199197
result = self.list(filters=filters)
200198
if len(result) > 0:
@@ -236,8 +234,8 @@ def create(self, **kwargs):
236234
if name is not None and description is not None:
237235
self.opencti.log("info", "Creating Incident {" + name + "}.")
238236
query = """
239-
mutation XOpenCTIIncidentAdd($input: XOpenCTIIncidentAddInput) {
240-
xOpenCTIIncidentAdd(input: $input) {
237+
mutation IncidentAdd($input: IncidentAddInput) {
238+
incidentAdd(input: $input) {
241239
id
242240
standard_id
243241
entity_type
@@ -269,9 +267,7 @@ def create(self, **kwargs):
269267
}
270268
},
271269
)
272-
return self.opencti.process_multiple_fields(
273-
result["data"]["xOpenCTIIncidentAdd"]
274-
)
270+
return self.opencti.process_multiple_fields(result["data"]["incidentAdd"])
275271
else:
276272
self.opencti.log("error", "Missing parameters: name and description")
277273

pycti/entities/opencti_note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, opencti):
164164
... on Vulnerability {
165165
name
166166
}
167-
... on XOpenCTIIncident {
167+
... on Incident {
168168
name
169169
}
170170
... on StixCoreRelationship {

pycti/entities/opencti_observed_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, opencti):
164164
... on Vulnerability {
165165
name
166166
}
167-
... on XOpenCTIIncident {
167+
... on Incident {
168168
name
169169
}
170170
... on StixCoreRelationship {

pycti/entities/opencti_opinion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, opencti):
164164
... on Vulnerability {
165165
name
166166
}
167-
... on XOpenCTIIncident {
167+
... on Incident {
168168
name
169169
}
170170
... on StixCoreRelationship {

pycti/entities/opencti_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def __init__(self, opencti):
169169
... on Vulnerability {
170170
name
171171
}
172-
... on XOpenCTIIncident {
172+
... on Incident {
173173
name
174174
}
175175
... on StixCoreRelationship {

pycti/entities/opencti_stix_core_relationship.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def __init__(self, opencti):
162162
... on Vulnerability {
163163
name
164164
}
165-
... on XOpenCTIIncident {
165+
... on Incident {
166166
name
167167
}
168168
... on StixCyberObservable {
@@ -243,7 +243,7 @@ def __init__(self, opencti):
243243
... on Vulnerability {
244244
name
245245
}
246-
... on XOpenCTIIncident {
246+
... on Incident {
247247
name
248248
}
249249
... on StixCyberObservable {

pycti/entities/opencti_stix_domain_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def __init__(self, opencti, file):
359359
x_opencti_integrity_impact
360360
x_opencti_availability_impact
361361
}
362-
... on XOpenCTIIncident {
362+
... on Incident {
363363
name
364364
description
365365
aliases

pycti/entities/opencti_stix_object_or_stix_relationship.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def __init__(self, opencti):
310310
x_opencti_integrity_impact
311311
x_opencti_availability_impact
312312
}
313-
... on XOpenCTIIncident {
313+
... on Incident {
314314
name
315315
description
316316
aliases

0 commit comments

Comments
 (0)