Repository navigation
Remove unused 'pull-requests: read' permission from the labels workflow - #28241
Open
吴旭云 (yuunnn) wants to merge 1 commit into
Open
吴旭云 (yuunnn) wants to merge 1 commit into
吴旭云 (yuunnn) wants to merge 1 commit into
Conversation
吴旭云 (yuunnn)
requested review from
a team and
Justin Chung (jshigetomi)
as code owners
October 20, 2026 09:37
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Label validation reads the webhook payload without API calls, and checkout retains its required permission.
No open issues 🎉
What changed in this PR
Addresses #28194 by reducing token permissions in the label-validation workflow.
Changes:
- Removes unused
pull-requests: read. - Retains
contents: readfor checkout without changing label validation.
| File | Description |
|---|---|
.github/workflows/labels.yml |
Removes an unnecessary token permission. |
Review effort: Balanced
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.
PR Summary
Fixes #28194.
Verify PR Labelsdeclarespull-requests: read, but no step in the workflow needs it. The only steps are:actions/checkout, which requirescontents: read.actions/github-script, whose inline script makes no API call. It readscontext.payload.pull_request.labels, which is already part of the webhook payload the runner received. Reading it does not touch the REST API, so no permission authorises anything.pull-requests: readwould only be required if the script fetched the labels through the API instead, for examplepulls.getorissues.listLabelsOnIssue. It does not, socontents: readis the minimal sufficient set.PR Context
Removing the scope keeps the workflow working and reduces the token permissions granted to the job, in line with the principle of least privilege. The token minted for this workflow is available to every step, including the third-party actions pinned in it.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerValidation
The change only removes a permission that is not consumed. The
verify-labelsjob is guarded byif: github.repository_owner == 'PowerShell', so it does not run on forks; on the upstream repository it continues to evaluatecontext.payload.pull_request.labelsexactly as before, andactions/checkoutkeeps thecontents: readit needs.