Repository navigation
Restrict the workflow token permissions and pass only the needed secrets - #80
Merged
Merged
Conversation
GRADLE_ENCRYPTION_KEY is optional in test.yml, because pull requests from forks receive no secrets. Assisted-by: Claude:claude-opus-5-5
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.
The GitHub Actions workflows had no
permissions:block, passed all secrets to the reusable test workflow, and used an input expression directly in arun:script.This PR fixes the findings of
zizmorthat we can fix in the YAML alone.What changed
GITHUB_TOKENpermissions. Without apermissions:block, the token gets the default permissions of the repository or the org. Now:release.ymlsetspermissions: {}at the top, so each job must ask for what it needs.build-and-releasejob getscontents: writeto create the GitHub release andpackages: writeto push to GHCR.contents: read.GH_PERSONAL_ACCESS_TOKEN, so they do not need more permissions onGITHUB_TOKEN.test.yml.secrets: inheritgave all secrets to the test workflow, includingGH_PERSONAL_ACCESS_TOKENin the release workflow.test.ymlnow declaresGRADLE_ENCRYPTION_KEYas aworkflow_callsecret, andmain.ymlandrelease.ymlpass only that secret. The secret is optional, because the build works without it:setup-gradlethen only skips the save and restore of the configuration cache. Pull requests from forks and from Dependabot also receive no secrets. Note: the CI logs show thatGRADLE_ENCRYPTION_KEYis empty today, also for runs from this repository, so CI never caches the configuration cache. To change this, an admin must create the secret, for example withopenssl rand -base64 16.persist-credentials: falseintest.yml. The test job does not push, so the token does not need to stay in.git/config.incrementinput goes throughenv:.release.ymlused${{ github.event.inputs.increment }}directly in the script. It is nowINCREMENTinenv:, as GitHub recommends for inline scripts (Use an intermediate environment variable). The real risk was low, because only users with write access can start the workflow and the input is achoice.Not in this PR
GH_PERSONAL_ACCESS_TOKENin the release checkout.actions/checkoutstores the PAT in.git/configfor the whole release job, so every later step can read it. The job needs it forpushReleaseand the README push tomain. A fine-grained PAT limited to this repository, or a GitHub App token fromactions/create-github-app-token, reduces the risk. This needs a change in the repository or org settings.@v5. GitHub recommends a full commit SHA for third-party actions. With SHA pins, we also need Dependabot for thegithub-actionsecosystem, so the pins stay current.Relation to #79
#79 added a Helm chart push to GHCR in the release job. The
packages: writepermission of this PR covers that push too.Tests
zizmor1.16.3 in default mode reports 15 findings instead of 24. Noexcessive-permissions,secrets-inherit, ortemplate-injectionerror or warning remains. The remaining findings are the PAT checkout and 6 tag references, see "Not in this PR", and 8 informational or help findings for our own values (env.*andsteps.*).