Skip to content

Commit

Permalink
[CSP - Account] Added an option to receive custom fields (#37248)
Browse files Browse the repository at this point in the history
* [CSP - Account] Added an option to recive custom fields

* Update 1_34_48.md

* Add log

* Fix error
  • Loading branch information
mmhw authored Nov 19, 2024
1 parent ded28f5 commit 4ef58f4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Packs/Base/ReleaseNotes/1_35_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Scripts

##### CommonServerPython

Added an option to the *Account* entity to receive custom fields.
15 changes: 13 additions & 2 deletions Packs/Base/Scripts/CommonServerPython/CommonServerPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -5110,7 +5110,7 @@ def __init__(self, id=None, type=None, username=None, display_name=None, groups=
department=None, country=None, state=None, city=None, street=None, is_enabled=None,
dbot_score=None, relationships=None, blocked=None, community_notes=None, creation_date=None,
description=None, stix_id=None, tags=None, traffic_light_protocol=None, user_id=None,
manager_email=None, manager_display_name=None, risk_level=None):
manager_email=None, manager_display_name=None, risk_level=None, **kwargs):

self.id = id
self.type = type
Expand Down Expand Up @@ -5140,6 +5140,7 @@ def __init__(self, id=None, type=None, username=None, display_name=None, groups=
self.manager_email_address = manager_email
self.manager_display_name = manager_display_name
self.risk_level = risk_level
self.kwargs = kwargs

if dbot_score and not isinstance(dbot_score, Common.DBotScore):
raise ValueError('dbot_score must be of type DBotScore')
Expand All @@ -5161,7 +5162,7 @@ def to_context(self):
if self.creation_date:
account_context['CreationDate'] = self.creation_date

irrelevent = ['CONTEXT_PATH', 'to_context', 'dbot_score', 'id', 'create_context_table']
irrelevent = ['CONTEXT_PATH', 'to_context', 'dbot_score', 'id', 'create_context_table', 'kwargs']
details = [detail for detail in dir(self) if not detail.startswith('__') and detail not in irrelevent]

for detail in details:
Expand Down Expand Up @@ -5195,6 +5196,16 @@ def to_context(self):
if self.community_notes:
account_context['CommunityNotes'] = self.create_context_table(self.community_notes)

if self.kwargs:
for key, value in self.kwargs.items():
if key not in account_context:
account_context[key] = value
else:
demisto.debug(
'Skipping the addition of the "{key}" key to the account context as it already exists.'.format(
key=key)
)

ret_value = {
Common.Account.CONTEXT_PATH: account_context
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6308,7 +6308,8 @@ def test_create_account(self):
user_id='test_user_id',
manager_email='[email protected]',
manager_display_name='test_manager_display_name',
risk_level='test_risk_level'
risk_level='test_risk_level',
**{'some_undefinedKey': 'value'}
)

results = CommandResults(
Expand Down Expand Up @@ -6351,7 +6352,8 @@ def test_create_account(self):
'Email': '[email protected]',
'DisplayName': 'test_manager_display_name'
},
'RiskLevel': 'test_risk_level'
'RiskLevel': 'test_risk_level',
'some_undefinedKey': 'value'
}
],
'DBotScore(val.Indicator && val.Indicator == obj.Indicator &&'
Expand Down
2 changes: 1 addition & 1 deletion Packs/Base/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Base",
"description": "The base pack for Cortex XSOAR.",
"support": "xsoar",
"currentVersion": "1.35.2",
"currentVersion": "1.35.3",
"author": "Cortex XSOAR",
"serverMinVersion": "6.0.0",
"url": "https://www.paloaltonetworks.com/cortex",
Expand Down

0 comments on commit 4ef58f4

Please sign in to comment.