Skip to content

Add ociremote.WithSubjectDescriptor option#4940

Draft
codysoyland wants to merge 1 commit into
sigstore:mainfrom
codysoyland:ociremote-with-subject-descriptor
Draft

Add ociremote.WithSubjectDescriptor option#4940
codysoyland wants to merge 1 commit into
sigstore:mainfrom
codysoyland:ociremote-with-subject-descriptor

Conversation

@codysoyland

Copy link
Copy Markdown
Member

WriteReferrer unconditionally HEADs the subject reference to build the
referrer's subject descriptor, so attaching an attestation fails when the
subject manifest is not present in the target repository — even though the
OCI distribution spec explicitly allows manifests whose subject does not
exist. This option lets callers that store attestations apart from the
image (or before it is pushed) supply the subject descriptor directly,
instead of forking the referrer manifest construction. The descriptor is
used verbatim, a digest mismatch with the subject reference is rejected,
and behavior without the option is unchanged.

Assisted by Claude Fable 5

WriteReferrer unconditionally HEADs the subject reference to build the
referrer's subject descriptor, so attaching an attestation fails when
the subject manifest is not present in the target repository. The OCI
distribution spec explicitly allows manifests whose subject does not
exist, and callers that store attestations apart from the image (or
before it is pushed) currently have to fork the whole referrer manifest
construction just to relax that one HEAD.

Let callers supply the subject descriptor directly instead. The
descriptor is used verbatim — the caller is responsible for providing a
valid descriptor, and a digest that does not match the subject
reference is rejected to catch caller bugs. Without the option,
behavior is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Cody Soyland <cody.soyland@chainguard.dev>
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.86%. Comparing base (2ef6022) to head (c8c7429).
⚠️ Report is 775 commits behind head on main.

Files with missing lines Patch % Lines
pkg/oci/remote/write.go 81.81% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4940      +/-   ##
==========================================
- Coverage   40.10%   38.86%   -1.24%     
==========================================
  Files         155      222      +67     
  Lines       10044    13620    +3576     
==========================================
+ Hits         4028     5294    +1266     
- Misses       5530     7554    +2024     
- Partials      486      772     +286     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codysoyland added a commit to chainguard-dev/terraform-provider-cosign that referenced this pull request Jun 12, 2026
)

Writing a bundle referrer currently requires the subject manifest to
exist in the target repository: cosign's
`WriteAttestationNewBundleFormat` builds the referrer's subject
descriptor by unconditionally HEADing the subject reference, so the
write fails when the subject is absent — even though the OCI
distribution spec explicitly allows referrer manifests whose subject
does not exist.

Downstream status tooling hits exactly that case: it attests synthetic
digests (layer blobs, pseudo-digests of non-registry entities) into an
override repository where the subject manifest never exists.

This adds `Statement.SubjectDescriptor`, used verbatim as the referrer's
subject when supplied, while nil keeps the strict HEAD behavior. The
forked write path mirrors cosign's referrer manifest byte-for-byte
(pinned by a parity test) and is temporary until sigstore/cosign#4940,
which adds an `ociremote.WithSubjectDescriptor` option upstream, merges.

Assisted by Claude Fable 5

---------

Signed-off-by: Cody Soyland <cody.soyland@chainguard.dev>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant