Skip to content

Commit 22fbe94

Browse files
committed
fix: ignore non-arch-specific tags when arch-specific variants exist
1 parent c7397ac commit 22fbe94

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

stack_scanner/main.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,24 @@ def scan_binary(
260260
subprocess.run(cmd)
261261

262262

263+
_ARCH_SUFFIXES = ("-amd64", "-arm64")
264+
265+
266+
def _filter_redundant_manifest_tags(tags: list[str]) -> list[str]:
267+
"""Remove non-arch-specific tags when arch-specific variants exist.
268+
269+
For example, if both "v4.5.1" and "v4.5.1-amd64" are present, the plain
270+
"v4.5.1" tag is dropped because the arch-specific tags already cover it.
271+
"""
272+
arch_bases = {
273+
tag.removesuffix(suffix)
274+
for tag in tags
275+
for suffix in _ARCH_SUFFIXES
276+
if tag.endswith(suffix)
277+
}
278+
return [tag for tag in tags if tag not in arch_bases or tag.endswith(_ARCH_SUFFIXES)]
279+
280+
263281
def scan_additional_images(secobserve_api_token: str) -> None:
264282
"""Scan additional images that are not part of the regular versioned Stackable release.
265283
@@ -285,7 +303,7 @@ def scan_additional_images(secobserve_api_token: str) -> None:
285303

286304
recent_tags, latest_tag = result
287305
if recent_tags:
288-
tags = recent_tags
306+
tags = _filter_redundant_manifest_tags(recent_tags)
289307
print(f"Found {len(tags)} recent tag(s) for {project}/{repository}: {tags}")
290308
elif latest_tag is not None:
291309
print(

0 commit comments

Comments
 (0)