-
Notifications
You must be signed in to change notification settings - Fork 564
Add tests to ensure rules are properly deprecated #1050
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
brokensound77
merged 3 commits into
elastic:main
from
brokensound77:tests/add-deprecation-tests
Mar 17, 2021
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Deprecating rules | ||
|
||
Rules that have been version locked (added to [version.lock.json](../etc/version.lock.json)), which also means they | ||
have been added to the detection engine in Kibana, must be properly [deprecated](#steps-to-properly-deprecate-a-rule). | ||
|
||
If a rule was never version locked (not yet pushed to Kibana or still in non-`production` `maturity`), the rule can | ||
simply be removed with no additional changes, or updated the `maturity = "development"`, which will leave it out of the | ||
release package to Kibana. | ||
|
||
|
||
## Steps to properly deprecate a rule | ||
|
||
1. Update the `maturity` to `deprecated` | ||
2. Move the rule file to [rules/_deprecated](../rules/_deprecated) | ||
3. Add `deprecation_date` and update `updated_date` to match | ||
|
||
Next time the versions are locked, the rule will be added to the [deprecated_rules.json](../etc/deprecated_rules.json) | ||
file. | ||
|
||
|
||
### Using the deprecate-rule command | ||
|
||
Alternatively, you can run `python -m detection_rules dev deprecate-rule <rule-file>`, which will perform all the steps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
{} | ||
{ | ||
"3a86e085-094c-412d-97ff-2439731e59cb": { | ||
"deprecation_date": "2021-03-03", | ||
"rule_name": "Setgid Bit Set via chmod", | ||
"stack_version": "7.13" | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
rules/_deprecated/privilege_escalation_setgid_bit_set_via_chmod.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[metadata] | ||
creation_date = "2020/04/23" | ||
deprecation_date = "2021/03/16" | ||
maturity = "deprecated" | ||
updated_date = "2021/03/16" | ||
brokensound77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[rule] | ||
author = ["Elastic"] | ||
description = """ | ||
An adversary may add the setgid bit to a file or directory in order to run a file with the privileges of the owning | ||
group. An adversary can take advantage of this to either do a shell escape or exploit a vulnerability in an application | ||
with the setgid bit to get code running in a different user’s context. Additionally, adversaries can use this mechanism | ||
on their own malware to make sure they're able to execute in elevated contexts in the future. | ||
""" | ||
from = "now-9m" | ||
index = ["auditbeat-*", "logs-endpoint.events.*"] | ||
language = "lucene" | ||
license = "Elastic License" | ||
max_signals = 33 | ||
name = "Setgid Bit Set via chmod" | ||
risk_score = 21 | ||
rule_id = "3a86e085-094c-412d-97ff-2439731e59cb" | ||
severity = "low" | ||
tags = ["Elastic", "Host", "Linux", "Threat Detection", "Privilege Escalation"] | ||
timestamp_override = "event.ingested" | ||
type = "query" | ||
|
||
query = ''' | ||
event.category:process AND event.type:(start or process_started) AND process.name:chmod AND process.args:(g+s OR /2[0-9]{3}/) AND NOT user.name:root | ||
''' | ||
|
||
|
||
[[rule.threat]] | ||
framework = "MITRE ATT&CK" | ||
[[rule.threat.technique]] | ||
id = "T1548" | ||
name = "Abuse Elevation Control Mechanism" | ||
reference = "https://attack.mitre.org/techniques/T1548/" | ||
[[rule.threat.technique.subtechnique]] | ||
id = "T1548.001" | ||
name = "Setuid and Setgid" | ||
reference = "https://attack.mitre.org/techniques/T1548/001/" | ||
|
||
|
||
|
||
[rule.threat.tactic] | ||
id = "TA0004" | ||
name = "Privilege Escalation" | ||
reference = "https://attack.mitre.org/tactics/TA0004/" | ||
[[rule.threat]] | ||
framework = "MITRE ATT&CK" | ||
|
||
[rule.threat.tactic] | ||
id = "TA0003" | ||
name = "Persistence" | ||
reference = "https://attack.mitre.org/tactics/TA0003/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
from the name, it's not clear whether this was the first version where this was removed, or the last version this was included
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.
That's a good point. I think I can better handle this when expanding for #958, so I will punt this to that