ci: wire optional SCORECARD_TOKEN for the Branch-Protection check#115
Merged
Conversation
The Branch-Protection Scorecard check needs to read classic branch-protection rules, which the default GITHUB_TOKEN can't — so it errors and scores -1. scorecard.yml now passes a repo_token that prefers a fine-grained PAT stored as the SCORECARD_TOKEN secret and falls back to github.token when it's absent, so forks and template copies still scan cleanly (only Branch-Protection degrades there). Documents the opt-in in the README.
🏗️ CDK infra diff — PR vs
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
scorecard.yml: passrepo_token: ${{ secrets.SCORECARD_TOKEN || github.token }}so the OpenSSF Scorecard Branch-Protection check can read classic branch-protection rules via a fine-grained PAT, falling back to the default token when the secret is absent.README.md: document the opt-in under Code scoring and attestation.Why
The default
GITHUB_TOKENcan't read classic branch-protection settings, so Branch-Protection currently reports an internal error and scores-1. A fine-grained PAT (repo-scoped,Administration: Read-only) stored asSCORECARD_TOKENlets it read and score them.Fork / template safe
Repository secrets are never copied to forks or "Use this template" copies, so the
|| github.tokenfallback keeps the scan working there — only Branch-Protection degrades to-1, exactly as it does today. No hard failure from the absent secret.Activation
Merging this is safe before the secret exists (it just falls back). The maintainer then creates the
SCORECARD_TOKENsecret and triggers a scan viaworkflow_dispatch.Scope
CI workflow + README only — no Python, infra, dependency, or API-surface changes. Validated:
check-yamlandmake lint-docspass.