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

Fixed issues with handling null values. #27031

Merged
merged 26 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a9cfb8d
Update .devcontainer.json name
spearmin10 Feb 9, 2023
ab63dfb
Merge remote-tracking branch 'upstream/master'
spearmin10 Feb 10, 2023
ab9320f
Update .devcontainer.json name
spearmin10 Feb 10, 2023
21ff8b4
Merge remote-tracking branch 'upstream/master'
spearmin10 Feb 13, 2023
da16925
Merge remote-tracking branch 'upstream/master'
spearmin10 Feb 13, 2023
78f5dce
Merge remote-tracking branch 'upstream/master'
spearmin10 Feb 13, 2023
a2a3029
Merge remote-tracking branch 'upstream/master'
spearmin10 Mar 5, 2023
8e5070b
Update .devcontainer.json name
spearmin10 Mar 5, 2023
9e59339
Merge remote-tracking branch 'upstream/master'
spearmin10 Apr 18, 2023
756503f
Update .devcontainer.json name
spearmin10 Apr 18, 2023
980c0c3
Merge remote-tracking branch 'upstream/master'
spearmin10 Apr 20, 2023
fe61ff7
Merge remote-tracking branch 'upstream/master'
spearmin10 Apr 23, 2023
9ab90b6
Merge remote-tracking branch 'upstream/master'
spearmin10 May 29, 2023
4a63045
Merge remote-tracking branch 'upstream/master'
spearmin10 May 29, 2023
2568af9
update
spearmin10 May 29, 2023
fe81c82
Merge remote-tracking branch 'upstream/master' into ArrayElement
spearmin10 May 29, 2023
f16ba03
Updated docker tags
spearmin10 May 29, 2023
cc1eb35
Updated RN
spearmin10 May 29, 2023
8b1f936
Added README
spearmin10 May 29, 2023
08cd6ba
Updated RN
spearmin10 May 29, 2023
d23a5ba
Merge remote-tracking branch 'upstream/master' into ArrayElement
spearmin10 May 31, 2023
4ec7ee6
Update RN
spearmin10 May 31, 2023
d1fc51d
Update Packs/FiltersAndTransformers/ReleaseNotes/1_2_19.md
RotemAmit Jun 4, 2023
7cb32a2
Update Packs/FiltersAndTransformers/ReleaseNotes/1_2_19.md
RotemAmit Jun 4, 2023
c78a11f
Merge branch 'contrib/spearmin10_ArrayElement' into ArrayElement
RotemAmit Jun 4, 2023
e9af52e
Merge branch 'contrib/spearmin10_ArrayElement' into ArrayElement
RotemAmit Jun 4, 2023
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
13 changes: 13 additions & 0 deletions Packs/FiltersAndTransformers/ReleaseNotes/1_2_19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#### Scripts

##### LastArrayElement
- Updated the Docker image to: *demisto/python3:3.10.11.61265*.

- Fixed the way in which the script handled null value given to the argument parameters, instead of returning 'None', it will return a meaningful error message.
RotemAmit marked this conversation as resolved.
Show resolved Hide resolved

##### FirstArrayElement
- Updated the Docker image to: *demisto/python3:3.10.11.61265*.

- Fixed the way in which the script handled null value given to the argument parameters, instead of returning 'None', it will return a meaningful error message.
RotemAmit marked this conversation as resolved.
Show resolved Hide resolved

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def main():

if isinstance(value, list) and value:
value = value[0]
elif value is None:
value = []

demisto.results(value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ args:
isArray: true
scripttarget: 0
runonce: false
dockerimage: demisto/python3:3.9.8.24399
dockerimage: demisto/python3:3.10.11.61265
runas: DBotWeakRole
tests:
- No test - unit test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ def test_main(mocker):
results = demisto.results.call_args[0][0]
assert isinstance(results, list)
assert results[2] == 3

mocker.patch.object(demisto, 'args', return_value={
'value': None
})
mocker.patch.object(demisto, 'results')
main()
assert demisto.results.call_count == 1
results = demisto.results.call_args[0][0]
assert isinstance(results, list)
assert results == []
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Returns the first element of an array. If the value passed is not an array, it returns the original value that was passed.

## Script Data

---

| **Name** | **Description** |
Expand All @@ -10,12 +11,14 @@ Returns the first element of an array. If the value passed is not an array, it
| Cortex XSOAR Version | 5.0.0 |

## Inputs

---

| **Argument Name** | **Description** |
| --- | --- |
| value | An array for which to return the first element. |

## Outputs

---
There are no outputs for this script.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def main():

if type(value) is list and len(value) > 0:
value = value[-1]
elif value is None:
value = []

demisto.results(value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ args:
isArray: true
scripttarget: 0
runonce: false
dockerimage: demisto/python3:3.9.8.24399
dockerimage: demisto/python3:3.10.11.61265
runas: DBotWeakRole
tests:
- No test - unit test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ def test_main(mocker):
results = demisto.results.call_args[0][0]
assert isinstance(results, list)
assert results[2] == 3

mocker.patch.object(demisto, 'args', return_value={
'value': None
})
mocker.patch.object(demisto, 'results')
main()
assert demisto.results.call_count == 1
results = demisto.results.call_args[0][0]
assert isinstance(results, list)
assert results == []
24 changes: 24 additions & 0 deletions Packs/FiltersAndTransformers/Scripts/LastArrayElement/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Returns the last element of an array. If the value passed is not an array, it returns the original value that was passed.

## Script Data

---

| **Name** | **Description** |
| --- | --- |
| Script Type | python3 |
| Tags | general, transformer, entirelist |
| Cortex XSOAR Version | 5.0.0 |

## Inputs

---

| **Argument Name** | **Description** |
| --- | --- |
| value | An array for which to return the last value. |

## Outputs

---
There are no outputs for this script.
2 changes: 1 addition & 1 deletion Packs/FiltersAndTransformers/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Filters And Transformers",
"description": "Frequently used filters and transformers pack.",
"support": "xsoar",
"currentVersion": "1.2.18",
"currentVersion": "1.2.19",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down