Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,22 @@ concurrency:
group: docker-publish-${{ github.ref }}
cancel-in-progress: true

# Read-only by default. Each job below asks for what it needs on top: build
# pushes to GHCR (packages: write), release creates the GitHub Release
# (contents: write).
permissions:
contents: read

# There is deliberately NO workflow-level `permissions:` block here.
#
# One was added in #231 for least privilege. It broke every run from a fork
# pull request: the run failed during workflow expansion, so it was created with
# ZERO jobs and produced no log and no annotation. Removing it restored them.
#
# The combination is what matters, not either half. The build job below asks for
# `packages: write` to push to GHCR, and a fork pull request can never be granted
# a write token. On its own that is harmless, because GitHub downgrades it and
# the job runs. Underneath a workflow-level cap, the same request was observed to
# make GitHub reject the run before any job existed. Evidence, the full A/B and
# the counterexample that narrows this are in the PR that removed it.
Comment on lines +39 to +48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two claims in this block will outlive the PR and neither holds as written. Removing it restored them is past tense about something not yet observed: main still carries the block, and no fork run has exercised this branch. And the packages-specific narrowing does not survive the counterexample it cites — audit.yml is contents: read, not read-all as the PR body says, and its only write-scoped job (Scorecard, security-events: write + id-token: write) is gated if: github.ref == 'refs/heads/main' and was skipped on the fork head. Set that aside and the evidence fits the broader cap + any job-level write scope shape, which is what whoever re-adds a cap next to a pull-requests: write job needs to know.

Technical details
# Overstated diagnosis in the replacement comments

## Affected sites
- `.github/workflows/docker-publish.yml:40-48` — "Removing it restored them" plus the "combination is what matters" paragraph naming `packages: write`
- `.github/workflows/ns8-module.yml:40-51` — the same two claims, mirrored
- `.github/workflows/audit.yml:23-24` — top-level block is `contents: read`, not `read-all`
- `.github/workflows/audit.yml:33-37` — Scorecard is the only job with a write scope and is `main`-gated; run `43449040419` on fork head `fe75122` shows SBOM ok, claims guard ok, Scorecard skipped

## Required outcome
- The comments separate what was observed (zero-job runs, no log, no annotation, coincident with the cap landing) from what is inferred (the mechanism), and do not assert a restore that has not happened.
- The generalisation is stated at the width the evidence supports: with the Audit counterexample removed, nothing distinguishes `packages` from any other write scope, so the shape to avoid is a workflow-level cap plus a job-level write on a workflow that runs on fork PRs.
- Keep the "do not re-add this as a tidy-up" warning — it is the durable value in this block.

## Suggested approach
- Observation-only wording, e.g. "Fork pull requests produced zero-job runs (`startup_failure`, no log, no annotation) once this cap was added; the mechanism is undocumented, so if fork runs still fail, the rule is wider than this."
- If the intended end state is worth recording, note it here: a PR-path workflow with no write scopes at all (publish split off), which is what #231's least-privilege intent actually needed.
- Drop `Removing it restored them` until a fork run with a non-empty job list exists, then cite it.

#
# Least privilege is not weakened by leaving this out: every job below declares
# its own permissions, and the repository default is already `read`. Do not
# re-add this as a tidy-up; that is exactly how the fork runs were lost.
env:
REGISTRY: ghcr.io
# Hardcoded lowercase — GHCR tags reject the repo's actual "Calnode/calnode"
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/ns8-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,24 @@ concurrency:
group: ns8-module-publish
cancel-in-progress: false

# Read-only by default. Only the build job writes, to push the module image
# to GHCR (packages: write), and it says so itself.
permissions:
contents: read

# There is deliberately NO workflow-level `permissions:` block here.
#
# One was added in #231 for least privilege. It broke every run from a fork
# pull request: the run failed during workflow expansion, so it was created with
# ZERO jobs and produced no log and no annotation. Removing it restored them.
# The symptom is worth knowing, because it does not look like a permissions
# problem: the `validate` job below only needs `contents: read`, and it never ran
# either, because nothing runs when the whole run is rejected.
#
# The combination is what matters, not either half. The build job asks for
# `packages: write` to push the module image to GHCR, and a fork pull request can
# never be granted a write token. On its own that is harmless, because GitHub
# downgrades it and the job runs. Underneath a workflow-level cap, the same
# request was observed to make GitHub reject the run before any job existed.
#
# Least privilege is not weakened by leaving this out: every job below declares
# its own permissions, and the repository default is already `read`. Do not
# re-add this as a tidy-up; that is exactly how the fork runs were lost.
jobs:
validate:
runs-on: ubuntu-latest
Expand Down
Loading