Skip to content

containerimage: use policyimage.ResolveAttestationStatements#6825

Draft
smerkviladze wants to merge 1 commit into
moby:masterfrom
smerkviladze:move-attestation-blobs
Draft

containerimage: use policyimage.ResolveAttestationStatements#6825
smerkviladze wants to merge 1 commit into
moby:masterfrom
smerkviladze:move-attestation-blobs

Conversation

@smerkviladze

@smerkviladze smerkviladze commented Jun 3, 2026

Copy link
Copy Markdown

WIP

Replaces BuildKit's private addAttestationBlobs function in source/containerimage/source.go with a call to the shared ResolveAttestationStatements function in moby/policy-helpers/pull/30.

Both functions do the same work: walk the layers of an attestation manifest, filter them by in-toto predicate type, fetch matching blobs, and add them to the attestation chain.

What changed:

  • Removed addAttestationBlobs from source/containerimage/source.go;
  • Replaced its call site with policyimage.ResolveAttestationStatements plus a small loop that merges the result into ac.Blobs while preserving the original "skip if already fetched" deduplication.

External behaviour is unchanged.

Testing:

This change is covered by existing integration tests:

  • testImageResolveProvenanceAttestation
  • testImageResolveAttestationChainLocal
  • testImageResolveAttestationChainRequiresNetwork

Replace the private addAttestationBlobs function with a call to the
shared implementation in github.com/moby/policy-helpers/image. The
deduplication of blobs against ac.Blobs that addAttestationBlobs
performed is preserved at the call site.

This consolidates the attestation-walking logic so that moby/buildkit
and moby/moby can share a single implementation rather than each
carrying its own copy.

Signed-off-by: Sopho Merkviladze <smerkviladze@mirantis.com>
@github-actions github-actions Bot added area/dependencies Pull requests that update a dependency file area/source labels Jun 3, 2026
Comment on lines +278 to +281
ac.Blobs[b.Descriptor.Digest] = sourceresolver.Blob{
Descriptor: b.Descriptor,
Data: b.Data,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ac.Blobs[b.Descriptor.Digest] = sourceresolver.Blob{
Descriptor: b.Descriptor,
Data: b.Data,
}
ac.Blobs[b.Descriptor.Digest] = sourceresolver.Blob(b)

In Go, values of one struct type are convertible to values of another struct type if both have the same fields with the same name and type, in the same order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dependencies Pull requests that update a dependency file area/source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants