Skip to content

Commit

Permalink
Fixed issues with handling null values. (#27199)
Browse files Browse the repository at this point in the history
* Fixed issues with handling null values. (#27031)

* Update .devcontainer.json name

* Update .devcontainer.json name

* Update .devcontainer.json name

* Update .devcontainer.json name

* update

* Updated docker tags

* Updated RN

* Added README

* Updated RN

* Update RN

* Update Packs/FiltersAndTransformers/ReleaseNotes/1_2_19.md

Co-authored-by: ShirleyDenkberg <[email protected]>

* Update Packs/FiltersAndTransformers/ReleaseNotes/1_2_19.md

Co-authored-by: ShirleyDenkberg <[email protected]>

---------

Co-authored-by: spearmin10 <[email protected]>
Co-authored-by: RotemAmit <[email protected]>
Co-authored-by: ShirleyDenkberg <[email protected]>

* fixed pre-commit error

---------

Co-authored-by: Masahiko Inoue <[email protected]>
Co-authored-by: spearmin10 <[email protected]>
Co-authored-by: RotemAmit <[email protected]>
Co-authored-by: ShirleyDenkberg <[email protected]>
Co-authored-by: RotemAmit <[email protected]>
  • Loading branch information
6 people authored Jun 4, 2023
1 parent e985868 commit fa55ad3
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 3 deletions.
15 changes: 15 additions & 0 deletions Packs/FiltersAndTransformers/ReleaseNotes/1_2_19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#### Scripts

##### LastArrayElement

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

- Fixed the way in which the script handled a null value given to the argument parameters. Instead of returning 'None', it will return a meaningful error message.

##### FirstArrayElement

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

- Fixed the way in which the script handled a null value given to the argument parameters. Instead of returning 'None', it will return a meaningful error message.

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

0 comments on commit fa55ad3

Please sign in to comment.