Repository navigation
Harden CI workflow token scope with explicit least-privilege permissions - #26
Conversation
Co-authored-by: fupacat <595487+fupacat@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The single-line contents: read permission is correctly placed and scoped, and matches every step in the workflow, which performs only checkout and read-only Maven builds.
0 open findings
What changed in this PR
This PR hardens the CI GitHub Actions workflow by replacing the implicit GITHUB_TOKEN scope with an explicit, workflow-level least-privilege permissions block. It remediates a code scanning finding about missing workflow token permissions. The contents: read scope matches the workflow's actual needs (checkout + Maven build/test/package), and no step requires write privileges, so the change is functionally safe.
Changes:
- Added a top-level
permissionsblock to.github/workflows/ci.ymlscopingGITHUB_TOKENtocontents: read.
| File | Description |
|---|---|
.github/workflows/ci.yml |
Declares explicit least-privilege token permissions (contents: read) at the workflow level to remove the implicit broad default scope. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This PR addresses the code scanning finding on GitHub Actions workflow permissions by removing implicit token scope and declaring explicit minimal permissions in CI. The change is narrowly scoped to the existing CI workflow.
Alert remediation
permissionsblock soGITHUB_TOKENdoes not inherit broader repository/org defaults.Workflow security posture