verify-action-build: skip pin warning for multi-stage FROM references#733
Merged
verify-action-build: skip pin warning for multi-stage FROM references#733
Conversation
analyze_dockerfile previously warned on any FROM whose image lacked a @sha256 digest or tag, including FROM lines that refer to an earlier build stage by alias (e.g. FROM builder AS runtime after FROM node:20 AS builder). Multi-stage internal references don't pull an image — the name resolves to a stage defined in the same Dockerfile — so flagging them as unpinned is incorrect and noisy. Track aliases introduced by `FROM <image> AS <alias>` and treat any later FROM whose image matches a known alias as a multi-stage reference rather than an unpinned image. The regex is also tightened from `(.+?)` to `(\S+)` so the image token and optional stage alias parse unambiguously. Generated-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
analyze_dockerfileflaggedFROM <alias>as unpinned when the alias was defined by an earlierFROM ... AS <alias>in the same Dockerfile. Multi-stage internal references don't pull an image, so the warning was noise.FROM <image> AS <alias>and treat a laterFROMwhose image matches a known alias as a multi-stage reference instead of emitting a pin warning.(.+?)to(\S+)so the image token and optional alias parse unambiguously.Test plan
test_multistage_internal_from_no_warningscovering a two-stage Dockerfile (FROM node:20@sha256:abc123 AS builder→FROM builder AS runtime)uv run --with pytest pytest tests/verify_action_build/test_security.py— 16 passed🤖 Generated with Claude Code