ci: fix CodeQL dockerfile/latest-tag alert in Dockerfile-distroless-testing#44857
Draft
Copilot wants to merge 2 commits into
Draft
ci: fix CodeQL dockerfile/latest-tag alert in Dockerfile-distroless-testing#44857Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…sting Switch FROM lines to use ARG-based digest references with placeholder defaults, and update ci/do_ci.sh to capture image digests via docker image inspect and pass them as --build-arg. Agent-Logs-Url: https://github.com/envoyproxy/envoy/sessions/78201a59-0327-4ae6-a0fe-fe3d919fcc15 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CodeQL alert for unpinned Dockerfile tags
ci: fix CodeQL dockerfile/latest-tag alert in Dockerfile-distroless-testing
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CodeQL alert #3503 (
dockerfile/latest-tag) fires on twoFROMlines inci/Dockerfile-distroless-testingthat referenceenvoyproxy/envoy:distroless-devandenvoyproxy/envoy:contrib-distroless-devby mutable tag. The tags are intentionally unpinned (CI tests freshly-built images), but dismissing the alert costs security scorecard points and suppresses the rule class globally.The fix parameterises the digest via
ARG, defaulting to a zero-hash placeholder. CodeQL treatsFROM image:tag@${ARG}as pinned (alert closes as fixed); CI injects the real digest at build time so the test still exercises the images produced in the same run. The zero-hash default is a deliberate tripwire — a build without the args fails immediately on manifest resolution rather than silently pulling a stale tag.ci/Dockerfile-distroless-testingAlso normalises
as→ASfor consistency with thedebian-basestage.ci/do_ci.sh(verify-distroless)Resolves the local image digest via
docker image inspect --format '{{.Id}}'(.Idis alreadysha256:…for locally-loaded images) and forwards both values as--build-argto eachdocker buildinvocation.Original prompt
Background
CodeQL alert #3503 (rule
dockerfile/latest-tag— unpinned tag in DockerfileFROM) fires onci/Dockerfile-distroless-testingfor these two lines:These references are intentionally unpinned in source: the purpose of this Dockerfile is to test images that were just built in the same CI run. We do not want to pin to a digest checked into the repo, because that would defeat the purpose of the test (we'd be testing a stale image, not the one this PR produces).
Dismissing the alert is not desired — it costs scorecard/secret-scanning points and silences a class of real regressions in other Dockerfiles.
Goal
Resolve the alert as fixed (not dismissed) while preserving the "test the freshly-built image" semantics.
Approach
Switch the two
FROMlines fromimage:tagform toimage:tag@${DIGEST}form, where${DIGEST}is a buildARGthat CI sets to the digest of the image it just built. Provide a deliberately invalid placeholder default so a missing override fails loudly rather than silently pulling a moving tag.The
dockerfile/latest-tagCodeQL query does not fire when the image reference contains an@sha256:…digest portion, even if that portion comes from anARG.Required changes
1.
ci/Dockerfile-distroless-testingUpdate to:
Note: also normalises
as→ASfor consistency with the existingdebian-basestage.2. CI invocation site(s)
Find where
ci/Dockerfile-distroless-testingis built (likely a workflow under.github/workflows/and/or a script underci/— search the repo forDockerfile-distroless-testing). Update each invocation to:envoyproxy/envoy:distroless-devandenvoyproxy/envoy:contrib-distroless-devimages. Two cases — pick whichever matches the existing CI flow:docker/build-push-action, use itsoutputs.digest.docker load), resolve via:.Idis already insha256:…form for locally-loaded images and is acceptable as the digest portion of aFROMreference resolved from the local daemon.)If the freshly-built images are only available locally (not pushed), the build of
Dockerfile-distroless-testingmust run with the same local Docker daemon / buildx instance so thatimage@sha256:<localId>resolves locally.Acceptance criteria
ci/Dockerfile-distroless-testingno longer triggers CodeQLdockerfile/latest-tag(alert hot restart failed when upgrade envoy binary from v1.5.0 to v1.6.0 #3503 closes as fixed on the PR's analysis).This pull request was created from Copilot chat.