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

Remove redundant assignment of var #27571

Merged
merged 3 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking bc, why are we deciding to stop support for textual logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt mean to break bc.
And I dont understand how it breaks bc.

The way I see it
There is no need to assign a value amount_of_ events in case it is a string.
but if its not a list and not a string throw an exception.
The split str by \n is done in split_data_to_chunks method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed the not

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