Description
Describe the bug
The OCI 1.1 specification for the "referrers" API states that, for the descriptors in the returned referrers index, The descriptors MUST include an artifactType field that is set to the value of the artifactType in the image manifest or index, if present
and The descriptors MUST include annotations from the image manifest or index.
.
However, the current go-containerregistry
library does not fulfill either of these requirements.
To Reproduce
For annotations:
- Create a
v1.Image
with a non-emptyannotations
field andsubject
field and useremote.Write
to write the image - Call
remote.Referrers
on the subject and examine the manifest entry - Current behavior is that the descriptor for the image from step 1 does not have an
annotations
field
For artifactType
:
- Create a
v1.Image
that specifies a value for theartifactType
field (can be done by including this field in the output of theRawManifest()
implementation ofv1.Image
) andsubject
field and useremote.Write
to write the image - Call
remote.Referrers
on the subject and examine the manifest entry - Current behavior is that the
artifactType
field of the descriptor for the image from step 1 is set to the value ofConfig.MediaType
Expected behavior
For annotations:
- The descriptor for image should have an
annotations
field that matches theannotations
field of the image
For artifactType
:
- The descriptor for the image should have an
artifactType
value that matches thearitfactType
field of the image
Additional context
Full text of the referrers specification:
Upon success, the response MUST be a JSON body with an image index containing a list of descriptors. The Content-Type header MUST be set to application/vnd.oci.image.index.v1+json. Each descriptor is of an image manifest or index in the same <name> namespace with a subject field that specifies the value of <digest>. The descriptors MUST include an artifactType field that is set to the value of the artifactType in the image manifest or index, if present. If the artifactType is empty or missing in the image manifest, the value of artifactType MUST be set to the config descriptor mediaType value. If the artifactType is empty or missing in an index, the artifactType MUST be omitted. The descriptors MUST include annotations from the image manifest or index. If a query results in no matching referrers, an empty manifest list MUST be returned.
GitHub has implemented an action that uses the referrers API to upload referrers using subjects, and it looks like their implementation properly does this (sets annotations and artifact types for referrer ImageIndex): actions/attest-build-provenance#73 (comment)