Skip to content

Conversation

@lcarva
Copy link
Contributor

@lcarva lcarva commented Jul 2, 2025

Changes

Chains fetches existing information about the container images it signs and attests. This works well when the image reference refers to an Image Index or an Image Manifest since those are served from the same endpoint in a container registry. However, when fetching information about a blob (layer) a different endpoint is needed.

Cosign handles this behavior by making this step optional: https://github.com/sigstore/cosign/blob/c86498055d0c4ea2f39076064aa094db12f85f6a/cmd/cosign/cli/sign/sign.go#L181-L186

Thus it is possible to sign/attest a blob with the cosign CLI. This commit implements the same logic to Chains so it can also sign/attest blobs.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Signing and attesting blobs is now supported.

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 2, 2025
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-chains-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/chains/storage/oci/attestation.go 80.0% 81.5% 1.5
pkg/chains/storage/oci/simple.go 81.5% 82.8% 1.3

@mathur07
Copy link
Contributor

mathur07 commented Jul 2, 2025

/lgtm

@tekton-robot
Copy link

@mathur07: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

}
se, err := ociremote.SignedEntity(req.Artifact, ociremote.WithRemoteOptions(s.remoteOpts...))
if err != nil {
if _, isEntityNotFoundErr := err.(*ociremote.EntityNotFoundError); isEntityNotFoundErr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whenever there is an entity not found we are default considering it as a blob, what if the digest was incorrect or the blob is not there? Is there a possibility to check if such a blob exists before attesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code is not necessarily handling a blob but it's handling the case where the image reference does not reference an existing Image Manifest or Image Index. It just so happens that this is what makes the blob signing/attesting work. I linked in the description how cosign itself implements this logic. I think it's safe to copy what they're doing there.

@anithapriyanatarajan
Copy link
Contributor

@lcarva Could you help clarify the scenario in which Tekton PRs or TRs would result in standalone blobs being pushed to container registries (i.e., not part of an image or manifest)?

From my understanding, typical Tekton outputs are full OCI images. Are there cases where individual blobs are pushed independently and need signing or attestation support?

This context would help in understanding the need for handling blob references explicitly in this logic.

Chains fetches existing information about the container images it signs
and attests. This works well when the image reference refers to an Image
Index or an Image Manifest since those are served from the same endpoint
in a container registry. However, when fetching information about a
blob (layer) a different endpoint is needed.

Cosign handles this behavior by making this step optional:
https://github.com/sigstore/cosign/blob/c86498055d0c4ea2f39076064aa094db12f85f6a/cmd/cosign/cli/sign/sign.go#L181-L186

Thus it is possible to sign/attest a blob with the cosign CLI. This
commit implements the same logic to Chains so it can also sign/attest
blobs.

Signed-off-by: Luiz Carvalho <[email protected]>
@lcarva lcarva force-pushed the handle-non-manifest branch from 3b48cfd to 512c64b Compare July 3, 2025 13:12
@lcarva
Copy link
Contributor Author

lcarva commented Jul 3, 2025

@lcarva Could you help clarify the scenario in which Tekton PRs or TRs would result in standalone blobs being pushed to container registries (i.e., not part of an image or manifest)?

From my understanding, typical Tekton outputs are full OCI images. Are there cases where individual blobs are pushed independently and need signing or attestation support?

This context would help in understanding the need for handling blob references explicitly in this logic.

It's really up to a Task. With something like oras, I can push individual blobs to the registry and emit those references in my Task result.

The use case I'm exploring that highlighted this was that I was using a Tekton Task to build a python wheel. I want to make sure the digest of the wheel (same as the digest of the blob) is in the SLSA Provenance.

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-chains-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/chains/storage/oci/attestation.go 80.0% 82.1% 2.1
pkg/chains/storage/oci/simple.go 81.5% 83.3% 1.9

}

ctx := logtesting.TestContextWithLogger(t)
_, err = storer.Store(ctx, &api.StoreRequest[name.Digest, *intoto.Statement]{
Copy link
Member

Choose a reason for hiding this comment

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

Any chance we can assert the output anyway ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's important. It looks like the Store method is half-baked and always returns &api.StoreResponse{}.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I did check that, but thought if we can assert the logs, but that should be fine as we are check if the error is nil or not

@PuneetPunamiya
Copy link
Member

/approve

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: PuneetPunamiya

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 8, 2025
@lcarva
Copy link
Contributor Author

lcarva commented Jul 8, 2025

/lgtm

Not sure if I can do this 🙏

@tekton-robot
Copy link

@lcarva: you cannot LGTM your own PR.

Details

In response to this:

/lgtm

Not sure if I can do this 🙏

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@PuneetPunamiya
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 9, 2025
@tekton-robot tekton-robot merged commit b15d733 into tektoncd:main Jul 9, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants