From ea26ea77d7e99dae852c6fc1787afdc5b3ec0f2c Mon Sep 17 00:00:00 2001 From: eric-forte-elastic <119343520+eric-forte-elastic@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:20:18 -0400 Subject: [PATCH] [FR] Update build-release to support bbr release (#2987) * Fixes bug in unit tests * fix rule paths * removed unused import --- detection_rules/navigator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/detection_rules/navigator.py b/detection_rules/navigator.py index 1cba01c2e..228851af0 100644 --- a/detection_rules/navigator.py +++ b/detection_rules/navigator.py @@ -14,10 +14,10 @@ from marshmallow import pre_load import json -from . import utils from .attack import CURRENT_ATTACK_VERSION from .mixins import MarshmallowDataclassMixin from .rule import TOMLRule +from .rule_loader import DEFAULT_RULES_DIR, DEFAULT_BBR_DIR from .schemas import definitions @@ -163,8 +163,10 @@ class NavigatorBuilder: def rule_links_dict(self, rule: TOMLRule) -> dict: base_url = 'https://github.com/elastic/detection-rules/blob/main/rules/' - local_rules_path = utils.get_path('rules') - base_path = rule.path.relative_to(local_rules_path) + try: + base_path = str(rule.path.resolve().relative_to(DEFAULT_RULES_DIR)) + except ValueError: + base_path = str(rule.path.resolve().relative_to(DEFAULT_BBR_DIR)) url = f'{base_url}{base_path}' return self.links_dict(rule.name, url)