Skip to content

[Bug] Update Sort Parameter #3531

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

Merged

Conversation

eric-forte-elastic
Copy link
Contributor

Issues

#3530

Summary

This PR updates the sort parameter so that the collect-events command functions correctly with the elasticsearch 8.12 python library. See issue for more background/context info.

Testing

Run collect events and make sure you can collect data. If data is collected, the test is successful.

endpoint-rules on  2356-fr-add-host-family-to-data-path [?] via  v3.8.10 (venv) on  eric.forte took 20s 
❯ python -m endpoint_rules es --cloud-id <cloud_id> collect-events --rta-name bitsadmin_execution <host_id>

███████╗███╗   ██╗██████╗ ██████╗  ██████╗ ██╗███╗   ██╗████████╗
██╔════╝████╗  ██║██╔══██╗██╔══██╗██╔═══██╗██║████╗  ██║╚══██╔══╝
█████╗  ██╔██╗ ██║██║  ██║██████╔╝██║   ██║██║██╔██╗ ██║   ██║
██╔══╝  ██║╚██╗██║██║  ██║██╔═══╝ ██║   ██║██║██║╚██╗██║   ██║
███████╗██║ ╚████║██████╔╝██║     ╚██████╔╝██║██║ ╚████║   ██║
╚══════╝╚═╝  ╚═══╝╚═════╝ ╚═╝      ╚═════╝ ╚═╝╚═╝  ╚═══╝   ╚═╝
        ██████╗ ██╗   ██╗██╗     ███████╗███████╗
        ██╔══██╗██║   ██║██║     ██╔════╝██╔════╝
        ██████╔╝██║   ██║██║     █████╗  ███████╗
        ██╔══██╗██║   ██║██║     ██╔══╝  ╚════██║
        ██║  ██║╚██████╔╝███████╗███████╗███████║
        ╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚══════╝

es_user: eric.forte
es_password: 
Press any key once detonation is complete ...
149 events saved to: /tmp/init_tmp/endpoint-rules/unit_tests/data/true_positives/bitsadmin_execution/windows/endpoint.ndjson
32 events saved to: /tmp/init_tmp/endpoint-rules/unit_tests/data/true_positives/bitsadmin_execution/windows/metricbeat.ndjson
2 events saved to: /tmp/init_tmp/endpoint-rules/unit_tests/data/true_positives/bitsadmin_execution/windows/filebeat.ndjson

@eric-forte-elastic eric-forte-elastic added bug Something isn't working python Internal python for the repository Area: DED labels Mar 22, 2024
@eric-forte-elastic eric-forte-elastic self-assigned this Mar 22, 2024
@eric-forte-elastic eric-forte-elastic linked an issue Mar 22, 2024 that may be closed by this pull request
Copy link
Contributor

@Mikaayenson Mikaayenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Just additional context for our future selves. The elasticsearch client basically ignores the old way we were passing sort params:

        # The 'sort' parameter with a colon can't be encoded to the body.
        if sort is not None and (
            (isinstance(sort, str) and ":" in sort)
            or (
                isinstance(sort, (list, tuple))
                and all(isinstance(_x, str) for _x in sort)
                and any(":" in _x for _x in sort)
            )
        ):
            __query["sort"] = sort
            sort = None

@eric-forte-elastic eric-forte-elastic merged commit 3503786 into main Mar 25, 2024
@eric-forte-elastic eric-forte-elastic deleted the 3530-bug-collect-events-outdated-sort-argument branch March 25, 2024 15:46
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
protectionsmachine pushed a commit that referenced this pull request Mar 25, 2024
(cherry picked from commit 3503786)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport: auto bug Something isn't working python Internal python for the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Collect Events Outdated Sort Argument
3 participants