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

Commit 4e662fb

Browse files
[client] background tasks to worker fixes (opencti #10274)
1 parent 3e4383d commit 4e662fb

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
from pycti.utils.opencti_stix2_update import OpenCTIStix2Update
3030
from pycti.utils.opencti_stix2_utils import (
3131
OBSERVABLES_VALUE_INT,
32+
STIX_CORE_OBJECTS,
3233
STIX_CYBER_OBSERVABLE_MAPPING,
33-
STIX_OBJECTS,
34+
STIX_META_OBJECTS,
3435
)
3536

3637
datefinder.ValueError = ValueError, OverflowError
@@ -2542,17 +2543,25 @@ def organization_unshare(self, item):
25422543

25432544
def element_operation_delete(self, item, operation):
25442545
# 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"
2546+
force_delete = operation == "delete_force"
2547+
if item["type"] == "relationship":
2548+
self.opencti.stix_core_relationship.delete(id=item["id"])
2549+
elif item["type"] == "sighting":
2550+
self.opencti.stix_sighting_relationship.delete(id=item["id"])
2551+
elif item["type"] in STIX_META_OBJECTS:
25472552
self.opencti.stix.delete(id=item["id"], force_delete=force_delete)
2553+
elif item["type"] in list(STIX_CYBER_OBSERVABLE_MAPPING.keys()):
2554+
self.opencti.stix_cyber_observable.delete(id=item["id"])
2555+
elif item["type"] in STIX_CORE_OBJECTS:
2556+
self.opencti.stix_core_object.delete(id=item["id"])
25482557
else:
25492558
# Element is not knowledge we need to use the right api
25502559
stix_helper = self.get_internal_helper().get(item["type"])
25512560
if stix_helper and hasattr(stix_helper, "delete"):
25522561
stix_helper.delete(id=item["id"])
25532562
else:
25542563
raise ValueError(
2555-
"Delete operation or no stix helper", {"type": item["type"]}
2564+
"Delete operation or not found stix helper", {"type": item["type"]}
25562565
)
25572566

25582567
def apply_opencti_operation(self, item, operation):

pycti/utils/opencti_stix2_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
"publicdashboard",
1818
]
1919

20-
SUPPORTED_STIX_ENTITY_OBJECTS = [
20+
STIX_META_OBJECTS = [
21+
"label",
22+
"vocabulary",
23+
"kill-chain-phase",
24+
]
25+
26+
STIX_CORE_OBJECTS = [
2127
"attack-pattern",
2228
"campaign",
2329
"case-incident",
@@ -42,8 +48,6 @@
4248
"indicator",
4349
"infrastructure",
4450
"intrusion-set",
45-
"kill-chain-phase",
46-
"label",
4751
"language",
4852
"location",
4953
"malware",
@@ -58,10 +62,11 @@
5862
"x-opencti-task",
5963
"threat-actor",
6064
"tool",
61-
"vocabulary",
6265
"vulnerability",
6366
]
6467

68+
SUPPORTED_STIX_ENTITY_OBJECTS = STIX_META_OBJECTS + STIX_CORE_OBJECTS
69+
6570
STIX_CYBER_OBSERVABLE_MAPPING = {
6671
"autonomous-system": "Autonomous-System",
6772
"directory": "Directory",

0 commit comments

Comments
 (0)