Skip to content

Commit

Permalink
Apply black to close alert folder
Browse files Browse the repository at this point in the history
  • Loading branch information
TOUFIKIzakarya committed Nov 5, 2024
1 parent 1e099a9 commit 8baf367
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
24 changes: 18 additions & 6 deletions Packs/SekoiaXDR/Scripts/SekoiaXDRCloseAlert/SekoiaXDRCloseAlert.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,38 @@ def close_alert(
close_notes: Optional[str],
username: str,
mirror_status: str,
is_mirror_out: bool
is_mirror_out: bool,
):
readable_output = ""
alert_status = get_status_name(alert_id)
if alert_status not in ["Closed", "Rejected"]:
if reject == "false":
if mirror_status == "In" and is_mirror_out:
execute_command("sekoia-xdr-update-status-alert", {"id": alert_id, "status": "Closed"})
execute_command(
"sekoia-xdr-update-status-alert",
{"id": alert_id, "status": "Closed"},
)
elif mirror_status is None and is_mirror_out:
execute_command("setIncident", {"sekoiaxdralertstatus": "Closed"})
execute_command("sekoia-xdr-update-status-alert", {"id": alert_id, "status": "Closed"})
execute_command(
"sekoia-xdr-update-status-alert",
{"id": alert_id, "status": "Closed"},
)
else:
execute_command("setIncident", {"sekoiaxdralertstatus": "Closed"})
readable_output = f"**** The alert {alert_id} has been closed. ****"
if reject == "true":
if mirror_status == "In" and is_mirror_out:
execute_command("sekoia-xdr-update-status-alert", {"id": alert_id, "status": "Rejected"})
execute_command(
"sekoia-xdr-update-status-alert",
{"id": alert_id, "status": "Rejected"},
)
elif mirror_status is None and is_mirror_out:
execute_command("setIncident", {"sekoiaxdralertstatus": "Closed"})
execute_command("sekoia-xdr-update-status-alert", {"id": alert_id, "status": "Rejected"})
execute_command(
"sekoia-xdr-update-status-alert",
{"id": alert_id, "status": "Rejected"},
)
else:
execute_command("setIncident", {"sekoiaxdralertstatus": "Rejected"})
readable_output = f"**** The alert {alert_id} has been rejected. ****"
Expand Down Expand Up @@ -92,7 +104,7 @@ def main():
close_notes = demisto.getArg("closeNotes")
username = demisto.getArg("closingUserId") # type: ignore
close_alert(
alert_short_id, reject, close_reason, close_notes, username, mirror_direction, is_mirror_out # type: ignore
alert_short_id, reject, close_reason, close_notes, username, mirror_direction, is_mirror_out # type: ignore
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import demistomock as demisto
import SekoiaXDRCloseAlert # type: ignore
from SekoiaXDRCloseAlert import get_status_name, get_username, \
post_closure_comment, close_alert, main # type: ignore
from SekoiaXDRCloseAlert import (
get_status_name,
get_username,
post_closure_comment,
close_alert,
main,
) # type: ignore


def test_get_status_name(mocker):
Expand Down Expand Up @@ -34,13 +39,13 @@ def test_close_alert(mocker):
demisto.results.call_args[0][0]["Contents"]
== "**** The alert 1 has been closed. ****"
)

close_alert("1", "false", "reason", "notes", "admin", None, True)
assert (
demisto.results.call_args[0][0]["Contents"]
== "**** The alert 1 has been closed. ****"
)

close_alert("1", "false", "reason", "notes", "admin", None, False)
assert (
demisto.results.call_args[0][0]["Contents"]
Expand All @@ -52,13 +57,13 @@ def test_close_alert(mocker):
demisto.results.call_args[0][0]["Contents"]
== "**** The alert 1 has been rejected. ****"
)

close_alert("1", "true", "reason", "notes", "admin", None, True)
assert (
demisto.results.call_args[0][0]["Contents"]
== "**** The alert 1 has been rejected. ****"
)

close_alert("1", "true", "reason", "notes", "admin", None, False)
assert (
demisto.results.call_args[0][0]["Contents"]
Expand Down

0 comments on commit 8baf367

Please sign in to comment.