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

Commit 52026fb

Browse files
committed
[client] handle delete operation depending on type
1 parent 4244f3c commit 52026fb

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
OBSERVABLES_VALUE_INT,
3232
STIX_CYBER_OBSERVABLE_MAPPING,
3333
STIX_OBJECTS,
34+
STIX_META_OBJECTS,
35+
STIX_CORE_OBJECTS,
3436
)
3537

3638
datefinder.ValueError = ValueError, OverflowError
@@ -2542,9 +2544,17 @@ def organization_unshare(self, item):
25422544

25432545
def element_operation_delete(self, item, operation):
25442546
# If data is stix, just use the generic stix function for deletion
2545-
if item["type"] in STIX_OBJECTS:
2546-
force_delete = operation == "delete_force"
2547+
force_delete = operation == "delete_force"
2548+
if item["type"] == "relationship":
2549+
self.opencti.stix_core_relationship.delete(id=item["id"])
2550+
elif item["type"] == "sighting":
2551+
self.opencti.stix_sighting_relationship.delete(id=item["id"])
2552+
elif item["type"] in STIX_META_OBJECTS:
25472553
self.opencti.stix.delete(id=item["id"], force_delete=force_delete)
2554+
elif item["type"] in list(STIX_CYBER_OBSERVABLE_MAPPING.keys()):
2555+
self.opencti.stix_cyber_observable.delete(id=item["id"])
2556+
elif item["type"] in STIX_CORE_OBJECTS:
2557+
self.opencti.stix_core_object.delete(id=item["id"])
25482558
else:
25492559
# Element is not knowledge we need to use the right api
25502560
stix_helper = self.get_internal_helper().get(item["type"])

pycti/utils/opencti_stix2_utils.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,54 @@
1717
"publicdashboard",
1818
]
1919

20+
STIX_META_OBJECTS = [
21+
"label",
22+
"vocabulary",
23+
"kill-chain-phase",
24+
]
25+
26+
STIX_CORE_OBJECTS = [
27+
"attack-pattern",
28+
"campaign",
29+
"case-incident",
30+
"x-opencti-case-incident",
31+
"case-rfi",
32+
"x-opencti-case-rfi",
33+
"case-rft",
34+
"x-opencti-case-rft",
35+
"channel",
36+
"course-of-action",
37+
"data-component",
38+
"x-mitre-data-component",
39+
"data-source",
40+
"x-mitre-data-source",
41+
"event",
42+
"external-reference",
43+
"feedback",
44+
"x-opencti-feedback",
45+
"grouping",
46+
"identity",
47+
"incident",
48+
"indicator",
49+
"infrastructure",
50+
"intrusion-set",
51+
"language",
52+
"location",
53+
"malware",
54+
"malware-analysis",
55+
"marking-definition",
56+
"narrative",
57+
"note",
58+
"observed-data",
59+
"opinion",
60+
"report",
61+
"task",
62+
"x-opencti-task",
63+
"threat-actor",
64+
"tool",
65+
"vulnerability",
66+
]
67+
2068
SUPPORTED_STIX_ENTITY_OBJECTS = [
2169
"attack-pattern",
2270
"campaign",

0 commit comments

Comments
 (0)