Skip to content

Commit a3a7e0c

Browse files
authored
Filter out "-env" suffixed tags from CVE remediation (#245)
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
1 parent 8ea5b31 commit a3a7e0c

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

.github/scripts/cve-scan-helper-remediation.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ find_compatible_upgrade() {
187187
continue
188188
fi
189189

190+
# Skip internal testing tags with -env suffix (e.g., "720-env")
191+
if [[ "$tag" =~ -env$ ]]; then
192+
continue
193+
fi
194+
190195
parse_output=$(parse_version "$tag" 2>/dev/null) || continue
191196

192197
local tag_version="${parse_output%|*}"

.github/scripts/tests/cve-scan-helper-remediation.bats

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,28 @@ setup() {
237237
[ "$result" = "20240707" ]
238238
}
239239

240+
@test "find_compatible_upgrade: skips internal -env tags" {
241+
# Current: 2.0.0
242+
# Available: internal -env tags, valid versions
243+
# Should return: 2.1.0 (skips 720-env, 718-env)
244+
local tags=("720-env" "2.1.0" "718-env" "2.0.0")
245+
local result
246+
result=$(find_compatible_upgrade "2.0.0" "${tags[@]}")
247+
248+
[ "$result" = "2.1.0" ]
249+
}
250+
251+
@test "find_compatible_upgrade: returns empty when only -env tags are newer" {
252+
# Current: 2.0.0
253+
# Available: 720-env, 718-env (newer but -env), 2.0.0 (equal, not an upgrade)
254+
# Should return: empty (-env tags must never be selected as upgrade target)
255+
local tags=("720-env" "718-env" "2.0.0")
256+
local result
257+
result=$(find_compatible_upgrade "2.0.0" "${tags[@]}")
258+
259+
[ -z "$result" ]
260+
}
261+
240262
# ============================================================================
241263
# verify-image step Tests
242264
# ============================================================================

0 commit comments

Comments
 (0)