Skip to content

Commit

Permalink
Add all historical versions for v8.17.0 and above packages (#4279)
Browse files Browse the repository at this point in the history
(cherry picked from commit d3c05a0)
  • Loading branch information
shashank-elastic authored and github-actions[bot] committed Dec 3, 2024
1 parent ad9c598 commit 7b5f4ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion detection_rules/devtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +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]:
Expand Down Expand Up @@ -124,7 +126,19 @@ 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')

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 7b5f4ac

Please sign in to comment.