From f70cda554b7408699c4b6022a3401db0780df8b9 Mon Sep 17 00:00:00 2001 From: Shashank K S Date: Tue, 3 Dec 2024 21:40:45 +0530 Subject: [PATCH 1/3] Add all historical versions for v8.17.0 and above pacakges --- detection_rules/devtools.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/detection_rules/devtools.py b/detection_rules/devtools.py index 0df0fe10c99..0b145c869f6 100644 --- a/detection_rules/devtools.py +++ b/detection_rules/devtools.py @@ -63,7 +63,8 @@ f'[![ATT&CK navigator coverage](https://img.shields.io/badge/ATT&CK-Navigator-red.svg)]({NAVIGATOR_URL})' ) RULES_CONFIG = parse_rules_config() - +# The base package version that we will start to include all versions of historical rules +BASE_PKG_VERSION = Version(major=8,minor=17,patch=0) def get_github_token() -> Optional[str]: """Get the current user's GitHub token.""" @@ -124,7 +125,16 @@ def build_release(ctx: click.Context, config_file, update_version_lock: bool, ge registry_data['conditions']['kibana.version'].strip("^")) sde = SecurityDetectionEngine() historical_rules = sde.load_integration_assets(previous_pkg_version) - limited_historical_rules = sde.keep_latest_versions(historical_rules) + current_pkg_version = Version.parse(registry_data['version']) + # pre-release versions are not included in the version comparison + # Version 8.17.0-beta.1 is considered lower than 8.17.0 + current_pkg_version_no_prerelease = Version(major=current_pkg_version.major,minor=current_pkg_version.minor,patch=current_pkg_version.patch) + if current_pkg_version_no_prerelease>= BASE_PKG_VERSION: + click.echo(f'[+] Adding all historical rule versions in our release package for version {current_pkg_version_no_prerelease}') + limited_historical_rules = historical_rules + else: + click.echo(f'[+] Limit historical rule versions in our release package for version {current_pkg_version_no_prerelease}') + limited_historical_rules = sde.keep_latest_versions(historical_rules) package.add_historical_rules(limited_historical_rules, registry_data['version']) click.echo(f'[+] Adding historical rules from {previous_pkg_version} package') From cb10be38acb0780938956d7eb3dfa1a5d3d5fbeb Mon Sep 17 00:00:00 2001 From: Shashank K S Date: Tue, 3 Dec 2024 21:50:05 +0530 Subject: [PATCH 2/3] Fix lint errors --- detection_rules/devtools.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/detection_rules/devtools.py b/detection_rules/devtools.py index 0b145c869f6..69377a884c5 100644 --- a/detection_rules/devtools.py +++ b/detection_rules/devtools.py @@ -64,7 +64,8 @@ ) RULES_CONFIG = parse_rules_config() # The base package version that we will start to include all versions of historical rules -BASE_PKG_VERSION = Version(major=8,minor=17,patch=0) +BASE_PKG_VERSION = Version(major=8, minor=17, patch=0) + def get_github_token() -> Optional[str]: """Get the current user's GitHub token.""" @@ -128,12 +129,15 @@ def build_release(ctx: click.Context, config_file, update_version_lock: bool, ge current_pkg_version = Version.parse(registry_data['version']) # pre-release versions are not included in the version comparison # Version 8.17.0-beta.1 is considered lower than 8.17.0 - current_pkg_version_no_prerelease = Version(major=current_pkg_version.major,minor=current_pkg_version.minor,patch=current_pkg_version.patch) - if current_pkg_version_no_prerelease>= BASE_PKG_VERSION: - click.echo(f'[+] Adding all historical rule versions in our release package for version {current_pkg_version_no_prerelease}') + current_pkg_version_no_prerelease = Version(major=current_pkg_version.major, + minor=current_pkg_version.minor, patch=current_pkg_version.patch) + if current_pkg_version_no_prerelease >= BASE_PKG_VERSION: + click.echo(f'[+] Adding all historical rule versions in our release package for version \ + {current_pkg_version_no_prerelease}') limited_historical_rules = historical_rules else: - click.echo(f'[+] Limit historical rule versions in our release package for version {current_pkg_version_no_prerelease}') + click.echo(f'[+] Limit historical rule versions in our release package for version \ + {current_pkg_version_no_prerelease}') limited_historical_rules = sde.keep_latest_versions(historical_rules) package.add_historical_rules(limited_historical_rules, registry_data['version']) click.echo(f'[+] Adding historical rules from {previous_pkg_version} package') From 93183162d926558366532e93aa4a01b0bc7ed21d Mon Sep 17 00:00:00 2001 From: Shashank K S Date: Tue, 3 Dec 2024 21:52:17 +0530 Subject: [PATCH 3/3] Adding minor release version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6e8a158f2e7..ad459c11c78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "detection_rules" -version = "0.2.1" +version = "0.3.0" 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." readme = "README.md" requires-python = ">=3.12"