-
Notifications
You must be signed in to change notification settings - Fork 575
[Bug] Threshold Rule Importing Failures #3560
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
[Bug] Threshold Rule Importing Failures #3560
Conversation
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.
With the issue to do larger refactors later, I think this makes sense.
@@ -973,7 +973,7 @@ def test_event_override(self): | |||
# TODO: determine if we expand this to ES|QL | |||
# ignores any rule that does not use EQL or KQL queries specifically | |||
# this does not avoid rule types where variants of KQL are used (e.g. new terms) | |||
if rule_language not in ('eql', 'kuery') or rule.contents.data.is_sequence: | |||
if rule_language not in ('eql', 'kuery') or getattr(rule.contents.data, 'is_sequence', False): |
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.
Good catch.
🟢 Testing Looks Good. Ran Import Rule of the test file.
File creation |
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
* remove threshold specific req * fix test event override --------- Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> (cherry picked from commit a9cc323)
Issues
#3547
Summary
This PR addresses an issue where threshold rules would not import correctly as the rule prompt would ask for information that was present in the rule file instead of using what was supplied. See the original issue for the steps to reproduce the error. The fix is to remove a hardcoding loading for specifically threshold rules to load them in this way. I expect that this was done due to a historic Kibana issue that is not longer necessary.
Note: If you import a rule and then run unit tests they will fail as we have some additional tags and fields that we enforce on our rules that should not be enforced on customers. In testing this, we also found a minor flaw in one of our unit tests (
test_event_override
) that is also fixed here. Previously the unit test would fail on the first instance of a test violation and not produce a list of all of the rules violating the test. This fix addresses that.Testing
Export a threshold rule from Kibana
Example: rules_export_threashold.ndjson.txt
Use the importer `python -m detection_rules import-rules <file.ndjson>
See that the importer no longer tries to prompt for threshold fields even though they exist in the ndjson