From 172e670787406f1298cd4fbfc757da0b7d8a8fe1 Mon Sep 17 00:00:00 2001 From: Koby Meir Date: Thu, 21 Dec 2023 14:06:00 +0200 Subject: [PATCH] Human-readable output using the JsonToTable script not giving expected results (#31511) Human-readable output using the JsonToTable script not giving expected results #31511 --- .../ReleaseNotes/1_2_48.md | 7 +++++++ .../Scripts/JsonToTable/JsonToTable.py | 6 +++++- .../Scripts/JsonToTable/JsonToTable.yml | 4 ++-- .../Scripts/JsonToTable/JsonToTable_test.py | 2 +- .../Scripts/JsonToTable/README.md | 20 ++++++++++++++----- .../FiltersAndTransformers/pack_metadata.json | 2 +- 6 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 Packs/FiltersAndTransformers/ReleaseNotes/1_2_48.md diff --git a/Packs/FiltersAndTransformers/ReleaseNotes/1_2_48.md b/Packs/FiltersAndTransformers/ReleaseNotes/1_2_48.md new file mode 100644 index 000000000000..88f909045312 --- /dev/null +++ b/Packs/FiltersAndTransformers/ReleaseNotes/1_2_48.md @@ -0,0 +1,7 @@ + +#### Scripts + +##### JsonToTable + +- Fixed an issue where the **JsonToTable** script not returning Human-Readable output. +- Updated the Docker image to: *demisto/python3:3.10.13.83255*. diff --git a/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.py b/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.py index 74c6b0d3e8c3..9390dba5ff64 100644 --- a/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.py +++ b/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.py @@ -21,7 +21,11 @@ def main(): json_transformers[header_key] = JsonTransformer(**values) markdown = tableToMarkdown(title, value, headers=headers, json_transform_mapping=json_transformers, is_auto_json_transform=is_auto_json_transform) - return_results(markdown) + + return_results(CommandResults( + readable_output=markdown, + raw_response=markdown, + )) def get_value_from_str(value: Any): diff --git a/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.yml b/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.yml index 39c4dced458c..16f3b2e9a2df 100644 --- a/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.yml +++ b/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable.yml @@ -23,10 +23,10 @@ args: - name: is_auto_json_transform description: Try transforming complex JSON automatically. - name: json_transform_properties - description: 'Transformation JSON from value to strings. The syntax is: `{"header_key": {"keys": [, ...], "is_nested": true/false}}` ' + description: 'Transformation JSON from value to strings. The syntax is: `{"header_key": {"keys": [, ...], "is_nested": true/false}}`.' scripttarget: 0 subtype: python3 -dockerimage: demisto/python3:3.10.12.63474 +dockerimage: demisto/python3:3.10.13.83255 runas: DBotWeakRole tests: - JsonToTable - Test Playbook diff --git a/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable_test.py b/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable_test.py index 6e386be59c82..5e1b48f47a51 100644 --- a/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable_test.py +++ b/Packs/FiltersAndTransformers/Scripts/JsonToTable/JsonToTable_test.py @@ -27,4 +27,4 @@ def test_json_to_table__sanity(mocker, value, expected_md): mocker.patch.object(JsonToTable, 'return_results') JsonToTable.main() - JsonToTable.return_results.assert_called_with(expected_md) + assert JsonToTable.return_results.call_args[0][0].readable_output == expected_md diff --git a/Packs/FiltersAndTransformers/Scripts/JsonToTable/README.md b/Packs/FiltersAndTransformers/Scripts/JsonToTable/README.md index 665a21939320..9cff3365496a 100644 --- a/Packs/FiltersAndTransformers/Scripts/JsonToTable/README.md +++ b/Packs/FiltersAndTransformers/Scripts/JsonToTable/README.md @@ -27,7 +27,9 @@ There are no outputs for this script. ## Script Examples ### Example command -```!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]```` +``` +!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]` +``` ### Context Example ```json {} @@ -42,7 +44,9 @@ There are no outputs for this script. ### Example command -```!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]` headers=name``` +``` +!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]` headers=name +``` ### Context Example ```json {} @@ -57,7 +61,9 @@ There are no outputs for this script. ### Example command -```!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` is_auto_json_transform=true``` +``` +!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` is_auto_json_transform=true +``` ### Context Example ```json {} @@ -72,7 +78,9 @@ There are no outputs for this script. ### Example command -```!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["first", "second"]}}```` +``` +!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["first", "second"]}}` +``` ### Context Example ```json {} @@ -87,7 +95,9 @@ There are no outputs for this script. ### Example command -```!JsonToTable value=`[{"name": {"first": {"a": "val"}, "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": {"a": "val2"}, "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["a", "second"], "is_nested": "true"}}```` +``` +!JsonToTable value=`[{"name": {"first": {"a": "val"}, "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": {"a": "val2"}, "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["a", "second"], "is_nested": "true"}}` +``` ### Context Example ```json {} diff --git a/Packs/FiltersAndTransformers/pack_metadata.json b/Packs/FiltersAndTransformers/pack_metadata.json index 4b562b2308ee..2f44e48ba873 100644 --- a/Packs/FiltersAndTransformers/pack_metadata.json +++ b/Packs/FiltersAndTransformers/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Filters And Transformers", "description": "Frequently used filters and transformers pack.", "support": "xsoar", - "currentVersion": "1.2.47", + "currentVersion": "1.2.48", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",