Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
39aff75
added error message
shmuel44 Aug 13, 2023
ab496c1
RN
shmuel44 Aug 13, 2023
34d9ca8
Merge branch 'master' into sk_xdr_error_message_xsup_27092
shmuel44 Aug 13, 2023
8d7da52
Merge branch 'sk_xdr_error_message_xsup_27092' of github.com:demisto/…
shmuel44 Aug 13, 2023
99473b8
Apply suggestions from code review
shmuel44 Aug 14, 2023
62b5764
Update 5_0_8.md
shmuel44 Aug 14, 2023
ee5f54b
fix cr
shmuel44 Aug 14, 2023
bc65a7e
return warning
shmuel44 Aug 21, 2023
5077898
return warning
shmuel44 Aug 22, 2023
4384c2e
Merge branch 'master' into sk_xdr_error_message_xsup_27092
shmuel44 Aug 22, 2023
cd370d3
revert
shmuel44 Aug 22, 2023
f23c985
revert
shmuel44 Aug 22, 2023
23e6e31
revert
shmuel44 Aug 22, 2023
58226f6
test
shmuel44 Aug 22, 2023
948773b
UT
shmuel44 Aug 23, 2023
c4c09a9
merge master
shmuel44 Aug 23, 2023
667711c
RN
shmuel44 Aug 23, 2023
63558fd
RN
shmuel44 Aug 23, 2023
273c2c9
Update Packs/Core/ReleaseNotes/2_0_9.md
shmuel44 Aug 24, 2023
49dfbe9
Update Packs/CortexXDR/ReleaseNotes/5_0_11.md
shmuel44 Aug 24, 2023
7be60e0
Update 5_0_11.md
shmuel44 Aug 24, 2023
a26381e
Merge branch 'master' into sk_xdr_error_message_xsup_27092
shmuel44 Aug 24, 2023
7eab39c
Update Packs/ApiModules/Scripts/CoreIRApiModule/CoreIRApiModule.py
shmuel44 Aug 24, 2023
8f088f3
Update Packs/ApiModules/Scripts/CoreIRApiModule/CoreIRApiModule.py
shmuel44 Aug 24, 2023
2eca5a2
Merge branch 'master' into sk_xdr_error_message_xsup_27092
shmuel44 Aug 24, 2023
3492114
cr
shmuel44 Aug 24, 2023
5ca1c77
copy
shmuel44 Aug 24, 2023
ed5e524
Merged master into current branch.
Aug 24, 2023
b4b3ce9
Bump pack from version CortexXDR to 5.1.1.
Aug 24, 2023
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
16 changes: 15 additions & 1 deletion Packs/ApiModules/Scripts/CoreIRApiModule/CoreIRApiModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,15 @@ def list_risky_users_or_host_command(client: CoreClient, command: str, args: dic
ValueError: If the API connection fails.

"""
def _warn_if_module_is_disabled(e: DemistoException) -> None:
if (
e is not None
and e.res is not None
and e.res.status_code == 500
and 'No identity threat' in str(e)
and "An error occurred while processing XDR public API" in e.message
):
return_warning(f'Please confirm the XDR Identity Threat Module is enabled.\nFull error message: {e}', exit=True)

match command:
case "user":
Expand All @@ -3890,6 +3899,7 @@ def list_risky_users_or_host_command(client: CoreClient, command: str, args: dic
try:
outputs = client.risk_score_user_or_host(id_).get('reply', {})
except DemistoException as e:
_warn_if_module_is_disabled(e)
if error_message := enrich_error_message_id_group_role(e=e, type_="id", custom_message=""):
not_found_message = 'was not found'
if not_found_message in error_message:
Expand All @@ -3903,8 +3913,12 @@ def list_risky_users_or_host_command(client: CoreClient, command: str, args: dic

else:
list_limit = int(args.get('limit', 50))
outputs = get_func().get('reply', [])[:list_limit]

try:
outputs = get_func().get('reply', [])[:list_limit]
except DemistoException as e:
_warn_if_module_is_disabled(e)
raise
table_for_markdown = [parse_risky_users_or_hosts(user, *table_headers) for user in outputs]

readable_output = tableToMarkdown(name=table_title, t=table_for_markdown, headers=table_headers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import zipfile
from typing import Any

from pytest_mock import MockerFixture
import pytest

import demistomock as demisto
Expand Down Expand Up @@ -3278,6 +3278,56 @@ def __init__(self, status_code) -> None:
assert result.readable_output == 'The user test was not found'


@pytest.mark.parametrize(
"command ,args, client_func",
[
('user', {"user_id": "test"}, "risk_score_user_or_host"),
('host', {"host_id": "test"}, "risk_score_user_or_host"),
('user', {}, "list_risky_users"),
('host', {}, "list_risky_hosts"),
],
ids=['user_id', 'host_id', 'list_users', 'list_hosts']
)
def test_list_risky_users_hosts_command_no_license_warning(mocker: MockerFixture, command: str, args: dict, client_func: str):
"""
Given:
- XDR API error indicating that the user / host was not found

When:
- executing the list_risky_users_or_host_command function

Then:
- make sure a message indicating that the user was not found is returned
"""

client = CoreClient(
base_url="test",
headers={},
)

class MockException:
def __init__(self, status_code) -> None:
self.status_code = status_code

mocker.patch.object(
client,
client_func,
side_effect=DemistoException(
message="An error occurred while processing XDR public API, No identity threat",
res=MockException(500)
),
)
import CoreIRApiModule
warning = mocker.patch.object(CoreIRApiModule, 'return_warning')

with pytest.raises(DemistoException):
list_risky_users_or_host_command(client, command, args)
assert warning.call_args[0][0] == ('Please confirm the XDR Identity Threat Module is enabled.\n'
'Full error message: An error occurred while processing XDR public API,'
' No identity threat')
assert warning.call_args[1] == {"exit": True}


def test_list_user_groups_command(mocker):
"""
Test function to validate the behavior of the `list_user_groups_command` function.
Expand Down
6 changes: 6 additions & 0 deletions Packs/Core/ReleaseNotes/2_0_9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### Investigation & Response

Fixed an issue where the ***core-list-risky-users*** and ***core-list-risky-hosts*** commands would fail when the XDR Identity Threat Module was disabled or the license was missing.
2 changes: 1 addition & 1 deletion Packs/Core/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Core - Investigation and Response",
"description": "Automates incident response",
"support": "xsoar",
"currentVersion": "2.0.8",
"currentVersion": "2.0.9",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
6 changes: 6 additions & 0 deletions Packs/CortexXDR/ReleaseNotes/5_1_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Playbooks

##### Cortex XDR Malware - Incident Enrichment

Fixed an issue where the ***xdr-list-risky-users*** and ***xdr-list-risky-hosts*** commands would fail when the XDR Identity Threat Module was disabled or the license was missing.
2 changes: 1 addition & 1 deletion Packs/CortexXDR/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Cortex XDR by Palo Alto Networks",
"description": "Automates Cortex XDR incident response, and includes custom Cortex XDR incident views and layouts to aid analyst investigations.",
"support": "xsoar",
"currentVersion": "5.1.0",
"currentVersion": "5.1.1",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down