Skip to content

ci: declare contents:read on pre-commit workflow#7848

Open
arpitjain099 wants to merge 1 commit into
tensorflow:masterfrom
arpitjain099:chore/ci-lint-permissions
Open

ci: declare contents:read on pre-commit workflow#7848
arpitjain099 wants to merge 1 commit into
tensorflow:masterfrom
arpitjain099:chore/ci-lint-permissions

Conversation

@arpitjain099
Copy link
Copy Markdown

The pre-commit workflow runs pre-commit/action@v3.0.1 against the diff range. It only checks out the repo and invokes pre-commit hooks locally; no GitHub API write, no comment-on-PR step.

This patch sets permissions: contents: read at workflow scope, matching the per-job permission block already declared in wheels.yml (id-token: write for trusted publishing).

With explicit scope:

  • the workflow token can't be widened by a future change to the repository default
  • the SLSA / OpenSSF Scorecard Token-Permissions check passes for this file
  • a hypothetical compromise of actions/checkout, actions/setup-python, or pre-commit/action (cf. tj-actions/changed-files CVE-2025-30066) stays boxed in read-only

ci-test.yml is deliberately out of scope: it uses cache: 'pip' in setup-python plus a bazelisk-cache: true directive, both of which write back to the GitHub Actions cache. Pinning explicit permissions there has to account for the cache-save path, which deserves a separate look.

No behavioural change.

The pre-commit workflow runs pre-commit/action@v3.0.1 against a diff
range. No GitHub API write beyond actions/checkout. contents:read is
the minimum.

Matches the per-job permissions block already used by wheels.yml
(id-token:write for trusted publishing).

ci-test.yml is left out because it uses both setup-python cache and
bazelisk-cache, which interact with the cache-save path and warrant
a separate discussion.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@keerthanakadiri keerthanakadiri self-assigned this May 14, 2026
@keerthanakadiri keerthanakadiri requested a review from aktech May 14, 2026 05:24
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.

2 participants