Skip to content

Commit

Permalink
Fix the detection query to sort in ascending order (#37001)
Browse files Browse the repository at this point in the history
* fix

* rn

* fix tests

* replace to created_timestamp.asc
  • Loading branch information
RosenbergYehuda authored Oct 31, 2024
1 parent 73734e2 commit d67b9a9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ def get_detections(last_behavior_time=None, behavior_id=None, filter_arg=None):
text_to_encode += f"+{filter_arg}"
endpoint_url += urllib.parse.quote_plus(text_to_encode)
demisto.debug(f"In get_detections: {LEGACY_VERSION =} and {endpoint_url=}")
return http_request('GET', endpoint_url)
return http_request('GET', endpoint_url, {'sort': 'created_timestamp.asc'})
else:
endpoint_url = '/detects/queries/detects/v1'
demisto.debug(f"In get_detections: {LEGACY_VERSION =} and {endpoint_url=} and {params=}")
Expand All @@ -1555,8 +1555,9 @@ def get_fetch_detections(last_created_timestamp=None, filter_arg=None, offset: i
Returns:
Response json of the get detection endpoint (IDs of the detections)
"""
sort_key = 'first_behavior.asc' if LEGACY_VERSION else 'created_timestamp.asc'
params = {
'sort': 'first_behavior.asc',
'sort': sort_key,
'offset': offset,
}
if has_limit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7210,7 +7210,7 @@ def test_error_handler():
@pytest.mark.parametrize('Legacy_version, url_suffix, expected_len', [
(False,
"alerts/queries/alerts/v2?filter=product%3A%27epp%27%2Btype%3A%27ldt%27%2Bcreated_timestamp%3A%3E%272024-06-19T15%3A25%3A00Z%27",
2),
3),
(True, '/detects/queries/detects/v1', 3)
])
def test_get_detection___url_and_params(mocker, Legacy_version, url_suffix, expected_len):
Expand Down Expand Up @@ -7269,7 +7269,7 @@ def test_resolve_detection(mocker, Legacy_version, tag, url_suffix, data):
@pytest.mark.parametrize('Legacy_version, url_suffix, request_params', [
(False,
"/alerts/queries/alerts/v2?filter=product%3A%27epp%27%2Btype%3A%27ldt%27%2Bupdated_timestamp%3A%3E%272024-06-19T15%3A25%3A00Z%27",
{'sort': 'first_behavior.asc', 'offset': 5, 'limit': 3}),
{'sort': 'created_timestamp.asc', 'offset': 5, 'limit': 3}),
(True, '/detects/queries/detects/v1', {'sort': 'first_behavior.asc',
'offset': 5, 'limit': 3, 'filter': "date_updated:>'2024-06-19T15:25:00Z'"})
])
Expand Down
6 changes: 6 additions & 0 deletions Packs/CrowdStrikeFalcon/ReleaseNotes/2_0_22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### CrowdStrike Falcon

Fixed an issue where detections were fetched unsorted in the post-Raptor release.
2 changes: 1 addition & 1 deletion Packs/CrowdStrikeFalcon/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "CrowdStrike Falcon",
"description": "The CrowdStrike Falcon OAuth 2 API (formerly the Falcon Firehose API), enables fetching and resolving detections, searching devices, getting behaviors by ID, containing hosts, and lifting host containment.",
"support": "xsoar",
"currentVersion": "2.0.21",
"currentVersion": "2.0.22",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit d67b9a9

Please sign in to comment.