[Enhancement] Add test for constant_keyword fields on alerts-only rules#5997
Open
terrancedejesus wants to merge 1 commit intomainfrom
Open
[Enhancement] Add test for constant_keyword fields on alerts-only rules#5997terrancedejesus wants to merge 1 commit intomainfrom
terrancedejesus wants to merge 1 commit intomainfrom
Conversation
5 tasks
Contributor
Bug - GuidelinesThese guidelines serve as a reminder set of considerations when addressing a bug in the code. Documentation and Context
Code Standards and Practices
Testing
Additional Checks
|
6f048ce to
78e9e56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related
Summary - What I changed
Added a CI unit test that fails the build if any KQL/EQL/ES|QL/threshold/new_terms/threat_match rule (a) targets only .alerts-* AND (b) references a constant_keyword ECS field. This closes the validator gap that let #5943 merge: the existing AST validators merge ECS into every target schema, so they treat data_stream.dataset as a known field and never catch this class of bug. The test catches it before runtime regardless of language.
How To Test
On the fix branch, run:
Expected: PASS.
To confirm the test actually catches the bug, open any of the patched rules (e.g.
rules/cross-platform/newly_observed_elastic_detection_rule.toml) and changeevent.datasetback todata_stream.dataset. Re-run the command, expected: FAIL, with the rule name and offending field in the output. Revert the edit when done.Checklist
bug,enhancement,schema,maintenance,Rule: New,Rule: Deprecation,Rule: Tuning,Hunt: New, orHunt: Tuningso guidelines can be generatedmeta:rapid-mergelabel if planning to merge within 24 hoursContributor checklist