wip(748): declare explicit token permissions on all six workflows — NOT VERIFIED, do not merge
Build CI Toolchain Image / Build & push CI image (push) Successful in 39s

Candidate for #748 so the owner-level Actions default can move to Restricted
(server-management#714). Parked unmerged: blocked by #751.

  review-verdict.yml (job-level)  code: write, issues: read, pull-requests: read
  the other five (top-level)      code: read

`code: write` because Gitea has no `statuses` scope — status-write IS Code-write
(`reqRepoWriter(unit.TypeCode)`). The two read units are NOT optional: the job
also reads `/issues/{n}/timeline` (the #706 retarget fence) and, via
`scripts/pr-changed-files.sh`, `/pulls/{n}/files`. Declaring `permissions:` is
exhaustive, so a missing unit 403s under `set -euo pipefail` and the gate stops
being written — for every PR, with no force-merge escape since #743.

Corrects #748's body: `docker-build.yml` does NOT write a status with the
injected token (it has no GITEA_TOKEN reference at all; its ETV_STATUS_AUTH is
the scoped REGISTRY_* PAT doing a read-only GET). Only review-verdict.yml needs
write.

WHY THIS IS NOT MERGED: `review-verdict.yml` is never exercised by its own PR
(base-resolved), so CI-green here proves nothing. The prescribed scratch-base
probe was run and came back INCONCLUSIVE — not because the permissions are
wrong, but because the classify/post step never executes at all (#751). There
is no POST whose scope could be verified. Land only after #751.

refs #748 #751
This commit is contained in:
2026-08-06 14:36:53 +02:00
parent 3aed43c6de
commit 7280a91dce
6 changed files with 74 additions and 0 deletions
+11
View File
@@ -50,6 +50,17 @@ env:
REGISTRY: 192.168.1.95:3000
CI_IMAGE: 192.168.1.95:3000/timothy/ersatztv-ci
# Explicit token scope (ersatztv#748) so the owner-level Actions default can move to Restricted
# (server-management#714). This workflow never uses the injected GITEA_TOKEN for anything but the
# checkout — its registry/package writes authenticate with the scoped REGISTRY_* PAT
# (`ci.actions-credential-scoping`), and its API reads, if any, use their own credential. Declaring
# `permissions:` is EXHAUSTIVE, not additive: a unit omitted here is not granted. Read-only is the
# convention for every workflow that does not write the repo — only `review-verdict.yml` opts into
# write, and it says why inline.
permissions:
code: read
jobs:
build:
name: Build & push CI image
+11
View File
@@ -33,6 +33,17 @@ env:
DOTNET_CLI_USE_MSBUILD_SERVER: "0"
MSBUILDDISABLENODEREUSE: "1"
# Explicit token scope (ersatztv#748) so the owner-level Actions default can move to Restricted
# (server-management#714). This workflow never uses the injected GITEA_TOKEN for anything but the
# checkout — its registry/package writes authenticate with the scoped REGISTRY_* PAT
# (`ci.actions-credential-scoping`), and its API reads, if any, use their own credential. Declaring
# `permissions:` is EXHAUSTIVE, not additive: a unit omitted here is not granted. Read-only is the
# convention for every workflow that does not write the repo — only `review-verdict.yml` opts into
# write, and it says why inline.
permissions:
code: read
jobs:
scan:
name: NuGet vulnerable packages
+11
View File
@@ -102,6 +102,17 @@ env:
DOTNET_CLI_USE_MSBUILD_SERVER: "0" # no persistent MSBuild server process
MSBUILDDISABLENODEREUSE: "1" # MSBuild worker nodes exit with the build instead of lingering
# Explicit token scope (ersatztv#748) so the owner-level Actions default can move to Restricted
# (server-management#714). This workflow never uses the injected GITEA_TOKEN for anything but the
# checkout — its registry/package writes authenticate with the scoped REGISTRY_* PAT
# (`ci.actions-credential-scoping`), and its API reads, if any, use their own credential. Declaring
# `permissions:` is EXHAUSTIVE, not additive: a unit omitted here is not granted. Read-only is the
# convention for every workflow that does not write the repo — only `review-verdict.yml` opts into
# write, and it says why inline.
permissions:
code: read
jobs:
test:
name: Build & test (.NET)
+11
View File
@@ -42,6 +42,17 @@ concurrency:
group: ersatztv-pr-gates-${{ github.ref }}
cancel-in-progress: true
# Explicit token scope (ersatztv#748) so the owner-level Actions default can move to Restricted
# (server-management#714). This workflow never uses the injected GITEA_TOKEN for anything but the
# checkout — its registry/package writes authenticate with the scoped REGISTRY_* PAT
# (`ci.actions-credential-scoping`), and its API reads, if any, use their own credential. Declaring
# `permissions:` is EXHAUSTIVE, not additive: a unit omitted here is not granted. Read-only is the
# convention for every workflow that does not write the repo — only `review-verdict.yml` opts into
# write, and it says why inline.
permissions:
code: read
jobs:
# BLOCKING (ersatztv#390): the CI toolchain image pin in docker-build.yml must name the image that
# ci-image.yml actually last published — i.e. the short sha of the last commit to touch the image's
+11
View File
@@ -45,6 +45,17 @@ concurrency:
group: ersatztv-renovate
cancel-in-progress: false
# Explicit token scope (ersatztv#748) so the owner-level Actions default can move to Restricted
# (server-management#714). This workflow never uses the injected GITEA_TOKEN for anything but the
# checkout — Renovate's own repo writes (branches, PRs) authenticate with RENOVATE_TOKEN, a dedicated bot PAT
# that the Restricted default does not touch; it does not even check out. Declaring
# `permissions:` is EXHAUSTIVE, not additive: a unit omitted here is not granted. Read-only is the
# convention for every workflow that does not write the repo — only `review-verdict.yml` opts into
# write, and it says why inline.
permissions:
code: read
jobs:
renovate:
name: Renovate
+19
View File
@@ -118,6 +118,25 @@ jobs:
set-verdict-status:
name: Set review-verdict status
runs-on: small # a few API calls; keep it off the build runners
# Explicit token scope (ersatztv#748), so the owner-level Actions default can be set to
# Restricted (server-management#714) without this job losing the ability to write the gate.
#
# DECLARING THIS IS EXHAUSTIVE — it is not additive. From the moment it merges, this job holds
# EXACTLY these units even while the owner default is still `permissive`. A missing unit does not
# degrade gracefully: the `curl -sf` dies under `set -euo pipefail` and `review-verdict/h10` is
# never posted, which blocks EVERY merge to `main` — including the PR that would repair it, and
# `block_admin_merge_override: true` (ersatztv#743) means there is no force-merge escape. Change
# this block only with the scratch-base-branch probe in `docs/ci-cd.md`; this workflow is never
# exercised by its own PR.
#
# Why `code: write` and not something narrower: Gitea has NO `statuses` scope (GitHub-only, and
# explicitly unsupported). `POST /repos/{o}/{r}/statuses/{sha}` is gated by
# `reqRepoWriter(unit.TypeCode)`, so status-write IS Code-write — see `ci.actions-credential-scoping`.
# `contents: write` would also work but additionally grants `releases: write`, which is not used.
permissions:
code: write # POST /statuses/{sha} (the gate) + the /commits/{sha}/status reads
issues: read # GET /issues/{n}/timeline — the retarget-count fence (#706)
pull-requests: read # scripts/pr-changed-files.sh -> GET /pulls/{n}/files (#698 exemption path)
steps:
# BASE, not head — see the header. `fetch-depth: 1` is enough: nothing here reads history,
# only the working tree's `scripts/`.