Skip to content

Commit cd5d12e

Browse files
Limit backports to 8.3+ (#2450)
* Drop Rule Support for Outdated Stack Versions Less Than 8.3 * changed version lock key assignment logic and updated version lock file * added comment to stack-schema-map file * changed version lock key assignment logic to use custom Version method) * Update detection_rules/devtools.py Co-authored-by: Mika Ayenson <[email protected]> * reverting version lock file to original * updated version lock from adjusted comparison logic of stack versions * updated logic in devtools; removed < 8.3.0 in version lock file * trimmed lock version before merge --------- Co-authored-by: Mika Ayenson <[email protected]> (cherry picked from commit 8db42da)
1 parent 41aca96 commit cd5d12e

File tree

4 files changed

+34
-6262
lines changed

4 files changed

+34
-6262
lines changed

.github/workflows/lock-versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
description: 'List of branches to lock versions (ordered, comma separated)'
77
required: true
88
# 7.17 was intentionally skipped because it was added late and was bug fix only
9-
default: '7.16,8.0,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8'
9+
default: '8.3,8.4,8.5,8.6,8.7,8.8'
1010

1111
jobs:
1212
pr:

detection_rules/devtools.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -930,44 +930,44 @@ def raw_permalink(raw_link):
930930

931931

932932
@dev_group.command('trim-version-lock')
933-
@click.argument('min_version')
933+
@click.argument('stack_version')
934934
@click.option('--dry-run', is_flag=True, help='Print the changes rather than saving the file')
935-
def trim_version_lock(min_version: str, dry_run: bool):
935+
def trim_version_lock(stack_version: str, dry_run: bool):
936936
"""Trim all previous entries within the version lock file which are lower than the min_version."""
937937
stack_versions = get_stack_versions()
938-
assert min_version in stack_versions, f'Unknown min_version ({min_version}), expected: {", ".join(stack_versions)}'
938+
assert stack_version in stack_versions, \
939+
f'Unknown min_version ({stack_version}), expected: {", ".join(stack_versions)}'
939940

940-
min_version = Version.parse(min_version)
941+
min_version = Version.parse(stack_version)
941942
version_lock_dict = default_version_lock.version_lock.to_dict()
942943
removed = {}
943944

944945
for rule_id, lock in version_lock_dict.items():
945946
if 'previous' in lock:
946947
prev_vers = [Version.parse(v, optional_minor_and_patch=True) for v in list(lock['previous'])]
947-
outdated_vers = [v for v in prev_vers if v <= min_version]
948+
outdated_vers = [f"{v.major}.{v.minor}" for v in prev_vers if v < min_version]
948949

949950
if not outdated_vers:
950951
continue
951952

952-
# we want to remove all "old" versions, but save the latest that is <= the min version as the new
953-
# min_version. Essentially collapsing the entries and bumping it to a new "true" min
954-
latest_version = max(outdated_vers)
953+
# we want to remove all "old" versions, but save the latest that is >= the min version supplied as the new
954+
# stack_version.
955955

956956
if dry_run:
957-
outdated_minus_current = [str(v) for v in outdated_vers if v != min_version]
957+
outdated_minus_current = [str(v) for v in outdated_vers if v < stack_version]
958958
if outdated_minus_current:
959959
removed[rule_id] = outdated_minus_current
960960
for outdated in outdated_vers:
961961
popped = lock['previous'].pop(str(outdated))
962-
if outdated == latest_version:
963-
lock['previous'][str(min_version)] = popped
962+
if outdated >= stack_version:
963+
lock['previous'][str(Version(stack_version[:2]))] = popped
964964

965965
# remove the whole previous entry if it is now blank
966966
if not lock['previous']:
967967
lock.pop('previous')
968968

969969
if dry_run:
970-
click.echo(f'The following versions would be collapsed to {min_version}:' if removed else 'No changes')
970+
click.echo(f'The following versions would be collapsed to {stack_version}:' if removed else 'No changes')
971971
click.echo('\n'.join(f'{k}: {", ".join(v)}' for k, v in removed.items()))
972972
else:
973973
new_lock = VersionLockFile.from_dict(dict(data=version_lock_dict))

detection_rules/etc/stack-schema-map.yaml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Updates:
88
## 7.17 was intentionally skipped because it was added late and was bug fix only
99
## 06/2022 - dropped backport support for 7.13.0, 7.14.0, 7.15.0 as of 8.4 branch creation
10+
## 01/2023 - dropped backport support for 7.16.0, 8.0.0, 8.1.0, 8.2.0 - https://github.com/elastic/detection-rules/pull/2450
1011

1112
## Unsupported
1213
#"7.13.0":
@@ -22,27 +23,27 @@
2223
# beats: "7.15.1"
2324
# ecs: "1.11.0"
2425

25-
## Supported
26+
# "7.16.0":
27+
# beats: "7.16.2"
28+
# ecs: "1.12.2"
29+
# endgame: "1.9.0"
2630

27-
"7.16.0":
28-
beats: "7.16.2"
29-
ecs: "1.12.2"
30-
endgame: "1.9.0"
31+
# "8.0.0":
32+
# beats: "8.0.1"
33+
# ecs: "8.0.1"
34+
# endgame: "1.9.0"
3135

32-
"8.0.0":
33-
beats: "8.0.1"
34-
ecs: "8.0.1"
35-
endgame: "1.9.0"
36+
# "8.1.0":
37+
# beats: "8.1.2"
38+
# ecs: "8.1.0"
39+
# endgame: "1.9.0"
3640

37-
"8.1.0":
38-
beats: "8.1.2"
39-
ecs: "8.1.0"
40-
endgame: "1.9.0"
41+
# "8.2.0":
42+
# beats: "8.2.1"
43+
# ecs: "8.2.1"
44+
# endgame: "1.9.0"
4145

42-
"8.2.0":
43-
beats: "8.2.1"
44-
ecs: "8.2.1"
45-
endgame: "1.9.0"
46+
## Supported
4647

4748
"8.3.0":
4849
beats: "8.3.3"

0 commit comments

Comments
 (0)