-
Notifications
You must be signed in to change notification settings - Fork 513
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
[FR] Adding Support for missing_field_strategy
Field in Alert Suppression
#3201
[FR] Adding Support for missing_field_strategy
Field in Alert Suppression
#3201
Conversation
As exampled by in @brokensound77 's draft PR: https://github.com/elastic/detection-rules/pull/3207/files We can use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one suggestion then LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better! LGTM
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
…ession (#3201) * adding missing field strategy option to alert suppression * fixed linting errors * added validate methods for alertsuppression dataclass * fixed linting errors * replaced old variable with new variable * removing test rule * adding post_load to queryruledata * changed post_load to validates_schema * updated unit testing for alert suppression * fixed linting errors * changed validates method name to validates_exceptions * removed min compat for fields (cherry picked from commit 3ab57fb)
Issues
Summary
This PR adds
missing_field_strategy
toAlertSuppressionMapping
dataclass. This allows it to be a viable field in rules when loaded via schema.Additionally, the
missing_fields_strategy
has been min-stacked to8.8
where it was merged as shown with elastic/kibana#155055.Specific field values have been limited to
suppress
anddoNotSuppress
viadefiniitions.AlertSuppressionMissing
. Validation has been included to ensure the strings are bound to these two options.Note that we created a rule on an
8.10.3
stack, created a rule with alert suppression and both options toggled, then exported to understand what was required.Example Rule JSON Data
Example Good TOML Rule for Testing
Example Bad TOML Rule for Testing
Testing
test_rule.toml
in/rules
directory. Contents are shared above. Use both good and bad rule.python -m detection_rules view-rule PATH_TO_RULE_FILE
With the good rule, testing output should be a JSON object, which means the rule has been loaded through the dataclasses defined, including the alert suppression dataclass.
{'_schema': ["Suspicious Network Connection Attempt by Root rule's 'language' must be 'kuery' when using alert suppression."]}