Skip to content

chore(ci): pin the workflow token to read-only contents - #83

Merged
htcom-code merged 1 commit into
mainfrom
ci/workflow-token-permissions
Oct 13, 2026
Merged

htcom-code merged 1 commit into
mainfrom
ci/workflow-token-permissions

Conversation

@htcom-code

Copy link
Copy Markdown
Owner

Why

The first CodeQL run (default setup, enabled 2026-10-13) raised four actions/missing-workflow-permissions alerts (#1–#4, medium), one per job in ci.yml: lint, build, test and ci-complete. With no permissions: block, every job gets the token scope set by the repository default.

That default is read today (default_workflow_permissions: read), so the token is not over-scoped right now. But the setting lives outside the repo. If someone switches it to read/write, every CI run, including the npm ci of third-party packages, would start holding a write token, and nothing in review would show it.

What

  • Add a workflow-level permissions: contents: read to .github/workflows/ci.yml. All four jobs only check out the code, run npm and compare job results, so read access to contents is all they use.
  • No job, step or trigger changes. The required check stays ci-complete.

Verification

  • This PR's CI: lint, build, test and ci-complete must pass with the narrowed token. That shows nothing needed more than contents: read.
  • This PR's CodeQL check should report the four alerts as fixed. They close on main after merge.

CodeQL flagged all four CI jobs with missing-workflow-permissions:
without a permissions block they take whatever token scope the
repository default grants. The default is read today, but that is a
setting outside the repo; declaring contents: read in the workflow
keeps the token read-only even if the default is changed later.

Co-Authored-By: htjulia <htjulia1@gmail.com>
@htcom-code
htcom-code merged commit a2dd6d2 into main Oct 13, 2026
7 checks passed
@htcom-code
htcom-code deleted the ci/workflow-token-permissions branch October 13, 2026 04:38
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