elastic / detection-rules

https://www.elastic.co/guide/en/security/current/detection-engine-overview.html
Other
1.92k stars 492 forks source link

[Rule Tuning] Add `METADATA` checks for non-aggregate ES|QL queries and fix existing #4126

Open terrancedejesus opened 6 days ago

terrancedejesus commented 6 days ago

Pull Request

Issue link(s):

Summary - What I changed

Adds an additional check in ESQLRuleData.validates_esql_data for non-aggregate queries to ensure they have metadata _id _version _index after the from source command. Please reference the issue linked to this PR for more information.

How To Test

Screenshot 2024-10-02 at 1 51 24 PM

Aside from the image above, any of the rules in the diff can be used to test. Remove the metadata values in the query and then attempt to run view-rule or make tests.

Checklist

Contributor checklist

protectionsmachine commented 6 days ago

Enhancement - Guidelines

These guidelines serve as a reminder set of considerations when addressing adding a new schema feature to the code.

Documentation and Context

Code Standards and Practices

Testing

Additional Schema Related Checks