-
Notifications
You must be signed in to change notification settings - Fork 79
sign with sigstore-go instead of cosign #1594
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
base: main
Are you sure you want to change the base?
Conversation
|
Testing this was a challenge due to the OIDC/signing aspect of this, so I tested it by uploading a docker image and testing it from GitHub actions using that. https://github.com/spencerschrock/actions-test/actions/runs/18658202486/job/53207644946 You can see the transparency log entry get created correctly: And the webapp reject the results because it came from my fork instead of the real scorecard action: |
cosign used to do this, but sigstore-go doesn't have any support for ambient credential detection. This was copied from cosign: https://github.com/sigstore/cosign/blob/c6cdf1b37664e8e83fdf4d4abf464f2ead4021a2/pkg/providers/github/github.go Signed-off-by: Spencer Schrock <[email protected]>
This is in anticipation of Rekor v2, which will cause problems with the current way we verify results in the webapp. In order to verify with sigstore-go in the webapp, we also need the bundle, so send that over to the webapp. Configuration was based on sigstore-go's signing example: https://github.com/sigstore/sigstore-go/blob/b48a7c15af434de768f6db5d729a9aadafab5060/examples/sigstore-go-signing/main.go Signed-off-by: Spencer Schrock <[email protected]>
|
To help with reviewing, here is a difference between the OIDC I copied over, and the source: It doesnt need to fulfill the interface, so that functionality was cut, and it hardcodes the audience as sigstore. 1c1
< // Copyright 2025 OpenSSF Authors
---
> //
15,16d14
< //
< // SPDX-License-Identifier: Apache-2.0
18,19c16
< // Package oidc provides functionality to get an OIDC token from github.
< package oidc
---
> package github
28a26,28
>
> "github.com/sigstore/cosign/v3/pkg/cosign/env"
> "github.com/sigstore/cosign/v3/pkg/providers"
32,33c32,35
< envRequestURL = "ACTIONS_ID_TOKEN_REQUEST_URL"
< envRequestToken = "ACTIONS_ID_TOKEN_REQUEST_TOKEN"
---
> // Deprecated: use `env.VariableGitHubRequestToken` instead
> RequestTokenEnvKey = env.VariableGitHubRequestToken
> // Deprecated: use `env.VariableGitHubRequestURL` instead
> RequestURLEnvKey = env.VariableGitHubRequestURL
36,37c38,59
< func RequestToken(ctx context.Context) (string, error) {
< url := os.Getenv(envRequestURL) + "&audience=sigstore"
---
> func init() {
> providers.Register("github-actions", &githubActions{})
> }
>
> type githubActions struct{}
>
> var _ providers.Interface = (*githubActions)(nil)
>
> // Enabled implements providers.Interface
> func (ga *githubActions) Enabled(_ context.Context) bool {
> if env.Getenv(env.VariableGitHubRequestToken) == "" {
> return false
> }
> if env.Getenv(env.VariableGitHubRequestURL) == "" {
> return false
> }
> return true
> }
>
> // Provide implements providers.Interface
> func (ga *githubActions) Provide(ctx context.Context, audience string) (string, error) {
> url := env.Getenv(env.VariableGitHubRequestURL) + "&audience=" + audience
49c71
< req.Header.Add("Authorization", "bearer "+os.Getenv(envRequestToken))
---
> req.Header.Add("Authorization", "bearer "+env.Getenv(env.VariableGitHubRequestToken)) |
cmurphy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me from a sigstore-go perspective, it matches with the example usage. Glad to see sigstore-go being used instead of cosign for this use case.
Signed-off-by: Spencer Schrock <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1594 +/- ##
==========================================
- Coverage 26.32% 23.21% -3.12%
==========================================
Files 13 14 +1
Lines 775 866 +91
==========================================
- Hits 204 201 -3
- Misses 549 643 +94
Partials 22 22
🚀 New features to boost your workflow:
|
This is in anticipation of Rekor v2, which will cause problems with the
current way we verify results in the webapp. In order to verify with
sigstore-go in the webapp, we also need the bundle, so send that over
to the webapp.
Configuration was based on sigstore-go's signing example:
https://github.com/sigstore/sigstore-go/blob/b48a7c15af434de768f6db5d729a9aadafab5060/examples/sigstore-go-signing/main.go
As an added benefit, this drops binary size from 111MiB to 69MiB