Skip to content

[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

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions detection_rules/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ def rule_prompt(path=None, rule_type=None, required_only=True, save=True, verbos
contents[name] = threat_map
continue

if name == 'threshold':
contents[name] = {n: schema_prompt(f'threshold {n}', is_required=n in options['required'], **opts.copy())
for n, opts in options['properties'].items()}
continue

if kwargs.get(name):
contents[name] = schema_prompt(name, value=kwargs.pop(name))
continue
Expand Down
4 changes: 2 additions & 2 deletions tests/test_all_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def test_event_override(self):
for rule in self.all_rules:
# skip rules that do not leverage queries (i.e. machine learning)
# filters to acceptable query languages in definitions.FilterLanguages
# QueryRuleData should inheritenly ignore machine learning rules
# QueryRuleData should inherently ignore machine learning rules
if isinstance(rule.contents.data, QueryRuleData):
rule_language = rule.contents.data.language
has_event_ingested = rule.contents.data.get('timestamp_override') == 'event.ingested'
Expand All @@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

continue
else:
errors.append(f'{rule_str} - rule must have `timestamp_override: event.ingested`')
Expand Down