From 4054eb43d13bbb123778b987b4f3cb199825b33a Mon Sep 17 00:00:00 2001 From: Terrance DeJesus <99630311+terrancedejesus@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:40:51 -0500 Subject: [PATCH] patch fix for 2503 (#2527) --- detection_rules/rule.py | 4 ++-- detection_rules/version_lock.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/detection_rules/rule.py b/detection_rules/rule.py index 7703b337c..874559996 100644 --- a/detection_rules/rule.py +++ b/detection_rules/rule.py @@ -678,7 +678,7 @@ class BaseRuleContents(ABC): @property def is_dirty(self) -> Optional[bool]: """Determine if the rule has changed since its version was locked.""" - min_stack = Version.parse(self.get_supported_version()) + min_stack = Version.parse(self.get_supported_version(), optional_minor_and_patch=True) existing_sha256 = self.version_lock.get_locked_hash(self.id, str(min_stack).rstrip(".0")) if existing_sha256 is not None: @@ -743,7 +743,7 @@ class BaseRuleContents(ABC): """Get the lowest stack version for the rule that is currently supported in the form major.minor.""" rule_min_stack = self.metadata.get('min_stack_version') min_stack = self.convert_supported_version(rule_min_stack) - return str(min_stack) + return f"{min_stack.major}.{min_stack.minor}" def _post_dict_transform(self, obj: dict) -> dict: """Transform the converted API in place before sending to Kibana.""" diff --git a/detection_rules/version_lock.py b/detection_rules/version_lock.py index 3cfd1a74c..2ab6c949f 100644 --- a/detection_rules/version_lock.py +++ b/detection_rules/version_lock.py @@ -202,7 +202,8 @@ class VersionLock: for rule in rules: if rule.contents.metadata.maturity == "production" or rule.id in newly_deprecated: # assume that older stacks are always locked first - min_stack = Version.parse(rule.contents.get_supported_version()) + min_stack = Version.parse(rule.contents.get_supported_version(), + optional_minor_and_patch=True) lock_from_rule = rule.contents.lock_info(bump=not exclude_version_update) lock_from_file: dict = lock_file_contents.setdefault(rule.id, {})