chore: GHA permissions hardening - #3474
Open
zbynekstara wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Hardens GitHub Actions workflows across the repo by resetting default GITHUB_TOKEN permissions at the workflow level and granting only the minimal scopes per job, plus disabling credential persistence on actions/checkout to reduce token exposure to build/test code.
Changes:
- Adds
permissions: {}at workflow scope and sets explicit per-job permissions. - Sets
persist-credentials: falseforactions/checkoutusages. - Cleans up workflow YAML formatting/indentation in a couple of files.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/test-pr.yml | Resets workflow permissions and constrains the test job token; disables persisted checkout credentials. |
| .github/workflows/stale.yml | Resets workflow permissions and keeps explicit write permissions for stale automation; fixes schedule indentation. |
| .github/workflows/sonar.yml | Resets workflow permissions and constrains the Sonar job token; disables persisted checkout credentials. |
| .github/workflows/release.yml | Applies workflow-level permission reset and disables persisted checkout credentials for the publish job. |
| .github/workflows/publish-joint-react-docs.yml | Moves Pages permissions from workflow-level to per-job and disables persisted checkout credentials. |
| .github/workflows/codeql.yml | Resets workflow permissions, keeps explicit CodeQL permissions, and disables persisted checkout credentials. |
Suppressed comments (1)
.github/workflows/publish-joint-react-docs.yml:101
- Previously this workflow granted
contents: readat the workflow level; after moving to per-job permissions, the deploy job no longer hascontents: read. Some Pages steps (e.g., configure/deploy) expect this permission; keeping it here matches the previous effective permissions.
permissions:
pages: write # publish the artifact to GitHub Pages
id-token: write # OIDC token the Pages deployment is verified with
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements two security hardening fixes on GHA workflows:
permissions: {}at the start of every workflow and grants scopes per job.persist-credentials: falseas part of allactions/checkoutconfigs. By default, this action writes the run'sGITHUB_TOKENinto.git/configas an auth header, where it stays readable by anything that runs later in the same job, but that is not necessary unless an action need to do something (e.g. a push) while relying on those credentials. Changing the default keeps the token out of reach of build and test code, which prevents some attack vectors. Writing to the repository is still allowed if an action supplies its own credentials (like whatchangeset-release/masterdoes inrelease.yml).