Skip to content

feat: support cosign signatures in OCI-SIF files #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

dtrudg
Copy link
Member

@dtrudg dtrudg commented Jan 23, 2025

Add support for cosign signatures / attestations associated with images and indexes within OCI-SIF files.

Storage within the OCI-SIF

A cosign signature or attestation is an OCI image. It is associated with the image or index it targets using a tag based approach. The signature or attestation has a tag indicating the digest of its target.

Within an OCI-SIF file, we will store cosign signatures and annotations so that they have a org.opencontainers.image.ref.name annotation in the root index, where the ref.name is a placeholder _cosign
repository followed by the standard cosign tag, e.g.:

_cosign:sha256-432f982638b3aefab73cc58ab28f5c16e96fdb504e8c134fc58dff4bae8bf338.sig

SourceSink

The cosign module defines SignedImage and SignedImageIndex types, which wrap the standard ggcr image / index types. Because signatures / attestations are seperate images, associated with their target by tag, a SignedImage orSignedImageIndex needs to be able to access blobs outside of the scope of the wrapped image or index, to 'see' the
signatures / attestations.

This PR introduces a SIF SourceSink, which is both a Source and a Sink. A Source implements Get() to return a Descriptor that can provide an Image or an Index, depending on the content of the layout and the options that Get() was called with.

A Descriptor can be upgraded to a SignedDescriptor, which provides access to raw cosign signature/attestation images, as well as cosign.SignedImage/SignedImageIndex types.

A Sink implements Write(), accepting a Writable which is either a v1.Image or v1.Index. Options allow the image or index to have a name.ref annotation set in the root index when it is written.

Note that at this point, cosign signature / attestation images must be explicilty written into the SIF. Write does not automatically write associated signatures / attestations if passed a SignedImage.

@dtrudg dtrudg force-pushed the cosign-sourcesink-support branch 3 times, most recently from 834f3ad to a34bf95 Compare January 23, 2025 14:45
@dtrudg dtrudg marked this pull request as ready for review January 23, 2025 14:45
@dtrudg dtrudg force-pushed the cosign-sourcesink-support branch from a34bf95 to 588591f Compare January 23, 2025 15:19
Add support for cosign signatures / attestations associated with images
and indexes within OCI-SIF files.

**Storage within the OCI-SIF**

A cosign signature or attestation is an OCI image. It is associated with
the image or index it targets using a tag based approach. The signature
or attestation has a tag indicating the digest of its target.

Within an OCI-SIF file, we will store cosign signatures and annotations
so that they have a `org.opencontainers.image.ref.name` annotation in
the root index, where the `ref.name` is a placeholder `_cosign`
repository followed by the standard cosign tag, e.g.:

    _cosign:sha256-432f982638b3aefab73cc58ab28f5c16e96fdb504e8c134fc58dff4bae8bf338.sig

**SourceSink**

The cosign module defines `SignedImage` and `SignedImageIndex` types,
which wrap the standard ggcr image / index types. Because
signatures / attestations are seperate images, associated with their target
by tag, a `SignedImage` or`SignedImageIndex` needs to be able to access
blobs outside of the scope of the wrapped image or index, to 'see' the
signatures / attestations.

This PR introduces a SIF `SourceSink`, which is both a `Source` and a
`Sink`. A Source implements `Get()` to return a `Descriptor` that can
provide an Image or an Index, depending on the content of the layout
and the options that Get() was called with.

A `Descriptor` can be upgraded to a `SignedDescriptor`, which provides
access to raw cosign signature/attestation images, as well as
`cosign.SignedImage/SignedImageIndex` types.

A Sink implements `Write()`, accepting a Writable which is either a
v1.Image or v1.Index. Options allow the image or index to have a
`name.ref` annotation set in the root index when it is written.

Note that at this point, cosign signature / attestation images must
be explicilty written into the SIF. `Write` does not automatically
write associated signatures / attestations if passed a `SignedImage`
/ `SignedImageIndex`.
@dtrudg dtrudg force-pushed the cosign-sourcesink-support branch from 588591f to 57acf0c Compare January 23, 2025 15:19
@dtrudg dtrudg merged commit 6feb4f6 into sylabs:main Jan 23, 2025
12 checks passed
@dtrudg dtrudg deleted the cosign-sourcesink-support branch January 23, 2025 16:00
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.

2 participants