fix: support Docker images with SHA256 digests #340
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.
Description
This PR fixes an issue where Docker images containing SHA256 digests (e.g.,
cimg/node:22.11.0@sha256:76aae...
) incorrectly triggered "Missing image tag" errors.The fix properly supports Docker image references that use SHA256 digests for pinning to specific image versions, which is a common practice for ensuring reproducible builds and enhanced security.
This change pursues the same goal as #313, but that PR has been inactive for more than six months, so I reassessed the approach and implemented it anew.
I also considered verifying that the digest actually exists and, when a tag is present alongside a digest, that both refer to the same manifest. However, Docker Hub provides no direct API for digest look-ups and the added complexity seemed unwarranted, so this PR limits itself to parsing and validating the digest format.
Implementation details
Parser Changes (
pkg/parser/dockerImageParser.go
)@
as a digest:(@(.+))?$
Digest
field toast.DockerImageInfo
structure for storing the digest valueValidation Changes (
pkg/parser/validate/
)isValidDockerDigest()
function to validate digest formatsha256:[64 hex characters]
"Invalid Docker image digest format \"foo\". Expected format: sha256:<64 hexcharacters>"
How to validate