Repository navigation
fix attestation manifest serializing layers as null with zero statements - #7417
Closed
ToniAdreal wants to merge 1 commit into
Closed
ToniAdreal wants to merge 1 commit into
ToniAdreal wants to merge 1 commit into
Conversation
commitAttestationsManifest builds its manifest without setting Layers, and the append loop runs zero times when statements is empty, so the marshaled manifest contains "layers": null. This is the same defect moby#7341 reported for the distribution manifest, fixed there by moby#7343. Initialize Layers the same way so an attestation manifest with zero statements serializes "layers": []. Fixes moby#7411 Signed-off-by: ToniAdreal <184365500+ToniAdreal@users.noreply.github.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.
Fixes #7411
Problem
#7343 fixed the distribution manifest: a layerless image no longer serializes
"layers": null. The same pattern is still present in the attestation manifest path. Inexporter/containerimage/writer.go,commitAttestationsManifestbuilds its manifest literal without settingLayers, and the append loop only runs once per statement, so whenstatementsis empty,mfst.Layersstays nil and the marshaled manifest contains"layers": null. The image-specManifest.Layersfield has noomitempty, so this is the same schema-validating-registry rejection waiting to happen.Reachability (all on current master):
writer.go:317) enters the attestation path wheneverinp.Attestationscontains an entry for the platform, there is no length guard.attestation.Unbundlevalidates and then allocates an empty slice on empty input, no error.attestation.MakeInTotoStatementsmaps empty in to empty out.Fix
The same one-liner #7343 used for the distribution manifest: initialize
Layersin the manifest literal withmake([]ocispecs.Descriptor, 0, len(statements)).Verification
gofmtclean,go vet ./exporter/containerimage/clean,go build ./exporter/containerimage/passes.go test ./exporter/containerimage/...passes (the package itself has no test files;exptypespasses).Layers, zero statements) serializes"layers": []instead of"layers": null(Go 1.27.3, image-spec v1.1.1 as pinned by buildkit).Scope
I have not reproduced this in a real build: triggering it needs a platform entry in
Attestationswhose attestation list is empty, and I have not produced that state end to end. The evidence is source-level plus the marshal check above. The integration-test coverage for this path lives in the client tests, which need a daemon, so I am leaving that to CI here.