ci: scope reusable-workflow App tokens to least privilege#245
Merged
Conversation
Add explicit permission-* inputs to the six create-github-app-token steps that minted unscoped tokens (inheriting blanket GitHub App installation permissions), clearing the six standing zizmor/github-app code-scanning alerts (#170-#175). Each token is scoped to exactly what its consuming steps need, mirroring each job's already-declared permissions block: - enable-auto-merge (auto-merge): contents, pull-requests - create-release (release): contents, issues, pull-requests (semantic-release) - sync-cluster-policies (sync-policies): contents, pull-requests - validate-go-project (tidy, golangci-lint): contents, pull-requests - validate-go-project (lint): contents, issues, pull-requests Additive and backward-compatible: the token scope only narrows; no caller interface changes. update-copilot-skills.yaml was already scoped in #240. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR scopes previously unscoped GitHub App tokens in several reusable workflows by adding explicit permission-* inputs to actions/create-github-app-token, reducing token privileges and addressing zizmor github-app alerts across the workflow portfolio.
Changes:
- Added explicit
permission-*scopes to GitHub App token minting steps in multiple reusable workflows. - Aligned token scopes with the intended permissions needed by the downstream steps (checkout, PR operations, semantic-release).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| .github/workflows/validate-go-project.yaml | Adds explicit App token permission scoping for the auto-fix/tokenized checkout paths in tidy/lint jobs. |
| .github/workflows/sync-cluster-policies.yaml | Scopes the App token used for checkout + create-pull-request. |
| .github/workflows/enable-auto-merge.yaml | Scopes the App token used by gh to approve PRs and enable auto-merge. |
| .github/workflows/create-release.yaml | Scopes the App token used by semantic-release and checkout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The App tokens in the tidy, golangci-lint, and mega-linter jobs are used only as the git credential for checkout + git-auto-commit-action (pushing linter auto-fixes). They are never used for PR/issue API calls — MegaLinter's PR/issue reporting uses the default GITHUB_TOKEN, governed by the unchanged job-level permissions block. So the App tokens need contents:write only; drop the unused permission-pull-requests/permission-issues inputs to keep them least-privileged (addresses the Copilot review on PR #245). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What
Add explicit
permission-*inputs to the sixactions/create-github-app-tokensteps that were minting unscoped App tokens (inheriting the GitHub App's blanket installation permissions). This clears the six standingzizmor/github-app("dangerous use of GitHub App tokens") code-scanning alerts (#170–#175) on these reusable workflows.Why
A minted App token with no
permission-*inputs carries the full installation permission set, far more than any single job needs — exactly what zizmor'sgithub-apprule flags. These six were baseline (pre-existing, non-blocking) alerts. Scoping each token to least privilege hardens every consumer of these reusable workflows at once (the supply-chain blast radius is the whole portfolio) and is consistent with the scoping already applied toupdate-copilot-skills.yamlin #240.Scopes
Each token is scoped to exactly what its consuming steps need, mirroring each job's already-declared
permissions:block (so the App token is never more privileged than the job's intent — additive, nothing widens):permission-*addedenable-auto-merge/ auto-mergegh pr review --approve,gh pr merge --autocreate-release/ releasesync-cluster-policies/ sync-policiescreate-pull-request(signed commits)validate-go-project/ tidygo mod tidyauto-fixesvalidate-go-project/ golangci-lintvalidate-go-project/ lintValidation
actionlintclean on all four changed files — the only finding is the pre-existingcode-qualityunknown-scope false positive atvalidate-go-project.yaml(already documented in-file and ignored in CI viaACTION_ACTIONLINT_ARGUMENTS: -ignore code-quality); it is unrelated to this diff.workflow_callinputs/secrets) changes.Trade-offs / notes
create-releaseis scoped to the canonical semantic-release permission set (contents/issues/pull-requests) so both the Go (GoReleaser, commit-analyzer-only) and .NET (with@semantic-release/github) consumers keep working — a tightercontents-only scope would break the latter.