ci: set explicit permissions on workflows missing them - #29015
ci: set explicit permissions on workflows missing them#29015harshil-mistry wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
|
📊 PR Size: size/S
|
|
@googlebot I signed it! |
|
Pushed a follow-up commit to fix the failing zizmor flagged I fixed it rather than leaving the check red, since it's the same least-privilege concern this PR is about: the step now passes That leaves the workflow scoped at both levels — Happy to split this into its own PR if you'd rather keep the two separate. |
Summary
Adds an explicit
permissions:block to the six workflows that didn't have one, scoped to what each actually needs.Details
Without a
permissions:block a workflow'sGITHUB_TOKENinherits the repository/org default rather than being scoped to its job. The other 41 workflows here already declare one, and the repo is otherwise careful about this (actions pinned to full SHAs with# ratchet:comments,persist-credentials: falseon checkouts), so these six looked like oversights.I read each workflow before choosing a scope rather than blanket-applying
contents: read:deflake.ymlcontents: 'read'npm ci, build, dockerlinks.ymlcontents: 'read'tools-python-ci.ymlcontents: 'read'trigger_e2e.ymlcontents: 'read'issue-opened-labeler.ymlissues: 'write'docs-rebuild.yml{}Two that aren't just
contents: read:issue-opened-labeler.ymlneedsissues: write. It prefers a GitHub App token but falls back tosecrets.GITHUB_TOKENwhenAPP_IDis unset (github-token: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'), then callsissues.getandissues.addLabels. Pinning it toreadwould look tidier but would break labeling on that fallback path.docs-rebuild.ymlgetspermissions: {}. Its only stepcurlssecrets.DOCS_REBUILD_URL— no checkout, no API calls — so it needs no token scopes at all.This is hardening rather than a bug fix: if the repo default is already read-only, nothing changes at runtime. Formatting follows the existing convention in this repo (quoted scalar values).
Related Issues
Fixes #29014
How to Validate
for f in .github/workflows/*.yml; do grep -q "permissions:" "$f" || echo "$f"; done— lists the six before the change, nothing after.permissionsresolves as intended ({'contents': 'read'},{'issues': 'write'},{}) with each file's job list unchanged.GITHUB_TOKENfallback path and itsissues.addLabelscall, and thatdocs-rebuild.ymlmakes no API calls.The real confirmation is that these workflows behave identically after merge; the labeler is the one to watch, since it's the only one needing write.
Pre-Merge Checklist
Platform matrix left unchecked deliberately — this changes GitHub Actions config only, with no code path to exercise per platform, and I can't run these workflows from a fork.
npm run preflightnot run for the same reason.