From 97b1e450ce43397e43be0be3810e9710e21dc6bc Mon Sep 17 00:00:00 2001 From: Moshe Eichler <78307768+MosheEichler@users.noreply.github.com> Date: Mon, 7 Oct 2024 10:06:26 +0300 Subject: [PATCH] Bug fix/xsup 42076/bmc helix itsm fix query (#36583) * BMC Helix ITSM added brackets to the query * RN * Fix ut --- Packs/BmcITSM/Integrations/BmcITSM/BmcITSM.py | 4 ++-- Packs/BmcITSM/Integrations/BmcITSM/BmcITSM_test.py | 8 ++++---- Packs/BmcITSM/ReleaseNotes/1_0_27.md | 6 ++++++ Packs/BmcITSM/pack_metadata.json | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 Packs/BmcITSM/ReleaseNotes/1_0_27.md diff --git a/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM.py b/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM.py index d435b8a0dc82..3ceefa71ef5e 100644 --- a/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM.py +++ b/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM.py @@ -3476,7 +3476,7 @@ def gen_single_filters_statement(filter_key: str, values: list, oper_in_filter: stmt = oper_between_filters.join(f"'{filter_key}' {oper_in_filter} \"{resource_id}\"" for resource_id in (values)) - return stmt + return f'({stmt})' if stmt else '' def wrap_filter_value(filter_value: str, operation: str) -> str: @@ -3530,7 +3530,7 @@ def gen_fetch_incidents_query( str: query to fetch a certain ticket type. """ create_time_prop = "Create Date" if ticket_type == "task" else "Submit Date" - time_filter = f"'{create_time_prop}' <= \"{t_epoch_to}\" AND '{create_time_prop}' >\"{t_epoch_from}\"" + time_filter = f"('{create_time_prop}' <= \"{t_epoch_to}\" AND '{create_time_prop}' >\"{t_epoch_from}\")" status_statement = gen_single_filters_statement(TICKET_TYPE_TO_STATUS_KEY[ticket_type], status_filter, "=", " OR ") diff --git a/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM_test.py b/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM_test.py index 2173fd904a4f..92a26ad0348c 100644 --- a/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM_test.py +++ b/Packs/BmcITSM/Integrations/BmcITSM/BmcITSM_test.py @@ -702,7 +702,7 @@ def test_task_create_command( mock_response = load_mock_response(response_file_name) url = f"{BASE_URL}/api/arsys/v1/entry/TMS:Task?fields=values(Task ID,Create Date)" requests_mock.post(url=url, json=mock_response) - query = "'Request ID' = \"PKE000000000227\"" + query = "('Request ID' = \"PKE000000000227\")" url = f"{BASE_URL}/api/arsys/v1/entry/PBM:KnownErrorInterface?q={query}" requests_mock.get(url=url, json=load_mock_response("get_known_error.json")) @@ -1182,7 +1182,7 @@ def test_gen_fetch_incidents_query(): urgency_filter, custom_query, ) - assert query == "'Submit Date' <= \"1657032797\" AND 'Submit Date' >\"1657032797\" AND 'Urgency' = \"4-Low\"" + assert query == "('Submit Date' <= \"1657032797\" AND 'Submit Date' >\"1657032797\") AND ('Urgency' = \"4-Low\")" @pytest.mark.parametrize( @@ -1509,8 +1509,8 @@ def test_fetch_command( status_filter=[], impact_filter=[], urgency_filter=[], - custom_query=("'Submit Date' <= \"1657032797\" AND 'Submit Date'" - ">\"1657032797\" AND 'Urgency' = \"4-Low\""), + custom_query=("('Submit Date' <= \"1657032797\" AND 'Submit Date'" + ">\"1657032797\") AND ('Urgency' = \"4-Low\")"), mirror_direction="both", ) assert last_run_result["SRM:Request"]["last_create_time"] == expected_result diff --git a/Packs/BmcITSM/ReleaseNotes/1_0_27.md b/Packs/BmcITSM/ReleaseNotes/1_0_27.md new file mode 100644 index 000000000000..06046772030a --- /dev/null +++ b/Packs/BmcITSM/ReleaseNotes/1_0_27.md @@ -0,0 +1,6 @@ + +#### Integrations + +##### BMC Helix ITSM + +Fixed an issue were the ***fetch-incidents*** command returned unrelated incidents due to an incorrect query. diff --git a/Packs/BmcITSM/pack_metadata.json b/Packs/BmcITSM/pack_metadata.json index 657a1772a3e7..32bf652442b1 100644 --- a/Packs/BmcITSM/pack_metadata.json +++ b/Packs/BmcITSM/pack_metadata.json @@ -2,7 +2,7 @@ "name": "BMC Helix ITSM", "description": "BMC Helix ITSM allows customers to manage service request, incident, change request, task, problem investigation, known error and work order tickets.", "support": "xsoar", - "currentVersion": "1.0.26", + "currentVersion": "1.0.27", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",