Skip to content

Commit

Permalink
[Prisma Cloud V2] Fix Namespace Extraction (#30996)
Browse files Browse the repository at this point in the history
* fix

* update docker
  • Loading branch information
BEAdi committed Nov 21, 2023
1 parent 04c0473 commit 1c1a123
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
1 change: 1 addition & 0 deletions Packs/PrismaCloud/.pack-ignore
Expand Up @@ -48,6 +48,7 @@ fqdn
vpc
cloudtrail
Prioritization
namespaces

[file:classifier-Prisma_Cloud.json]
ignore=BA101
Expand Down
Expand Up @@ -517,7 +517,9 @@ def extract_namespace(response_items: List[Dict[str, Any]]):
Extract namespaces from resource list items.
"""
for item in response_items:
for member in item.get('members', []): # members is a list of dicts
for member in item.get('members', []): # members is a list of dict or strs
if isinstance(member, str):
continue
if item_namespace := member.get('namespaces', []):
item['namespaces'] = item_namespace
break
Expand Down
Expand Up @@ -111,7 +111,7 @@ script:
script: ''
type: python
subtype: python3
dockerimage: demisto/python3:3.10.13.74666
dockerimage: demisto/python3:3.10.13.80593
isfetch: true
isremotesyncin: true
isremotesyncout: true
Expand Down
41 changes: 41 additions & 0 deletions Packs/PrismaCloud/Integrations/PrismaCloudV2/PrismaCloudV2_test.py
Expand Up @@ -866,6 +866,47 @@ def test_calculate_offset(page_size, page_number, offset):
assert calculate_offset(page_size, page_number) == (page_size, offset)


def test_extract_namespace():
"""
Given:
- A response to extract namespace from.
When:
- Extracting namespaces from resource list items.
Then:
- The response is updated with the right namespaces.
"""
from PrismaCloudV2 import extract_namespace

res = [{'id': '1', 'name': 'No namespaces', 'resourceListType': 'TAG',
'description': 'some values',
'lastModifiedBy': 'name@company.com', 'lastModifiedTs': 1611682405313,
'members': [{'env': 'env'}, {'projec': 'project'}, {'securit': 'security'}]},
{'id': '2', 'name': 'Members is strings', 'resourceListType': 'RESOURCE_GROUP',
'description': '', 'lastModifiedBy': 'name@company.com', 'lastModifiedTs': 1648181381197,
'members': ['common']},
{'id': '3', 'name': 'Have namespaces',
'resourceListType': 'GROUP', 'description': 'Have namespaces',
'lastModifiedBy': 'name@company.com', 'lastModifiedTs': 1648507192479,
'members': [{'hosts': ['*'], 'appIDs': ['*'], 'images': ['*'], 'labels': ['*'], 'clusters': ['*'],
'codeRepos': ['*'], 'functions': ['*'], 'containers': ['*'], 'namespaces': ['*']}]}]
expected_res = [{'id': '1', 'name': 'No namespaces', 'resourceListType': 'TAG',
'description': 'some values',
'lastModifiedBy': 'name@company.com', 'lastModifiedTs': 1611682405313,
'members': [{'env': 'env'}, {'projec': 'project'}, {'securit': 'security'}]},
{'id': '2', 'name': 'Members is strings', 'resourceListType': 'RESOURCE_GROUP',
'description': '', 'lastModifiedBy': 'name@company.com', 'lastModifiedTs': 1648181381197,
'members': ['common']},
{'id': '3', 'name': 'Have namespaces',
'resourceListType': 'GROUP', 'description': 'Have namespaces',
'lastModifiedBy': 'name@company.com', 'lastModifiedTs': 1648507192479,
'members': [{'hosts': ['*'], 'appIDs': ['*'], 'images': ['*'], 'labels': ['*'],
'clusters': ['*'], 'codeRepos': ['*'], 'functions': ['*'],
'containers': ['*'], 'namespaces': ['*']}],
'namespaces': ['*']}]
extract_namespace(res)
assert res == expected_res


''' FETCH HELPER FUNCTIONS TESTS '''


Expand Down
7 changes: 7 additions & 0 deletions Packs/PrismaCloud/ReleaseNotes/4_2_11.md
@@ -0,0 +1,7 @@

#### Integrations

##### Prisma Cloud v2

- Fixed an issue in extracting namespaces in the ***prisma-cloud-resource-list*** command.
- Updated the Docker image to: *demisto/python3:3.10.13.80593*.
2 changes: 1 addition & 1 deletion Packs/PrismaCloud/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Prisma Cloud by Palo Alto Networks",
"description": "Automate and unify security incident response across your cloud environments, while still giving a degree of control to dedicated cloud teams.",
"support": "xsoar",
"currentVersion": "4.2.10",
"currentVersion": "4.2.11",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 1c1a123

Please sign in to comment.