Skip to content

Commit 7dd5665

Browse files
Add stub for solution
1 parent d3c05a0 commit 7dd5665

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

detection_rules/cli_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
DEFAULT_PREBUILT_RULES_DIRS, RuleCollection,
2323
dict_filter)
2424
from .schemas import definitions
25-
from .utils import clear_caches
25+
from .utils import clear_caches, rulename_to_filename
2626

2727

2828
def single_collection(f):
@@ -95,6 +95,15 @@ def get_collection(*args, **kwargs):
9595
if len(rules) == 0:
9696
client_error("No rules found")
9797

98+
# TODO add check here for rule directory path
99+
# Either fix or warn if the path is not correct
100+
for rule in rules:
101+
threat = rule.contents.data.get("threat")
102+
first_tactic = threat[0].tactic.name if threat else ""
103+
rule_name = rulename_to_filename(rule.contents.data.name, tactic_name=first_tactic)
104+
if rule.path.name != rule_name:
105+
click.secho(f"WARNING: Rule path does not match expected path: {rule.path.name} != {rule_name}", fg="yellow")
106+
98107
kwargs["rules"] = rules
99108
return f(*args, **kwargs)
100109

0 commit comments

Comments
 (0)