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
2 changes: 2 additions & 0 deletions pycti/api/opencti_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pycti import __version__
from pycti.api.opencti_api_connector import OpenCTIApiConnector
from pycti.api.opencti_api_draft import OpenCTIApiDraft
from pycti.api.opencti_api_internal_file import OpenCTIApiInternalFile
from pycti.api.opencti_api_notification import OpenCTIApiNotification
from pycti.api.opencti_api_pir import OpenCTIApiPir
from pycti.api.opencti_api_playbook import OpenCTIApiPlaybook
Expand Down Expand Up @@ -182,6 +183,7 @@ def __init__(
self.connector = OpenCTIApiConnector(self)
self.stix2 = OpenCTIStix2(self)
self.pir = OpenCTIApiPir(self)
self.internal_file = OpenCTIApiInternalFile(self)

# Define the entities
self.vocabulary = Vocabulary(self)
Expand Down
26 changes: 26 additions & 0 deletions pycti/api/opencti_api_internal_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class OpenCTIApiInternalFile:
"""OpenCTIApiInternalFile"""

def __init__(self, api):
self.api = api

def delete(self, **kwargs):
item = kwargs.get("item", None)
file_name = self.api.get_attribute_in_extension("id", item)
if file_name is not None:
query = """
mutation InternalFileDelete($fileName: String) {
deleteImport(fileName: $fileName)
}
"""
self.api.query(
query,
{
"fileName": file_name,
},
)
else:
self.api.app_logger.error(
"[stix_internal_file] Cant delete internal file, missing parameters: fileName"
)
return None
2 changes: 1 addition & 1 deletion pycti/api/opencti_api_playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def delete(self, **kwargs):
},
)
else:
self.opencti.app_logger.error(
self.api.app_logger.error(
"[stix_playbook] Cant delete playbook, missing parameters: id"
)
return None
3 changes: 2 additions & 1 deletion pycti/utils/opencti_stix2.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ def get_internal_helper(self):
"workspace": self.opencti.workspace,
"publicdashboard": self.opencti.public_dashboard,
"notification": self.opencti.notification,
"internalfile": self.opencti.internal_file,
}

def generate_standard_id_from_stix(self, data):
Expand Down Expand Up @@ -2599,7 +2600,7 @@ def element_operation_delete(self, item, operation):
# 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"])
stix_helper.delete(id=item["id"], item=item)
else:
raise ValueError(
"Delete operation or not found stix helper", {"type": item["type"]}
Expand Down