Skip to content
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

Add support for threshold rules #65

Merged
merged 2 commits into from
Jul 17, 2020

Conversation

brokensound77
Copy link
Contributor

Issues

resolves #63

Summary

This adds support for threshold rules in the schema and CLI. These rules are defined as type = threshold and have the additional required fields of field = string_field and value = int_greater_than 0

Support for the CLI is added as a temporary means, but the prompt will need complete refactoring and can be tracked in #64

Example

python -m detection_rules create-rule test/threshold.toml --required-only

█▀▀▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄   ▄      █▀▀▄ ▄  ▄ ▄   ▄▄▄ ▄▄▄
█  █ █▄▄  █  █▄▄ █    █   █  █ █ █▀▄ █      █▄▄▀ █  █ █   █▄▄ █▄▄
█▄▄▀ █▄▄  █  █▄▄ █▄▄  █  ▄█▄ █▄█ █ ▀▄█      █ ▀▄ █▄▄█ █▄▄ █▄▄ ▄▄█

Rule type (machine_learning, saved_query, query, threshold): threshold
author (required)  (multi, comma separated): punt-threater
description (required): test threshold
license [Elastic License] ("n/a" to leave blank)  (required): 
name (required): Threshold Rule
risk_score [21] ("n/a" to leave blank)  (required): 
rule_id [3020317b-b402-41e7-8443-cc18c832ae0a] ("n/a" to leave blank)  (required): 
severity [low] ("n/a" to leave blank)  (required): 
language [kuery] ("n/a" to leave blank)  (required): 
query (required): process.name:david.exe
threshold field (required): process.parent.name
threshold value (required): 25
ecs_version (multi, comma separated): 
Rule Threshold Rule saved to /Users/jibarra/PycharmProjects/detection-rules-fork/test/threshold.toml
Creates this rule
[metadata]
creation_date = "2020/07/16"
ecs_version = ["1.5.0"]
maturity = "development"
updated_date = "2020/07/16"

[rule]
author = ["punt-threater"]
description = "test threshold"
language = "kuery"
license = "Elastic License"
name = "Threshold Rule"
risk_score = 21
rule_id = "3020317b-b402-41e7-8443-cc18c832ae0a"
severity = "low"
type = "threshold"

query = '''
process.name:david.exe
'''


[rule.threshold]
field = "process.parent.name"
value = 25

@brokensound77 brokensound77 added the enhancement New feature or request label Jul 16, 2020
@brokensound77 brokensound77 changed the base branch from main to 7.9 July 16, 2020 17:34
@@ -245,6 +244,11 @@ def build(cls, path=None, rule_type=None, required_only=True, save=True, **kwarg
contents[name] = threat_map
continue

if name == 'threshold':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

temporary workaround until #64

@threat-punter threat-punter self-requested a review July 16, 2020 20:29
Copy link
Contributor

@rw-access rw-access left a comment

Choose a reason for hiding this comment

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

LGTM. agreed on the CLI 🏈 punt on #64

@brokensound77 brokensound77 merged commit 7647699 into elastic:7.9 Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Add support for threshold rules
3 participants