Skip to content

chore(ci): pin least-privilege token permissions in the CI workflow - #1440

Merged
anandgupta42 merged 1 commit into
mainfrom
chore/pin-ci-token-permissions
Oct 12, 2026
Merged

anandgupta42 merged 1 commit into
mainfrom
chore/pin-ci-token-permissions

Conversation

@anandgupta42

@anandgupta42 anandgupta42 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1439

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Standard least-privilege hardening of the CI workflow. The CI workflow runs on pull_request and executes code from the PR branch (tests, builds, scripts), but it declared no workflow-level permissions, so the scope of its token depended on a repository setting (the default workflow token permission). A workflow that runs PR code should not rely on a repo setting to get a read-only token, so this pins it in the file.

Changes, all in .github/workflows/ci.yml:

  • Add a top-level permissions block with contents: read.
  • Give the Detect Changes job pull-requests: read as well, because paths-filter lists the PR's files through the API.
  • Add persist-credentials: false to the checkout step of every job that runs PR code, so the checked-out code cannot read the token from the git config.

Per-job result (no job needs a write scope; no step calls the GitHub API with write, pushes, or uses OIDC):

Job permissions checkout persist-credentials: false
changes contents: read, pull-requests: read not changed (runs no PR code)
tracker-leaks contents: read (unchanged) already set
typecheck contents: read (unchanged) already set
typescript contents: read (inherited) added
driver-e2e contents: read (inherited) added
dbt-tools contents: read (inherited) added
windows-installer contents: read (inherited) added
windows-ripgrep-e2e contents: read (inherited) added
cold-start-regression contents: read (inherited) added
marker-guard contents: read (inherited) added (git fetch of the public upstream remote needs no credential)
dbt-tools-e2e, sanity-verdaccio contents: read (inherited) not changed (push-only, never run on PRs)

Deliberately not changed: the other workflows. aireceipts and dispatch-code-review already declare permissions; the remaining ones use pull_request_target, schedule, push or release triggers. No action versions, steps, or ordering were touched.

How did you verify your code works?

  • Parsed the workflow before and after and diffed the structures: the only differences are the permissions keys and the persist-credentials lines.
  • actionlint reports the same findings before and after (existing shellcheck notes only).
  • Read every step of each job to confirm none needs more than contents: read (no gh calls, no git push, no private submodules or git dependencies).
  • CI on this PR is the real test of the permission set: every PR job runs here under the pinned permissions.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

🤖 Generated with Claude Code


Note

Low Risk
Workflow-only token scoping and checkout credential hygiene; no application or runtime behavior changes.

Overview
Hardens the CI workflow so PR jobs no longer depend on the repo’s default GITHUB_TOKEN scope when running untrusted branch code.

Adds a workflow-level permissions: contents: read, grants pull-requests: read on the Detect Changes job (for paths-filter), and sets persist-credentials: false on actions/checkout for every job that executes PR code—so tests/scripts cannot read the token from git config. No job steps, action versions, or test commands were changed.

Reviewed by Cursor Bugbot for commit 1c970b1. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Hardens the ci.yml workflow with least-privilege token permissions so jobs that run pull-request code get a read-only token regardless of the repository's default setting.

  • Adds a top-level permissions: contents: read block.
  • Grants the Detect Changes job pull-requests: read so dorny/paths-filter can list the PR's files through the API.
  • Sets persist-credentials: false on the checkout step of every job running PR code so the checked-out code cannot read the token from git config.
  • No action versions, steps, or job ordering changed.

Written for commit 1c970b1. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Chores
    • Updated CI workflow permissions to limit repository and pull request access.
    • Checkout credentials are no longer retained in several automated checks. These changes affect the project’s build and test workflows; no end-user features or behavior changed.

`ci.yml` runs on `pull_request` and executes code from the PR branch (tests,
builds, scripts) but declared no workflow-level `permissions`, so its token
scope depended on the repository's default-token setting.

- add top-level `permissions: contents: read`
- `changes` job keeps `pull-requests: read` for `dorny/paths-filter`
- set `persist-credentials: false` on the `actions/checkout` steps of the
  jobs that run PR code (no later step in those jobs needs git credentials)

No action versions, steps, or ordering changed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6e5742bd-7fc0-49f4-8ef9-f0aca6697bb1

📥 Commits

Reviewing files that changed from the base of the PR and between 714de61 and 1c970b1.


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

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.



📝 Walkthrough

Walkthrough

The CI workflow now sets read-only token permissions and disables persisted checkout credentials in seven jobs.

Changes

CI token permissions

Layer / File(s) Summary
Workflow token permissions
.github/workflows/ci.yml
The workflow grants contents: read globally. The changes job also receives pull-requests: read.
Checkout credential persistence
.github/workflows/ci.yml
Seven jobs set persist-credentials: false. The marker-guard job retains its separate full-history checkout setting.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Suggested reviewers: ralphstodomingo


Merge Risk: ⚪ Minimal · up to 1c970

The workflow limits CI token access and avoids persisting checkout credentials in jobs that run pull-request code. No actionable merge-blocking issue was found.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: pinning least-privilege token permissions in the CI workflow.
Description check Passed The description includes the issue, change type, detailed implementation summary, verification steps, screenshots status, and completed checklist. It directly matches the pull request objectives.
Linked Issues check Passed Issue #1439 requires workflow-level contents: read, pull-requests: read only for the changes job, and persist-credentials: false for checkout steps in jobs that run PR code. The reviewed diff …
Out of Scope Changes check Passed The whole-PR diff contains changes only in .github/workflows/ci.yml. Each changed line adds the permissions or checkout credential setting described in issue #1439. No unrelated application, test, a…
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…

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the workflow lines
Read-only tokens keep their bounds
Checkout leaves no saved key behind
Seven jobs follow that design
The marker guard keeps full history
Then hops away, content and free

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

@kilo-code-bot

kilo-code-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • .github/workflows/ci.yml

Reviewed by gpt-6-sol · Input: 14 · Output: 2.1K · Cached: 207.2K

Review guidance: REVIEW.md from base branch main

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T04:46:11.337759Z 1c970b1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

View guided diff | Turn on auto-fix | Re-trigger cubic

@anandgupta42
anandgupta42 requested a review from sahrizvi October 12, 2026 17:32
@anandgupta42
anandgupta42 merged commit f30c6f1 into main Oct 12, 2026
35 checks passed
@anandgupta42
anandgupta42 removed the request for review from sahrizvi October 12, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: pin least-privilege token permissions in the CI workflow

1 participant