Skip to content

Commit e8380de

Browse files
Update to Pathlib
1 parent 56767c6 commit e8380de

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

detection_rules/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ def import_rules_into_repo( # noqa: PLR0912, PLR0913, PLR0915
223223
raise ValueError(f"Invalid rule file, please ensure the rule has a name field: {contents}")
224224

225225
local_contents = None
226-
rule_path = Path(
227-
os.path.join(str(save_directory) if save_directory else RULES_DIRS[0], base_path) # noqa: PTH118
228-
)
229-
if rules and contents.get("rule_id") in rules.id_map:
230-
rule_path = rules.id_map[contents["rule_id"]].path
231-
local_contents = rules.id_map[contents["rule_id"]].contents
226+
rule_base_path = Path(save_directory or RULES_DIRS[0])
227+
rule_path = rule_base_path / base_path
228+
rule_id = contents.get("rule_id")
229+
if rules and rule_id in rules.id_map:
230+
rule_path = rules.id_map[rule_id].path
231+
local_contents = rules.id_map[rule_id].contents
232232

233233
# handle both rule json formats loaded from kibana and toml
234234
data_view_id = contents.get("data_view_id") or contents.get("rule", {}).get("data_view_id")

0 commit comments

Comments
 (0)