diff --git a/.gitea/workflows/ci-image.yml b/.gitea/workflows/ci-image.yml index 6c3be2e09..d396f6291 100644 --- a/.gitea/workflows/ci-image.yml +++ b/.gitea/workflows/ci-image.yml @@ -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 diff --git a/.gitea/workflows/dependency-scan.yml b/.gitea/workflows/dependency-scan.yml index a971293e5..d31f1d3d3 100644 --- a/.gitea/workflows/dependency-scan.yml +++ b/.gitea/workflows/dependency-scan.yml @@ -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 diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index b90794028..f178165db 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -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) diff --git a/.gitea/workflows/pr-checks.yml b/.gitea/workflows/pr-checks.yml index 315cdc6c2..8db5a3ee7 100644 --- a/.gitea/workflows/pr-checks.yml +++ b/.gitea/workflows/pr-checks.yml @@ -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 diff --git a/.gitea/workflows/renovate.yml b/.gitea/workflows/renovate.yml index 114eb262e..526bacc72 100644 --- a/.gitea/workflows/renovate.yml +++ b/.gitea/workflows/renovate.yml @@ -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 diff --git a/.gitea/workflows/review-verdict.yml b/.gitea/workflows/review-verdict.yml index eccb2fb46..4a4a81a9b 100644 --- a/.gitea/workflows/review-verdict.yml +++ b/.gitea/workflows/review-verdict.yml @@ -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/`.