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

Commit 97daca0

Browse files
committed
[frontend] trials
1 parent 3461538 commit 97daca0

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

pycti/api/opencti_api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pycti.api.opencti_api_trash import OpenCTIApiTrash
1919
from pycti.api.opencti_api_work import OpenCTIApiWork
2020
from pycti.api.opencti_api_workspace import OpenCTIApiWorkspace
21+
from pycti.api.opencti_api_internal_file import OpenCTIApiInternalFile
2122
from pycti.entities.opencti_attack_pattern import AttackPattern
2223
from pycti.entities.opencti_campaign import Campaign
2324
from pycti.entities.opencti_capability import Capability
@@ -182,6 +183,7 @@ def __init__(
182183
self.connector = OpenCTIApiConnector(self)
183184
self.stix2 = OpenCTIStix2(self)
184185
self.pir = OpenCTIApiPir(self)
186+
self.internal_file = OpenCTIApiInternalFile(self)
185187

186188
# Define the entities
187189
self.vocabulary = Vocabulary(self)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class OpenCTIApiInternalFile:
2+
"""OpenCTIApiInternalFile"""
3+
4+
def __init__(self, api):
5+
self.api = api
6+
7+
def delete(self, **kwargs):
8+
fileName = kwargs.get("fileName", None)
9+
self.opencti.app_logger.info(
10+
"-------- fileName ----------",
11+
{"filename": fileName},
12+
)
13+
if fileName is not None:
14+
query = """
15+
mutation InternalFileDelete($fileName: String) {
16+
deleteImport(fileName: $fileName)
17+
}
18+
"""
19+
self.api.query(
20+
query,
21+
{
22+
"fileName": fileName,
23+
},
24+
)
25+
else:
26+
self.opencti.app_logger.error(
27+
"[stix_internal_file] Cant delete internal file, missing parameters: fileName"
28+
)
29+
return None

pycti/utils/opencti_stix2.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ def get_internal_helper(self):
941941
"workspace": self.opencti.workspace,
942942
"publicdashboard": self.opencti.public_dashboard,
943943
"notification": self.opencti.notification,
944+
"internalfile": self.opencti.internal_file
944945
}
945946

946947
def generate_standard_id_from_stix(self, data):
@@ -2598,7 +2599,22 @@ def element_operation_delete(self, item, operation):
25982599
else:
25992600
# Element is not knowledge we need to use the right api
26002601
stix_helper = self.get_internal_helper().get(item["type"])
2601-
if stix_helper and hasattr(stix_helper, "delete"):
2602+
2603+
self.opencti.app_logger.info(stix_helper)
2604+
self.opencti.app_logger.info(
2605+
"-------- TYPE ----------",
2606+
{"type": item["type"]},
2607+
)
2608+
if item["type"] == "internalfile":
2609+
self.opencti.app_logger.info(
2610+
"-------- internal file ----------",
2611+
{"type": item["type"]},
2612+
)
2613+
self.opencti.app_logger.info(item)
2614+
fileName = self.opencti.get_attribute_in_extension("id", item)
2615+
self.opencti.app_logger.info(fileName)
2616+
stix_helper.delete(fileName=item["fileName"])
2617+
elif stix_helper and hasattr(stix_helper, "delete"):
26022618
stix_helper.delete(id=item["id"])
26032619
else:
26042620
raise ValueError(

0 commit comments

Comments
 (0)