chore(ci): add explicit GITHUB_TOKEN permissions to workflows#116
Conversation
e0af6b8 to
b4b4425
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses CodeQL actions/missing-workflow-permissions findings by explicitly declaring minimal GITHUB_TOKEN permissions across all GitHub Actions workflows in the repo.
Changes:
- Added
permissions: { contents: read }to workflows that only need repository read access (checkout/audits/security notification). - Added
permissions: { contents: read, actions: write }to test workflows that upload artifacts viaactions/upload-artifact. - Set
permissions: {}on the issue-to-Slack notification workflow to explicitly disableGITHUB_TOKENaccess.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/Security-Notification.yml | Adds contents: read for checkout while using a PAT for Dependabot API calls. |
| .github/workflows/run-tanstack-tests.yml | Adds contents: read + actions: write for artifact upload in test workflow. |
| .github/workflows/run-python-tests.yml | Adds contents: read + actions: write for artifact upload in test workflow. |
| .github/workflows/run-java-spring-boot-tests.yml | Adds contents: read + actions: write for artifact upload in test workflow. |
| .github/workflows/run-express-tests.yml | Adds contents: read + actions: write for artifact upload in test workflow. |
| .github/workflows/new-issue-notify.yml | Sets permissions: {} since the job posts to Slack without needing GitHub API access. |
| .github/workflows/audit-tanstack.yml | Adds contents: read for checkout-only dependency audit workflow. |
| .github/workflows/audit-python-fastapi.yml | Adds contents: read for checkout-only dependency audit workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Nice, tightly-scoped least-privilege change — the
|
upload-artifact@v4 authenticates via ACTIONS_RUNTIME_TOKEN, not GITHUB_TOKEN actions: write. Keep contents: read only per review. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Good catch — dropped
All four test workflows now use: permissions:
contents: read |
|
Correction on commit hash above — the permissions change is in |
Minimal checkout + upload-artifact job with contents: read only to confirm actions: write is unnecessary. Remove after PR #116 merges. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Added a minimal verification workflow ( Result: run succeeded in 11s — https://github.com/mongodb/docs-sample-apps/actions/runs/27133317095 This confirms |
Verified upload-artifact@v4 succeeds with contents: read only (run 27133317095). No need to keep the throwaway workflow in the repo. Co-authored-by: Cursor <cursoragent@cursor.com>
dacharyc
left a comment
There was a problem hiding this comment.
LGTM - thanks for updating the perms! ✅
Summary
Resolves 8 open CodeQL
actions/missing-workflow-permissionsfindings by declaring minimalGITHUB_TOKENscopes on every workflow.Changes
audit-tanstack,audit-python-fastapi):contents: readcontents: read,actions: write(required forupload-artifact)contents: read(checkout only; Dependabot API usesDEPENDABOT_PAT)permissions: {}(noGITHUB_TOKENusage; Slack via secret only)Test plan
Related
Made with Cursor