fix: Dockerfile handling with alias (#46)
CD / Release (push) Successful in 6s

The previous version didn't support Docker images with an alias e.g. "... AS base".

Reviewed-on: t.behrendt/trivy-actions#46
Reviewed-by: branch-buddy <branch-buddy@t00n.de>
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
This commit was merged in pull request #46.
This commit is contained in:
2026-02-26 21:52:38 +01:00
committed by t.behrendt
parent 8527a1b518
commit 83a7cef9f1
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -28,8 +28,12 @@ runs:
images=$(
for f in $file_list; do
[ -f "$f" ] || continue
# Dockerfile: FROM [--platform=...] <image>
awk '/^[[:space:]]*FROM[[:space:]]/ { print $NF }' "$f" 2>/dev/null || true
# Dockerfile: FROM [--platform=...] <image> [AS <name>]
awk '/^[[:space:]]*FROM[[:space:]]/ {
for (i = 2; i <= NF; i++) {
if ($i !~ /^--/) { print $i; break }
}
}' "$f" 2>/dev/null || true
# Kubernetes / Docker Compose: image: <ref>
grep -E '[[:space:]]image:[[:space:]]' "$f" 2>/dev/null | sed 's/.*image:[[:space:]]*//' | awk '{ print $1 }' || true
# Helmfile values: repository + tag (both required, by indent); tag without repo is skipped
+1 -1
View File
@@ -4,7 +4,7 @@ FROM example.com/library/nginx:v1
# Registry path with tag — shared with K8s to test deduplication
FROM example.com/distroless/static:nonroot
# Registry with digest (Dockerfile)
FROM example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
FROM example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa AS base
# Ignored tags
## Short repo:tag (ignored by design; only registry refs are extracted)