Skip to content

Commit c79ce82

Browse files
ci: let Scorecard read branch protection via SCORECARD_TOKEN (#94)
* ci: pass SCORECARD_TOKEN so Scorecard can read branch protection Wire the optional Administration: Read-only PAT into both Scorecard action steps so Branch-Protection can leave the -1 auth error once a maintainer stores the secret. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: retrigger CI with corrected workflow budget note Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent fd060ad commit c79ce82

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎.github/workflows/scorecard.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ jobs:
3535
with:
3636
results_file: results.sarif
3737
results_format: sarif
38+
# Fine-grained PAT (Administration: Read-only) so Branch-Protection can read
39+
# classic rules. Maintainer stores it as SCORECARD_TOKEN; see SECURITY.md.
40+
# Fall back to github.token when SCORECARD_TOKEN is unset so an empty
41+
# secret does not override the action default and break the run.
42+
repo_token: ${{ secrets.SCORECARD_TOKEN || github.token }}
3843
# Public repositories: publish to the OpenSSF API for consumers and the badge.
39-
# Branch-Protection details that need admin scope stay partial without a PAT;
40-
# see SECURITY.md.
4144
publish_results: true
4245

4346
- name: Upload artifact
@@ -59,6 +62,7 @@ jobs:
5962
with:
6063
results_file: results.json
6164
results_format: json
65+
repo_token: ${{ secrets.SCORECARD_TOKEN || github.token }}
6266
publish_results: false
6367

6468
- name: Upload the result for the floor gate

‎SECURITY.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The published package can read the filesystem, read environment variables, spawn
2828

2929
## OpenSSF Scorecard
3030

31-
[`.github/workflows/scorecard.yml`](.github/workflows/scorecard.yml) runs OpenSSF Scorecard weekly, on every push to `main`, and on branch-protection changes. It publishes results to the Scorecard API and uploads SARIF to GitHub code scanning. Actions in that workflow are pinned to full commit SHAs, and the job uses the minimum token permissions Scorecard needs (`contents: read`, `security-events: write`, `id-token: write`).
31+
[`.github/workflows/scorecard.yml`](.github/workflows/scorecard.yml) runs OpenSSF Scorecard weekly, on demand, and on branch-protection changes. It publishes results to the Scorecard API and uploads SARIF to GitHub code scanning. Actions in that workflow are pinned to full commit SHAs, and the job uses the minimum token permissions Scorecard needs (`contents: read`, `security-events: write`, `id-token: write`). For the Branch-Protection check it also accepts an optional repository secret `SCORECARD_TOKEN`: a fine-grained PAT with **Administration: Read-only** (and Metadata read, set automatically), passed as `repo_token` per the [Scorecard fine-grained auth docs](https://github.com/ossf/scorecard-action/blob/main/docs/authentication/fine-grained-auth-token.md). Without that secret the check stays at `-1` ("some github tokens can't read" classic rules).
3232

3333
[`.github/workflows/codeql.yml`](.github/workflows/codeql.yml) runs CodeQL static analysis on every pull request and push to `main`, as well as every week and on demand, covering the JavaScript and TypeScript source that makes up the package, CLI, MCP server, and Action. It uploads SARIF to GitHub code scanning alongside the Scorecard and Offing results, with the same SHA-pinned actions and a job-level `security-events: write` permission.
3434

@@ -38,7 +38,7 @@ Existing workflows already declare top-level read permissions (or empty permissi
3838

3939
| Check | Why it is not raised further |
4040
|---|---|
41-
| Branch-Protection | `main` requires the `ci-ok` status check and conversation resolution. Required approving reviews stay at zero so agent and maintainer pull requests can merge after green checks; code-owner review is configured in `.github/CODEOWNERS` but not enforced as a hard gate. Admin-only Scorecard fields need a PAT the workflow does not store. |
41+
| Branch-Protection | `main` requires the `ci-ok` status check; force pushes and deletions are disabled. Required approving reviews stay at zero so agent and maintainer pull requests can merge after green checks; code-owner review is configured in `.github/CODEOWNERS` but not enforced as a hard gate. Reading classic protection rules needs the optional `SCORECARD_TOKEN` secret (Administration: Read-only); until a maintainer creates and stores that PAT, Scorecard reports `-1` for this check. |
4242
| Code-Review | Same as Branch-Protection: human review is expected for lifecycle evidence and public contracts via CODEOWNERS, but a required review count is not enforced on every merge. |
4343
| Pinned-Dependencies | GitHub Actions and Docker steps used in CI are SHA-pinned. The SLSA reusable workflow in `release.yml` stays on the upstream `v2.1.0` tag because that is how [`slsa-framework/slsa-github-generator`](https://github.com/slsa-framework/slsa-github-generator) documents calling it. |
4444
| Token-Permissions | Workflows use read-only (or empty) top-level permissions and grant write only on the jobs that need it. |

‎tests/scorecard-floor.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,11 @@ test("scorecard.yml keeps its Scorecard job to actions and runs the floor gate s
179179
const jsonIndex = steps.findIndex((step) => isScorecard(step) && step.with?.["results_format"] === "json");
180180
assert.ok(sarifIndex >= 0, "the SARIF analysis is missing from scorecard.yml");
181181
assert.ok(jsonIndex > sarifIndex, "the JSON analysis is missing from scorecard.yml");
182+
const sarifStep = steps[sarifIndex];
182183
const jsonStep = steps[jsonIndex];
184+
assert.equal(sarifStep?.with?.["repo_token"], "${{ secrets.SCORECARD_TOKEN || github.token }}");
183185
assert.equal(jsonStep?.with?.["results_file"], "results.json");
186+
assert.equal(jsonStep?.with?.["repo_token"], "${{ secrets.SCORECARD_TOKEN || github.token }}");
184187
assert.equal(jsonStep?.with?.["publish_results"], false);
185188
assert.equal(workflow.jobs.analysis["timeout-minutes"], 20);
186189

0 commit comments

Comments
 (0)