Skip to content

Commit a8dbf2c

Browse files
[FR] Expand CUSTOM_RULES_DIR to support user relative paths (#5390)
* Add user relative path support
1 parent 634de61 commit a8dbf2c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

detection_rules/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def parse_rules_config(path: Path | None = None) -> RulesConfig: # noqa: PLR091
227227
raise ValueError(f"rules config file does not exist: {path}")
228228
loaded = yaml.safe_load(path.read_text())
229229
elif CUSTOM_RULES_DIR:
230-
path = Path(CUSTOM_RULES_DIR) / "_config.yaml"
230+
path = Path(CUSTOM_RULES_DIR).expanduser() / "_config.yaml"
231231
if not path.exists():
232232
raise FileNotFoundError(
233233
"""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "detection_rules"
3-
version = "1.5.18"
3+
version = "1.5.19"
44
description = "Detection Rules is the home for rules used by Elastic Security. This repository is used for the development, maintenance, testing, validation, and release of rules for Elastic Security’s Detection Engine."
55
readme = "README.md"
66
requires-python = ">=3.12"

tests/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
def load_rules() -> RuleCollection:
2727
if CUSTOM_RULES_DIR:
2828
rc = RuleCollection()
29-
path = Path(CUSTOM_RULES_DIR)
29+
path = Path(CUSTOM_RULES_DIR).expanduser()
3030
assert path.exists(), f"Custom rules directory {path} does not exist"
3131
rc.load_directories(directories=RULES_CONFIG.rule_dirs)
3232
rc.freeze()
@@ -62,7 +62,7 @@ def setUpClass(cls):
6262
RULE_LOADER_FAIL = True
6363
RULE_LOADER_FAIL_MSG = str(e)
6464

65-
cls.custom_dir = Path(CUSTOM_RULES_DIR).resolve() if CUSTOM_RULES_DIR else None
65+
cls.custom_dir = Path(CUSTOM_RULES_DIR).expanduser().resolve() if CUSTOM_RULES_DIR else None
6666
cls.rules_config = RULES_CONFIG
6767

6868
@staticmethod

0 commit comments

Comments
 (0)