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

Merged
AN
2mo ago
+19-0

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):

Jobpermissionscheckout persist-credentials: false
changescontents: read, pull-requests: readnot changed (runs no PR code)
tracker-leakscontents: read (unchanged)already set
typecheckcontents: read (unchanged)already set
typescriptcontents: read (inherited)added
driver-e2econtents: read (inherited)added
dbt-toolscontents: read (inherited)added
windows-installercontents: read (inherited)added
windows-ripgrep-e2econtents: read (inherited)added
cold-start-regressioncontents: read (inherited)added
marker-guardcontents: read (inherited)added (git fetch of the public upstream remote needs no credential)
dbt-tools-e2e, sanity-verdacciocontents: 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 1c970b1f85d4339ae74de8d7f0120782293f15f1. 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.

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.