Repository navigation
ci: read-only top-level permissions in every workflow, writes per job (#1599) - #1624
Merged
Merged
Conversation
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.
Fixes #1599
What changes
ci.ymlhad nopermissions:at all. It now hascontents: readat the top, and the Test job addspull-requests: read, which the Changelog gate'sgh api repos/.../pulls/N/filesneeds. No job in it writes.release.yamlgrantedcontents: write,id-token: writeandattestations: writeto the whole workflow. The top level is nowcontents: read, and those three grants sit on thegoreleaserjob, which uses all of them: the GitHub release, cosign keyless signing plus the release-role OIDC plus provenance, and the attestation.deploy-checklist(pull-requests: write) and thedeploy-lambdascall (id-token: write, which the called workflow'sdeployjob needs) already had their own blocks.security.yml(contents: read), andawscli-pin.yml,efa-pin.ymlanddeploy-lambdas.yaml({}plus per-job grants), already complied. They are unchanged.The gate
workflow_permissions_test.godiscovers every file under.github/workflowsand fails when discovery finds nothing. It enforces four rules:permissions:key.pull_requestorpull_request_targetgrants no write anywhere.id-token: writeappears only on a job that uses an OIDC token:configure-aws-credentialswithrole-to-assume, cosign,attest-build-provenance, or a call to a local reusable workflow whose own jobs hold it.It runs under
go test ./...and also as a named "Workflow permissions gate" step in CI.I watched each rule fail against a revert that compiles:
ci.ymlandrelease.yaml;pull-requests: writeon the Test job;id-token: writeondeploy-checklist.Deployed state
The org and repo
default_workflow_permissionsare bothreadtoday, pergh api .../actions/permissions/workflow. So this change is defence in depth, and it does not change how any job runs now.Checks
make check: the root tests and lint pass locally. The only failures are path-with-a-space failures inlambda/dashboard-api, from the worktree's location. They are unrelated to this change.actionlint: the one finding is SC2001 in the Changelog gate's existing script.semgrepon the changed files is clean.