Skip to content

Add krel attestation sign - #4505

Open
puerco wants to merge 1 commit into
kubernetes:masterfrom
puerco:krel-sign-attestation
Open

Add krel attestation sign#4505
puerco wants to merge 1 commit into
kubernetes:masterfrom
puerco:krel-sign-attestation

Conversation

@puerco

@puerco puerco commented Aug 26, 2026

Copy link
Copy Markdown
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds support to krel to sign in-toto statements onto sigstore bundles.

The new subcommand is called krel sign attestation. While it can sign any attestation (even on a user's laptop) the main goal is to run it in our cloud build, job right after staging is done to sign the attestations with another identity not accesible to our build process.

Which issue(s) this PR fixes:

None.

Special notes for your reviewer:

The command will by default read any ambient identity providers (like sigstore) but is really intended to be used with a service account key. When using the SA credentials, krel locks onto that signing method and will only sign with that identity or fail.

/assign @saschagrunert @cpanato

Does this PR introduce a user-facing change?

krel now supports signing attestations with `krel sign attestation`. 

@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Aug 26, 2026
@kubernetes-prow kubernetes-prow Bot added needs-priority cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/release-eng Issues or PRs related to the Release Engineering subproject labels Aug 26, 2026
@kubernetes-prow
kubernetes-prow Bot requested a review from jrsapi August 26, 2026 20:32
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: puerco

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

@kubernetes-prow
kubernetes-prow Bot requested a review from salaxander August 26, 2026 20:32
@kubernetes-prow kubernetes-prow Bot added sig/release Categorizes an issue or PR as relevant to SIG Release. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 26, 2026
This commit adds a new krel attestation sign command. It takes an
attestation file and signs it with sigstore, preferrably with a
service account credential but (if not available) trying the ambient
identity providers (just like cosign does).

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev>
@puerco
puerco force-pushed the krel-sign-attestation branch from f909cd7 to fc35a04 Compare August 26, 2026 20:50
@kubernetes-prow kubernetes-prow Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 26, 2026
&signAttestationOpts.serviceAccountFile,
serviceAccountFileFlag,
"",
"path to a Google service account key (defaults to ambien credentials)",

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.

Nit: "ambien" → "ambient".

var out io.Writer = os.Stdout

if opts.outputPath != "" {
f, err := os.Create(opts.outputPath)

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.

os.Create truncates/creates the output file before signing starts. If SignFile fails, the file is left behind empty or partially written. Consider removing it in the error path or writing to a temp file and renaming on success.

Comment thread pkg/attestation/sign.go
sgnr.Options.DisableSTS = true
}

defer sgnr.Close()

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.

defer sgnr.Close() runs when SignStatement returns, before SignFile calls WriteBundle with the same signer. Today this works because Close() is a no-op for the token flow and WriteBundle is pure serialization, but it means using the signer after its lifecycle ends. Moving the Close() into SignFile (after WriteBundle) would be cleaner.

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. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants