Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Runtime image for goreleaser dockers_v2 (binary layout: $TARGETPLATFORM/kollect-render).
FROM gcr.io/distroless/static-debian12:nonroot
# Index digest (multi-arch). Scorecard Pinned-Dependencies; do not float on :nonroot.
FROM gcr.io/distroless/static-debian12:nonroot@sha256:1b7b9f0f0e0a1d2155f531db587cc48ec26aaf97ab64364225f5bf18a054e66a

Check warning on line 3 in Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use either the version tag or the digest for the image instead of both.

See more on https://sonarcloud.io/project/issues?id=PlatformRelay_kollect-render&issues=AZ_4GHE5uFBrYGwgCuIB&open=AZ_4GHE5uFBrYGwgCuIB&pullRequest=21
ARG TARGETPLATFORM

COPY ${TARGETPLATFORM}/kollect-render /kollect-render
Expand Down
41 changes: 41 additions & 0 deletions hack/test/dockerfile_pin_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Fail if Dockerfile FROM lines are not pinned to a sha256 digest.
# Scorecard Pinned-Dependencies treats a floating tag as mutable supply chain.
# Run: bash hack/test/dockerfile_pin_test.sh
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
DF="${ROOT}/Dockerfile"

fail=0
ok() { echo "ok: $*"; }
bad() { echo "FAIL: $*" >&2; fail=1; }

[[ -f "${DF}" ]] || { echo "FAIL: Dockerfile missing at ${DF}" >&2; exit 1; }

from_count=0
while IFS= read -r line || [[ -n "${line}" ]]; do
[[ "${line}" =~ ^[[:space:]]*FROM[[:space:]] ]] || continue
from_count=$((from_count + 1))
# Drop trailing comments.
ref="${line#FROM }"
ref="${ref%%#*}"
ref="${ref%"${ref##*[![:space:]]}"}"
# Stage alias (AS builder) is allowed after the digest.
if [[ ! "${ref}" =~ @sha256:[0-9a-f]{64}([[:space:]]|$) ]]; then
bad "unpinned FROM: ${line}"
else
ok "pinned FROM: ${ref}"
fi
done <"${DF}"

if [[ "${from_count}" -eq 0 ]]; then
echo "FAIL: no FROM lines in Dockerfile — assert is vacuous" >&2
exit 1
fi

if [[ "${fail}" -ne 0 ]]; then
echo "dockerfile_pin_test: RED" >&2
exit 1
fi
echo "dockerfile_pin_test: GREEN"
Loading