-
Notifications
You must be signed in to change notification settings - Fork 585
[Bug] [DaC] Metadata maturity field default mismatch and poor enforcement of rule naming conventions #4285
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] [DaC] Metadata maturity field default mismatch and poor enforcement of rule naming conventions #4285
Changes from all commits
7dd5665
ade05d1
8dccaa0
a9cd449
de9bdca
510042d
55a04f2
fe7c190
f72f62f
0726c25
00bd8b0
513ea39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,10 +237,21 @@ def kibana_export_rules(ctx: click.Context, directory: Path, action_connectors_d | |
rule_resource["author"] = rule_resource.get("author") or default_author or [rule_resource.get("created_by")] | ||
if isinstance(rule_resource["author"], str): | ||
rule_resource["author"] = [rule_resource["author"]] | ||
contents = TOMLRuleContents.from_rule_resource(rule_resource, maturity="production") | ||
threat = contents.data.get("threat") | ||
first_tactic = threat[0].tactic.name if threat else "" | ||
rule_name = rulename_to_filename(contents.data.name, tactic_name=first_tactic) | ||
# Inherit maturity from the rule already exists | ||
maturity = "development" | ||
threat = rule_resource.get("threat") | ||
first_tactic = threat[0].get("tactic").get("name") if threat else "" | ||
rule_name = rulename_to_filename(rule_resource.get("name"), tactic_name=first_tactic) | ||
# check if directory / f"{rule_name}" exists | ||
if (directory / f"{rule_name}").exists(): | ||
rules = RuleCollection() | ||
rules.load_file(directory / f"{rule_name}") | ||
if rules: | ||
maturity = rules.rules[0].contents.metadata.maturity | ||
Comment on lines
+247
to
+250
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may be reading this wrong.
Other than my question on 4. it looks good to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For question 4, short answer is no. This is not necessary and we may not want to do it, looking for input as to other's thoughts on this. More context from the PR summary above.
|
||
|
||
contents = TOMLRuleContents.from_rule_resource( | ||
rule_resource, maturity=maturity | ||
) | ||
rule = TOMLRule(contents=contents, path=directory / f"{rule_name}") | ||
except Exception as e: | ||
if skip_errors: | ||
|
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.
Is click the best option we have without adding new dependencies for warnings?
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.
We do not have a logging standard for Detection Rules as far as I am aware, and each entry point for the CLI commands uses click. Other than introducing something new that would break current convention, I do not see a strong alternative, but certainly open to suggestions.