Skip to content

Commit

Permalink
Remove redundant assignment of var (#27571)
Browse files Browse the repository at this point in the history
* Remove redundant amount_of_events assignments.

* Update RN.
Update docker.
Update version.

* Fix unit tests
  • Loading branch information
thefrieddan1 authored Jun 20, 2023
1 parent 5a2b2e1 commit e852f70
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 6 additions & 0 deletions Packs/Base/ReleaseNotes/1_32_16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Scripts

##### CommonServerPython
- Updated the Docker image to: *demisto/python:2.7.18.63476*.
- Improved implementation by removing redundant assignment to a variable.
8 changes: 1 addition & 7 deletions Packs/Base/Scripts/CommonServerPython/CommonServerPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -11107,18 +11107,13 @@ def send_events_to_xsiam(events, vendor, product, data_format=None, url_key='url
# only in case we have events data to send to XSIAM we continue with this flow.
# Correspond to case 1: List of strings or dicts where each string or dict represents an event.
if isinstance(events, list):
amount_of_events = len(events)
# In case we have list of dicts we set the data_format to json and parse each dict to a stringify each dict.
if isinstance(events[0], dict):
events = [json.dumps(event) for event in events]
data_format = 'json'
# Separating each event with a new line
data = '\n'.join(events)

elif isinstance(events, str):
amount_of_events = len(events.split('\n'))

else:
elif not isinstance(events, str):
raise DemistoException(('Unsupported type: {type_events} for the "events" parameter. Should be a string or '
'list.').format(type_events=type(events)))
if not data_format:
Expand Down Expand Up @@ -11170,7 +11165,6 @@ def events_error_handler(res):

client = BaseClient(base_url=xsiam_url)
data_chunks = split_data_to_chunks(data, XSIAM_EVENT_CHUNK_SIZE)
amount_of_events = 0
for data_chunk in data_chunks:
amount_of_events += len(data_chunk)
data_chunk = '\n'.join(data_chunk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ tests:
- Test-debug-mode
- Test-CreateDBotScore-With-Reliability
fromversion: 5.0.0
dockerimage: demisto/python:2.7.18.52566
dockerimage: demisto/python:2.7.18.63476
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.32.15",
"currentVersion": "1.32.16",
"author": "Cortex XSOAR",
"serverMinVersion": "6.0.0",
"url": "https://www.paloaltonetworks.com/cortex",
Expand Down

0 comments on commit e852f70

Please sign in to comment.