Skip to content

exporter: fix attestation manifest push order - #7012

Merged
crazy-max merged 1 commit into
moby:masterfrom
crazy-max:fix-attestation-subject-push-order
Aug 3, 2026
Merged

exporter: fix attestation manifest push order#7012
crazy-max merged 1 commit into
moby:masterfrom
crazy-max:fix-attestation-subject-push-order

Conversation

@crazy-max

@crazy-max crazy-max commented Aug 3, 2026

Copy link
Copy Markdown
Member

OCI artifact attestations carry a subject reference to the image manifest. Push manifests in an order that keeps child manifests before parent indexes while also pushing any in-stack subject manifest before the attestation that references it.

Add an integration test variant with a strict registry proxy to cover registries that reject manifests whose subject doesn't already exist.

Comment on lines -1025 to +1044
testExportAttestations(t, sb, false, false)
testExportAttestations(t, sb, false, false, false)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So many booleans; perhaps we should consider a small struct for these options (can be a follow-up)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes can look at this as follow-up. Wanted to keep changes as small as possible for a patch release.

Comment thread util/push/push.go
@crazy-max
crazy-max force-pushed the fix-attestation-subject-push-order branch from ff0ebbb to edbd366 Compare August 3, 2026 09:26
Comment thread util/push/push.go Outdated
return nil
}
visited[desc.Digest] = struct{}{}
if images.IsManifestType(desc.MediaType) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't apply to attestations, but Index can also have Subject:
https://github.com/opencontainers/image-spec/blob/af26a05fba5ee648512f4ea3c9fda1fcc1b6d6dc/specs-go/v1/index.go#L33-L34

Could probably also easily support this by extending this check to also include Indexes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes makes sense to extend.

@crazy-max
crazy-max force-pushed the fix-attestation-subject-push-order branch from edbd366 to c1f459e Compare August 3, 2026 09:30
@crazy-max
crazy-max requested review from thaJeztah and vvoland August 3, 2026 09:31

@vvoland vvoland left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Comment thread util/push/push.go Outdated
if err != nil {
return err
}
var manifest struct {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ultra nit, not a blocker:

Suggested change
var manifest struct {
var referer struct {

or

Suggested change
var manifest struct {
var withSubject struct {

OCI artifact attestations carry a subject reference to the image manifest.
Push manifests in an order that keeps child manifests before parent indexes
while also pushing any in-stack subject manifest before the attestation
that references it.

Add an integration test variant with a strict registry proxy to cover
registries that reject manifests whose subject doesn't already exist.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max
crazy-max force-pushed the fix-attestation-subject-push-order branch from c1f459e to 067b18b Compare August 3, 2026 09:39
@crazy-max
crazy-max merged commit ad8b7a7 into moby:master Aug 3, 2026
198 checks passed
@crazy-max
crazy-max deleted the fix-attestation-subject-push-order branch August 3, 2026 10:15
@tianon

tianon commented Aug 3, 2026

Copy link
Copy Markdown
Member

I think this is backwards? Referrers were designed so that the referrer objects could and even should be pushed before the manifest, and IMO it's a registry bug to validate otherwise.

The canonical use case was making sure (detached) signatures are pushed before the object they're signing, so that the manifest doesn't ever exist on the registry without a signature.

@thaJeztah

Copy link
Copy Markdown
Member

The canonical use case was making sure (detached) signatures are pushed before the object they're signing, so that the manifest doesn't ever exist on the registry without a signature.

Interesting. Kinda makes sense; the referrer being part of the step to validate if the registry should accept the blob.

@thaJeztah thaJeztah mentioned this pull request Aug 3, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attestations as OCI artifacts fail to push to gitlab.com when the subject manifest is new

4 participants