ci: add least-privilege permissions to remaining workflows#1451
Open
bmehta001 wants to merge 1 commit into
Open
ci: add least-privilege permissions to remaining workflows#1451bmehta001 wants to merge 1 commit into
bmehta001 wants to merge 1 commit into
Conversation
Adds top-level `permissions: { contents: read }` to the six workflow
files on `main` that lacked an explicit GITHUB_TOKEN scope:
- .github/workflows/build-android.yml
- .github/workflows/build-ios-mac.yml
- .github/workflows/build-posix-latest.yml
- .github/workflows/build-ubuntu-2204.yml
- .github/workflows/build-windows-vs2022.yaml
- .github/workflows/test-win-latest.yml
All six only check out source and run builds or tests; none post PR
comments, deploy artifacts via the token, or otherwise need write
scopes. `actions/upload-artifact@v4` (build-android.yml) uses its own
per-run SAS URL and does not require GITHUB_TOKEN scopes.
Carry-forward from PR microsoft#1450, which hardened spellcheck.yml the same
way, and mirrors the analogous modules-repo commit decc96501. Each
file gets an explanatory comment naming the CodeQL rule it satisfies
(actions/missing-workflow-permissions) if Actions analysis is later
enabled in this repo's code-scanning config. No behavior change.
Already-permissioned workflows (codeql-analysis.yml, deploy-docs-pages.yml)
are not touched.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds top-level least-privilege permissions: { contents: read } blocks to six CI workflows that previously inherited the repo default GITHUB_TOKEN scope. None of these workflows post comments, publish releases/packages, or write via the token, so contents: read is sufficient for actions/checkout. This mirrors the hardening pattern from PR #1450 (spellcheck) and modules PR #320.
Changes:
- Add
permissions: { contents: read }top-level block to six workflows. - Add explanatory comments referencing the CodeQL
actions/missing-workflow-permissionsrule. - No changes to triggers, jobs, runners, or steps.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/build-android.yml | Adds least-privilege permissions block before concurrency: |
| .github/workflows/build-ios-mac.yml | Adds least-privilege permissions block before concurrency: |
| .github/workflows/build-posix-latest.yml | Adds least-privilege permissions block before concurrency: |
| .github/workflows/build-ubuntu-2204.yml | Adds least-privilege permissions block before concurrency: |
| .github/workflows/build-windows-vs2022.yaml | Adds least-privilege permissions block before jobs: |
| .github/workflows/test-win-latest.yml | Adds least-privilege permissions block before concurrency: |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Adds top-level
permissions: { contents: read }to the six sister workflows that lacked an explicitGITHUB_TOKENscope, scoping the token to the minimum needed foractions/checkout.build-android.ymlcontents: readbuild-ios-mac.ymlcontents: readbuild-posix-latest.ymlcontents: readbuild-ubuntu-2204.ymlcontents: readbuild-windows-vs2022.yamlcontents: readtest-win-latest.ymlcontents: readWhy
Carry-forward from #1450 (which hardened
spellcheck.yml). Without an explicitpermissions:block,GITHUB_TOKENinherits the repo default — broader than needed. None of these jobs:actions/upload-artifact@v4uses its own per-run SAS, notGITHUB_TOKEN).So
contents: read(just enough foractions/checkout@v4) is sufficient everywhere.Each comment also names the CodeQL rule it satisfies (
actions/missing-workflow-permissions) if Actions language analysis is later added to this repo'scodeql-analysis.ymlmatrix — currently it's[cpp, javascript, python]+ Java only, which is why these don't appear as code-scanning alerts today.Mirrors the analogous modules-repo commit
decc96501(in modules PR #320), which closed 4 outstandingmissing-workflow-permissionsalerts there.Not touched
codeql-analysis.ymlanddeploy-docs-pages.yml— already have explicitpermissions:blocks.spellcheck.yml— already being hardened in ci(spellcheck): pin misspell + add least-privilege permissions #1450 (don't want to conflict)..offfiles — disabled by extension, not active workflows.Validation
permissions: {contents: read}at the top level.build-android.ymlwas CRLF upstream; rest are LF; my blobs match).References