-
Notifications
You must be signed in to change notification settings - Fork 522
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] New Terms Rule Import Failing #3569
[Bug] New Terms Rule Import Failing #3569
Conversation
@@ -17,7 +17,7 @@ | |||
DATE_PATTERN = r'^\d{4}/\d{2}/\d{2}$' | |||
MATURITY_LEVELS = ['development', 'experimental', 'beta', 'production', 'deprecated'] | |||
OS_OPTIONS = ['windows', 'linux', 'macos'] | |||
NAME_PATTERN = r'^[a-zA-Z0-9].+?[a-zA-Z0-9()]$' | |||
NAME_PATTERN = r'^[a-zA-Z0-9].+?[a-zA-Z0-9\[\]()]$' |
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.
Have an example of why this was needed?
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.
Yes, any case where rules exported from Kibana have a title similar to Rule Name [Duplicate]
Example from the testing block above that has this:
@@ -165,7 +165,19 @@ def rule_prompt(path=None, rule_type=None, required_only=True, save=True, verbos | |||
contents[name] = schema_prompt(name, value=kwargs.pop(name)) | |||
continue | |||
|
|||
result = schema_prompt(name, is_required=name in required_fields, **options.copy()) | |||
if name == "new_terms": |
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.
lgtm if it works 😓
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.
Ideally we need to fix the schema itself and modify the TOML state of the data (which I know we are punting for a bug fix a bit later).
This prompt is in desperate need of refactor, so intermediate patches help, but should be considered the temporary solution.
Nice job on this - 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.
This LGTM. I do think we don't need this if check on new_terms_fields
. The schema identifies that its new_terms
, in which case all the fields are required.
Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com>
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
* initial patch * Update definitions to allow for brackets in name * Update to prompt for required fields. * Update detection_rules/cli_utils.py Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> (cherry picked from commit fa75876)
Issues
#3542
Summary
This PR is an intermediate fix for addressing an issue where new terms rules do not import successfully. See the above issue for more context.
There are two primary issues addressed in this PR:
Testing
To test these updates use the following two example new terms rules and run
python -m detection_rules import-rules <filename> --required-only
This first export tests the first issue independently of the second.
rules_export.ndjson.txt
This second export tests both combined.
rules_export_new_terms_test_other.ndjson.txt