Repository navigation
ci: declare least-privilege workflow permissions - #13
Merged
Merged
Conversation
ci.yml ran with the repository's default GITHUB_TOKEN permissions,
which here are write. It now declares `contents: read` at the top
level, and one job is widened:
- changes: `contents: read` plus `pull-requests: read`. Its
dorny/paths-filter@v4 step lists the changed files through the
REST pull request API with `github.token` on pull_request events;
the action's v4 README states it requires `pull-requests: read`.
A job-level block replaces the top-level one, so `contents: read`
is restated for its checkout step. On push the action uses git and
needs nothing more.
- build-ubuntu, build-debian-trixie, build-arm64: check out, install
packages, and run cmake and ctest. `contents: read` covers them.
- ok: reads `needs.*.result` only.
ci.yml is not called from another workflow. This finds nothing:
git grep -n "uses: ./.github/workflows/ci.yml" -- .github
The only place naming it is the paths-filter `code` list inside the
`changes` job, so editing it sets `code` to true and the pull
request runs every build job.
Triggers: push to main and pull_request. Every job runs on a pull
request, and the pull_request run is the one that exercises the
`pull-requests: read` grant.
Validation: no actionlint here; ci.yml parses with `yaml.safe_load`
and resolves to top-level `{'contents': 'read'}` and, for
`changes`, `{'contents': 'read', 'pull-requests': 'read'}`.
Closes code-scanning alerts #1, #2, #3, #4 and #5 (rule
actions/missing-workflow-permissions, one per job).
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.
ci.yml ran with the repository's default GITHUB_TOKEN permissions,
which here are write. It now declares
contents: readat the toplevel, and one job is widened:
contents: readpluspull-requests: read. Itsdorny/paths-filter@v4 step lists the changed files through the
REST pull request API with
github.tokenon pull_request events;the action's v4 README states it requires
pull-requests: read.A job-level block replaces the top-level one, so
contents: readis restated for its checkout step. On push the action uses git and
needs nothing more.
packages, and run cmake and ctest.
contents: readcovers them.needs.*.resultonly.ci.yml is not called from another workflow. This finds nothing:
The only place naming it is the paths-filter
codelist inside thechangesjob, so editing it setscodeto true and the pullrequest runs every build job.
Triggers: push to main and pull_request. Every job runs on a pull
request, and the pull_request run is the one that exercises the
pull-requests: readgrant.Validation: no actionlint here; ci.yml parses with
yaml.safe_loadand resolves to top-level
{'contents': 'read'}and, forchanges,{'contents': 'read', 'pull-requests': 'read'}.Closes code-scanning alerts #1, #2, #3, #4 and #5 (rule
actions/missing-workflow-permissions, one per job).