Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pycti/utils/opencti_stix2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
from pycti.utils.opencti_stix2_update import OpenCTIStix2Update
from pycti.utils.opencti_stix2_utils import (
OBSERVABLES_VALUE_INT,
STIX_CORE_OBJECTS,
STIX_CYBER_OBSERVABLE_MAPPING,
STIX_OBJECTS,
STIX_META_OBJECTS,
)

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

def element_operation_delete(self, item, operation):
# If data is stix, just use the generic stix function for deletion
if item["type"] in STIX_OBJECTS:
force_delete = operation == "delete_force"
force_delete = operation == "delete_force"
if item["type"] == "relationship":
self.opencti.stix_core_relationship.delete(id=item["id"])
elif item["type"] == "sighting":
self.opencti.stix_sighting_relationship.delete(id=item["id"])
elif item["type"] in STIX_META_OBJECTS:
self.opencti.stix.delete(id=item["id"], force_delete=force_delete)
elif item["type"] in list(STIX_CYBER_OBSERVABLE_MAPPING.keys()):
self.opencti.stix_cyber_observable.delete(id=item["id"])
elif item["type"] in STIX_CORE_OBJECTS:
self.opencti.stix_core_object.delete(id=item["id"])
else:
# Element is not knowledge we need to use the right api
stix_helper = self.get_internal_helper().get(item["type"])
if stix_helper and hasattr(stix_helper, "delete"):
stix_helper.delete(id=item["id"])
else:
raise ValueError(
"Delete operation or no stix helper", {"type": item["type"]}
"Delete operation or not found stix helper", {"type": item["type"]}
)

def apply_opencti_operation(self, item, operation):
Expand Down
13 changes: 9 additions & 4 deletions pycti/utils/opencti_stix2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
"publicdashboard",
]

SUPPORTED_STIX_ENTITY_OBJECTS = [
STIX_META_OBJECTS = [
"label",
"vocabulary",
"kill-chain-phase",
]

STIX_CORE_OBJECTS = [
"attack-pattern",
"campaign",
"case-incident",
Expand All @@ -42,8 +48,6 @@
"indicator",
"infrastructure",
"intrusion-set",
"kill-chain-phase",
"label",
"language",
"location",
"malware",
Expand All @@ -58,10 +62,11 @@
"x-opencti-task",
"threat-actor",
"tool",
"vocabulary",
"vulnerability",
]

SUPPORTED_STIX_ENTITY_OBJECTS = STIX_META_OBJECTS + STIX_CORE_OBJECTS

STIX_CYBER_OBSERVABLE_MAPPING = {
"autonomous-system": "Autonomous-System",
"directory": "Directory",
Expand Down