Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XSUP-30786/Fix #31168

Merged
merged 13 commits into from Nov 30, 2023
Merged
8 changes: 7 additions & 1 deletion Packs/PAN-OS/Integrations/Panorama/Panorama.py
Expand Up @@ -416,7 +416,13 @@ def parse_pan_os_un_committed_data(dictionary, keys_to_remove):
dictionary[key] = dictionary[key]['#text']
elif isinstance(dictionary[key], list) and isinstance(dictionary[key][0], dict) \
and dictionary[key][0].get('#text'):
dictionary[key] = [text.get('#text') for text in dictionary[key]]
temp_list = []
for text in dictionary[key]:
if isinstance(text, dict):
temp_list.append(text.get('#text'))
elif isinstance(text, str):
temp_list.append(text)
dictionary[key] = temp_list

for value in dictionary.values():
if isinstance(value, dict):
Expand Down
2 changes: 1 addition & 1 deletion Packs/PAN-OS/Integrations/Panorama/Panorama.yml
Expand Up @@ -9366,7 +9366,7 @@ script:
description: The job ID to use when polling.
description: Exports a tech support file (TSF).
polling: true
dockerimage: demisto/pan-os-python:1.0.0.80157
dockerimage: demisto/pan-os-python:1.0.0.81877
isfetch: true
runonce: false
script: ''
Expand Down
55 changes: 38 additions & 17 deletions Packs/PAN-OS/Integrations/Panorama/Panorama_test.py
Expand Up @@ -2069,7 +2069,7 @@ def create_mock_responses(job_commit_status_count):
{'Description': '', 'JobID': '19420', 'Status': 'Pending'}, id="no args")
])
def test_panorama_commit_command_without_polling(
self, mocker, args, expected_request_params, request_result, expected_demisto_result
self, mocker, args, expected_request_params, request_result, expected_demisto_result
):
"""
Given:
Expand Down Expand Up @@ -2130,7 +2130,7 @@ def test_panorama_commit_command_without_polling(
]
)
def test_panorama_commit_command_with_polling(
self, mocker, args, expected_commit_request_url_params, api_response_queue
self, mocker, args, expected_commit_request_url_params, api_response_queue
):
"""
Given:
Expand Down Expand Up @@ -2396,7 +2396,7 @@ def test_panorama_push_to_device_group_command(mocker, args, expected_request_pa
id='with device'),
])
def test_panorama_push_to_template_command(
mocker, args, expected_request_params, request_result, expected_demisto_result
mocker, args, expected_request_params, request_result, expected_demisto_result
):
"""
Given:
Expand Down Expand Up @@ -2500,7 +2500,7 @@ def test_panorama_push_to_template_command(
id='with device'),
])
def test_panorama_push_to_template_stack_command(
mocker, args, expected_request_params, request_result, expected_demisto_result
mocker, args, expected_request_params, request_result, expected_demisto_result
):
"""
Given:
Expand Down Expand Up @@ -3328,16 +3328,16 @@ def test_reboot(self, mock_topology):

# We also want to check that if an empty string is passed, an error is returned
with pytest.raises(
DemistoException,
match="filter_str is not the exact ID of a host in this topology; use a more specific filter string."
DemistoException,
match="filter_str is not the exact ID of a host in this topology; use a more specific filter string."
):
UniversalCommand.reboot(mock_topology, "")

# Lets also check that if an invalid hostid is given, we also raise.
with pytest.raises(
DemistoException,
match="filter_str badserialnumber is not the exact ID of "
"a host in this topology; use a more specific filter string."
DemistoException,
match="filter_str badserialnumber is not the exact ID of "
"a host in this topology; use a more specific filter string."
):
UniversalCommand.reboot(mock_topology, "badserialnumber")

Expand Down Expand Up @@ -3566,7 +3566,8 @@ def test_panorama_apply_dns_command2(mocker):
apply_dns_signature_policy_command({'anti_spyware_profile_name': 'fake_profile_name'})

request_params = request_mock.call_args.kwargs['params'] # The body part of the request
assert request_params.get('xpath') == "/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='fakeDeviceGroup']/profiles/spyware/entry[@name='fake_profile_name']" # noqa
assert request_params.get(
'xpath') == "/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='fakeDeviceGroup']/profiles/spyware/entry[@name='fake_profile_name']" # noqa


class TestHygieneFunctions:
Expand Down Expand Up @@ -4707,7 +4708,7 @@ class TestPanOSListVirtualRouters:
]
)
def test_pan_os_list_virtual_routers_command_main_flow(
self, mocker, args, params, expected_url_params, mocked_response_path
self, mocker, args, params, expected_url_params, mocked_response_path
):
"""
Given:
Expand Down Expand Up @@ -4782,7 +4783,7 @@ class TestPanOSListRedistributionProfiles:
]
)
def test_pan_os_list_redistribution_profiles_main_flow(
self, mocker, args, params, expected_url_params
self, mocker, args, params, expected_url_params
):
"""
Given:
Expand Down Expand Up @@ -4983,7 +4984,7 @@ class TestPanOSEditRedistributionProfile:
]
)
def test_pan_os_edit_redistribution_profile_command_replace_action_main_flow(
self, mocker, args, params, expected_url_params
self, mocker, args, params, expected_url_params
):
"""
Tests several cases where behavior == 'replace'
Expand Down Expand Up @@ -5053,7 +5054,7 @@ def test_pan_os_edit_redistribution_profile_command_replace_action_main_flow(
]
)
def test_pan_os_edit_redistribution_profile_command_add_action_main_flow(
self, mocker, args, params, expected_url_params
self, mocker, args, params, expected_url_params
):
"""
Tests cases where behavior == 'add'
Expand Down Expand Up @@ -5129,7 +5130,7 @@ def test_pan_os_edit_redistribution_profile_command_add_action_main_flow(
]
)
def test_pan_os_edit_redistribution_profile_command_remove_action_main_flow(
self, mocker, args, params, expected_url_params
self, mocker, args, params, expected_url_params
):
"""
Tests cases where behavior == 'remove'
Expand Down Expand Up @@ -6785,8 +6786,8 @@ def test_filter_fetched_entries(mocker):
"""
from Panorama import filter_fetched_entries
raw_entries = {"log_type1": [{'device_name': 'dummy_device1'},
{'device_name': 'dummy_device1', 'seqno': '000000002'},
{'device_name': 'dummy_device2', 'seqno': '000000001'}],
{'device_name': 'dummy_device1', 'seqno': '000000002'},
{'device_name': 'dummy_device2', 'seqno': '000000001'}],
"log_type2": [{'device_name': 'dummy_device3', 'seqno': '000000004'},
{'seqno': '000000007'}]}
id_dict = {"log_type1": {'dummy_device1': '000000003', 'dummy_device2': '000000000'}}
Expand Down Expand Up @@ -6899,6 +6900,26 @@ def test_panorama_list_rules():
"/config/devices/entry/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[(application/member = 'dns')]"


def test_prettify_rules():
"""
Given:
- rule entry.
When:
- Running the prettify_rules method.
Then:
- Ensure no errors are raised.
"""
from Panorama import prettify_rules
test_rule = {
'@name': 'test',
'@uuid': '11111-111-111-11',
'source': {'@loc': 'test',
'member': [{'@loc': 'test', '#text': 'text'},
'Failing String']}}
prettier_rules = prettify_rules(test_rule)
assert 'Failing String' in prettier_rules[0].get('Source')


@pytest.mark.parametrize('include_shared', ['No', 'Yes'])
def test_panorama_list_tags(mocker, include_shared):
"""
Expand Down
7 changes: 7 additions & 0 deletions Packs/PAN-OS/ReleaseNotes/2_1_15.md
@@ -0,0 +1,7 @@

#### Integrations

##### Palo Alto Networks PAN-OS

- Fixed an issue where the ***pan-os-list-rules*** command failed to parse the response correctly.
- Updated the Docker image to: *demisto/pan-os-python:1.0.0.81877*.
2 changes: 1 addition & 1 deletion Packs/PAN-OS/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "PAN-OS by Palo Alto Networks",
"description": "Manage Palo Alto Networks Firewall and Panorama. Use this pack to manage Prisma Access through Panorama. For more information see Panorama documentation.",
"support": "xsoar",
"currentVersion": "2.1.14",
"currentVersion": "2.1.15",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down