-
Notifications
You must be signed in to change notification settings - Fork 645
✨ Add GitHub artifact attestation for Signed-Releases #5001
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,13 +26,19 @@ | |||||||||||||||||||||||||||||||||||||||||
| sce "github.com/ossf/scorecard/v5/errors" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||||||||||||||||||
| ownerEndpointUser = "users" | ||||||||||||||||||||||||||||||||||||||||||
| ownerEndpointOrg = "orgs" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| type releasesHandler struct { | ||||||||||||||||||||||||||||||||||||||||||
| client *github.Client | ||||||||||||||||||||||||||||||||||||||||||
| once *sync.Once | ||||||||||||||||||||||||||||||||||||||||||
| ctx context.Context | ||||||||||||||||||||||||||||||||||||||||||
| errSetup error | ||||||||||||||||||||||||||||||||||||||||||
| repourl *Repo | ||||||||||||||||||||||||||||||||||||||||||
| releases []clients.Release | ||||||||||||||||||||||||||||||||||||||||||
| client *github.Client | ||||||||||||||||||||||||||||||||||||||||||
| once *sync.Once | ||||||||||||||||||||||||||||||||||||||||||
| ctx context.Context | ||||||||||||||||||||||||||||||||||||||||||
| errSetup error | ||||||||||||||||||||||||||||||||||||||||||
| repourl *Repo | ||||||||||||||||||||||||||||||||||||||||||
| releases []clients.Release | ||||||||||||||||||||||||||||||||||||||||||
| ownerEndpointPrefix string | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| func (handler *releasesHandler) init(ctx context.Context, repourl *Repo) { | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -55,10 +61,58 @@ | |||||||||||||||||||||||||||||||||||||||||
| handler.errSetup = sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("githubv4.Query: %v", err)) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| handler.releases = releasesFrom(releases) | ||||||||||||||||||||||||||||||||||||||||||
| handler.ownerEndpointPrefix = handler.resolveOwnerEndpointPrefix() | ||||||||||||||||||||||||||||||||||||||||||
| handler.checkAttestations() | ||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||
| return handler.errSetup | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+64
to
69
|
||||||||||||||||||||||||||||||||||||||||||
| handler.ownerEndpointPrefix = handler.resolveOwnerEndpointPrefix() | |
| handler.checkAttestations() | |
| }) | |
| return handler.errSetup | |
| } | |
| }) | |
| return handler.errSetup | |
| } | |
| // setupAttestations lazily enriches the already-loaded releases with | |
| // attestation metadata. This is intentionally separate from setup so that | |
| // generic release listing does not incur the additional per-asset API calls. | |
| func (handler *releasesHandler) setupAttestations() error { | |
| if err := handler.setup(); err != nil { | |
| return err | |
| } | |
| handler.ownerEndpointPrefix = handler.resolveOwnerEndpointPrefix() | |
| handler.checkAttestations() | |
| return nil | |
| } |
Copilot
AI
Apr 5, 2026
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.
The comment says "hasAttestation will skip on 404", but hasAttestation currently returns false for all errors and does not special-case 404s. This also means if Users.Get fails (rate limit/network) for an org-owned repo, the fallback to users/... can cause all attestation checks to incorrectly return false due to hitting the wrong endpoint. Consider either (a) updating the comment, or (b) handling 404 by retrying the alternate users/orgs prefix once before returning false.
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.
The code treats attestation as an alternative for scoring (sets 10) and suppresses warnings when the attestation probe is false, but it still logs a warning when provenance is false even if attestation is true for that release. If attestation is intended as an alternative to provenance, consider also suppressing the provenance warning for releases that already have an attestation OutcomeTrue to avoid confusing/noisy output when the check is already at max score.