Skip to content

ci: drop contents and actions read from the scorecard job - #97

Merged
ryanhill1 merged 1 commit into
mainfrom
ci/scorecard-least-privilege
Aug 25, 2026
Merged

ci: drop contents and actions read from the scorecard job#97
ryanhill1 merged 1 commit into
mainfrom
ci/scorecard-least-privilege

Conversation

@ryanhill1

@ryanhill1 ryanhill1 commented Aug 25, 2026

Copy link
Copy Markdown
Member

Follow-up to #94, which merged before this came up in review on qBraid/pyqasm#412. Same change is open there and needed on qbraid-algorithms.

Both permissions are private-repository only

contents: read and actions: read do nothing on a public repository. Evidence, strongest last:

  1. The only Actions API call Scorecard makes is publicly readable. ListWorkflowRunsByFileName (checks/raw/github/packaging.go, checks/raw/binary_artifact.go) hits GET /repos/{owner}/{repo}/actions/workflows/{file}/runs. Requesting that for a public repo with no authentication at all returns 200 with total_count; /user returns 401 in the same session, confirming the request really was anonymous.

  2. Upstream ships both commented out. actions/starter-workflows code-scanning/scorecard.yml:

          # Uncomment the permissions below if installing in a private repository.
          # contents: read
          # actions: read
  3. OSSF dogfoods exactly this. ossf/scorecard and ossf/scorecard-action are both public and run with security-events: write and id-token: write alone. Their last five runs are green, and the checks that touch the Actions API score Packaging 10, Binary-Artifacts 10, CI-Tests 10. That is also the evidence for dropping contents: read — their actions/checkout step works without it.

Risk

Low but not zero. Both affected checks return an error rather than degrading if the API call fails, so a wrong call here would show as a check erroring rather than silently scoring low — visible, not silent. The run that merged with #1343 succeeded, so we have a known-good baseline to compare the next run against.

Worth noting Token-Permissions scores 9 rather than 10 on ossf/scorecard because they keep permissions: read-all at workflow level; ours is permissions: {}, which is stricter.

Summary by CodeRabbit

  • Chores
    • Updated the security analysis workflow permissions to follow a more restrictive access model.
    • Preserved the permissions required to publish security findings and authenticate securely.

Both are private-repository permissions and this repo is public.

The only Actions API call Scorecard makes is ListWorkflowRunsByFileName, from
the Packaging and Binary-Artifacts checks. That endpoint is publicly readable:
requesting it for a public repo with no authentication at all returns 200.

Upstream's starter workflow ships `contents: read` and `actions: read` commented
out under "uncomment if installing in a private repository", and OSSF runs
Scorecard on its own public repos -- ossf/scorecard and ossf/scorecard-action --
with `security-events: write` and `id-token: write` alone. Those runs are green
and score Packaging 10, Binary-Artifacts 10 and CI-Tests 10, which is the same
evidence for dropping `contents: read`: their checkout step works without it.

Follows #94, which merged before this was raised in review on qBraid/pyqasm#412.
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3f6e39f2-7567-483c-980c-eca58a309984

📥 Commits

Reviewing files that changed from the base of the PR and between 53da882 and 68f51d9.

📒 Files selected for processing (1)
  • .github/workflows/scorecard.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The Scorecard analysis job permissions were reduced. The job now requests only security-events: write and id-token: write.

Changes

Scorecard workflow permissions

Layer / File(s) Summary
Reduce analysis job permissions
.github/workflows/scorecard.yml
The job no longer requests contents: read or actions: read permissions. It retains security-events: write and id-token: write.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 68f51

This narrowly removes unnecessary read permissions from the Scorecard workflow; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: removing the contents: read and actions: read permissions from the Scorecard job.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/scorecard-least-privilege

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ryanhill1
ryanhill1 merged commit 138ae99 into main Aug 25, 2026
11 checks passed
@ryanhill1
ryanhill1 deleted the ci/scorecard-least-privilege branch August 25, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant