Skip to content

ci: declare least-privilege workflow permissions - #13

Merged
CameronBrooks11 merged 1 commit into
mainfrom
ci/workflow-permissions
Oct 19, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
ci/workflow-permissions

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

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).

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).
@CameronBrooks11
CameronBrooks11 merged commit 0702b4a into main Oct 19, 2026
9 checks passed
@CameronBrooks11
CameronBrooks11 deleted the ci/workflow-permissions branch October 19, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant