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

Commit e17091c

Browse files
committed
[client] PR review
1 parent 5bf7328 commit e17091c

File tree

9 files changed

+69
-34
lines changed

9 files changed

+69
-34
lines changed

pycti/api/opencti_api_playbook.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ def playbook_step_execution(self, playbook: dict, bundle: str):
3535

3636
def delete(self, **kwargs):
3737
id = kwargs.get("id", None)
38-
query = """
39-
mutation PlaybookDelete($id: ID!) {
40-
playbookDelete(id: $id)
41-
}
42-
"""
43-
self.api.query(
44-
query,
45-
{
46-
"id": id,
47-
},
48-
)
38+
if id is not None:
39+
query = """
40+
mutation PlaybookDelete($id: ID!) {
41+
playbookDelete(id: $id)
42+
}
43+
"""
44+
self.api.query(
45+
query,
46+
{
47+
"id": id,
48+
},
49+
)
50+
else:
51+
self.opencti.app_logger.error(
52+
"[stix_playbook] Cant delete playbook, missing parameters: id"
53+
)
54+
return None

pycti/api/opencti_api_public_dashboard.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ def __init__(self, api):
66

77
def delete(self, **kwargs):
88
id = kwargs.get("id", None)
9-
query = """
10-
mutation PublicDashboardDelete($id: ID!) {
11-
publicDashboardDelete(id: $id)
12-
}
13-
"""
14-
self.api.query(
15-
query,
16-
{
17-
"id": id,
18-
},
19-
)
9+
if id is not None:
10+
query = """
11+
mutation PublicDashboardDelete($id: ID!) {
12+
publicDashboardDelete(id: $id)
13+
}
14+
"""
15+
self.api.query(
16+
query,
17+
{
18+
"id": id,
19+
},
20+
)
21+
else:
22+
self.opencti.app_logger.error(
23+
"[stix_public_dashboard] Cant delete public dashboard, missing parameters: id"
24+
)
25+
return None

pycti/api/opencti_api_trash.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ def restore(self, operation_id: str):
1818
)
1919

2020
def delete(self, **kwargs):
21-
"""Delete a role given its ID
21+
"""Delete a trash item given its ID
2222
23-
:param id: ID for the role on the platform.
23+
:param id: ID for the delete operation on the platform.
2424
:type id: str
2525
"""
2626
id = kwargs.get("id", None)
2727
if id is None:
28-
self.api.admin_logger.error("[opencti_role] Missing parameter: id")
28+
self.api.admin_logger.error(
29+
"[opencti_trash] Cant confirm delete, missing parameter: id"
30+
)
2931
return None
30-
3132
query = """
3233
mutation DeleteOperationConfirm($id: ID!) {
3334
deleteOperationConfirm(id: $id) {

pycti/api/opencti_api_work.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ def delete_work(self, work_id: str):
133133

134134
def delete(self, **kwargs):
135135
id = kwargs.get("id", None)
136+
if id is None:
137+
self.opencti.admin_logger.error(
138+
"[opencti_work] Cant delete work, missing parameter: id"
139+
)
140+
return None
136141
query = """
137142
mutation ConnectorWorksMutation($workId: ID!) {
138143
workEdit(id: $workId) {

pycti/api/opencti_api_workspace.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ def __init__(self, api):
66

77
def delete(self, **kwargs):
88
id = kwargs.get("id", None)
9+
if id is None:
10+
self.api.admin_logger.error(
11+
"[opencti_workspace] Cant delete workspace, missing parameter: id"
12+
)
13+
return None
914
query = """
1015
mutation WorkspaceDelete($id: ID!) {
1116
workspaceDelete(id: $id)

pycti/entities/opencti_group.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ def delete(self, **kwargs):
323323
"""
324324
id = kwargs.get("id", None)
325325
if id is None:
326-
self.opencti.admin_logger.error("[opencti_user] Missing parameter: id")
326+
self.opencti.admin_logger.error(
327+
"[opencti_group] Cant delete group, missing parameter: id"
328+
)
327329
return None
328330
self.opencti.admin_logger.info("Deleting group", {"id": id})
329331
query = """

pycti/entities/opencti_indicator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def update_field(self, **kwargs):
334334
)
335335
else:
336336
self.opencti.app_logger.error(
337-
"[opencti_stix_domain_object] Missing parameters: id and input"
337+
"[opencti_stix_domain_object] Cant update indicator field, missing parameters: id and input"
338338
)
339339
return None
340340

pycti/entities/opencti_stix_core_object.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,9 @@ def rule_apply(self, **kwargs):
17021702
"""
17031703
self.opencti.query(query, {"elementId": element_id, "ruleId": rule_id})
17041704
else:
1705-
self.opencti.app_logger.error("[stix_core_object] Missing parameters: id")
1705+
self.opencti.app_logger.error(
1706+
"[stix_core_object] Cant apply rule, missing parameters: id"
1707+
)
17061708
return None
17071709

17081710
"""
@@ -1727,7 +1729,9 @@ def rule_clear(self, **kwargs):
17271729
"""
17281730
self.opencti.query(query, {"elementId": element_id, "ruleId": rule_id})
17291731
else:
1730-
self.opencti.app_logger.error("[stix_core_object] Missing parameters: id")
1732+
self.opencti.app_logger.error(
1733+
"[stix_core_object] Cant clear rule, missing parameters: id"
1734+
)
17311735
return None
17321736

17331737
"""
@@ -1750,7 +1754,9 @@ def rules_rescan(self, **kwargs):
17501754
"""
17511755
self.opencti.query(query, {"elementId": element_id})
17521756
else:
1753-
self.opencti.app_logger.error("[stix_core_object] Missing parameters: id")
1757+
self.opencti.app_logger.error(
1758+
"[stix_core_object] Cant rescan rule, missing parameters: id"
1759+
)
17541760
return None
17551761

17561762
"""
@@ -1779,7 +1785,9 @@ def clear_access_restriction(self, **kwargs):
17791785
},
17801786
)
17811787
else:
1782-
self.opencti.app_logger.error("[stix_core_object] Missing parameters: id")
1788+
self.opencti.app_logger.error(
1789+
"[stix_core_object] Cant clear access restriction, missing parameters: id"
1790+
)
17831791
return None
17841792

17851793
"""
@@ -1937,5 +1945,7 @@ def remove_from_draft(self, **kwargs):
19371945
"""
19381946
self.opencti.query(query, {"id": id})
19391947
else:
1940-
self.opencti.app_logger.error("[stix_core_object] Missing parameters: id")
1948+
self.opencti.app_logger.error(
1949+
"[stix_core_object] Cant remove from draft, missing parameters: id"
1950+
)
19411951
return None

pycti/utils/opencti_stix2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,7 @@ def organization_unshare(self, item):
25432543
def element_operation_delete(self, item, operation):
25442544
# If data is stix, just use the generic stix function for deletion
25452545
if item["type"] in STIX_OBJECTS:
2546-
force_delete = operation == "delete-force"
2546+
force_delete = operation == "delete_force"
25472547
self.opencti.stix.delete(id=item["id"], force_delete=force_delete)
25482548
else:
25492549
# Element is not knowledge we need to use the right api

0 commit comments

Comments
 (0)