From 431584bf79b4f081fa5040120ef07d22f62aad58 Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <328836012+pithead-developer[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 01:38:54 -0600 Subject: [PATCH 1/6] Open pin-bump PRs with the developer App token The Tor and shipped-pin bump workflows run in the pin-bump environment and mint a token for the developer App with contents and pull-request write on this repository only. That token pushes the bump branch, opens its PR and closes superseded ones; GITHUB_TOKEN keeps read access only. Each run first checks that PIN_BUMP_APP_ID and PIN_BUMP_APP_KEY are set and fails with a message naming the missing one before it pushes anything. The superseded-PR helpers treat the App's PRs as their own, the PR bodies say tiers 1 to 3 run as the PR's own checks, and docs/dev/releasing.md describes the one-time setup. make test-tools checks that both bump jobs keep this shape. Fixes #4677 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pin-bump.yml | 30 ++++++++++++++++++++++++++--- .github/workflows/tor-bump.yml | 31 +++++++++++++++++++++++++----- Makefile | 1 + docs/dev/releasing.md | 17 ++++++++++++---- scripts/watch/pin-bump-selftest.sh | 3 +++ scripts/watch/pin-bump.sh | 4 ++-- scripts/watch/tor-bump.sh | 5 ++++- 7 files changed, 76 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pin-bump.yml b/.github/workflows/pin-bump.yml index 3fa2972ce8..0e1d91f312 100644 --- a/.github/workflows/pin-bump.yml +++ b/.github/workflows/pin-bump.yml @@ -25,25 +25,48 @@ jobs: fail-fast: false matrix: component: [monero, p2pool, xmrig-proxy, rigforge] + environment: pin-bump permissions: - contents: write - pull-requests: write + contents: read env: - GH_TOKEN: ${{ github.token }} COMPONENT: ${{ matrix.component }} steps: + - name: Check the pin-bump App settings + env: + APP_ID: ${{ vars.PIN_BUMP_APP_ID }} + APP_KEY_SET: ${{ secrets.PIN_BUMP_APP_KEY != '' }} + run: | + if [ -z "$APP_ID" ]; then + echo "::error::The pin-bump environment has no PIN_BUMP_APP_ID variable, so this run cannot open its pull request." + exit 1 + fi + if [ "$APP_KEY_SET" != true ]; then + echo "::error::The pin-bump environment has no PIN_BUMP_APP_KEY secret, so this run cannot open its pull request." + exit 1 + fi + - name: Mint the developer App token for this repository + id: app + uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc + with: + app-id: ${{ vars.PIN_BUMP_APP_ID }} + private-key: ${{ secrets.PIN_BUMP_APP_KEY }} + permission-contents: write + permission-pull-requests: write - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: ref: develop persist-credentials: false - name: Resolve the newest release and its hash id: detect + env: + GH_TOKEN: ${{ steps.app.outputs.token }} run: | result="$(bash scripts/watch/pin-bump.sh detect "$COMPONENT")" printf '%s\n' "$result" | tee -a "$GITHUB_OUTPUT" - name: Push the bump and open its PR if: steps.detect.outputs.stale == 'true' && inputs.dry_run != true env: + GH_TOKEN: ${{ steps.app.outputs.token }} CURRENT: ${{ steps.detect.outputs.current }} LATEST: ${{ steps.detect.outputs.latest }} PIN: ${{ steps.detect.outputs.pin }} @@ -84,6 +107,7 @@ jobs: - name: Close bump PRs this run supersedes if: inputs.dry_run != true env: + GH_TOKEN: ${{ steps.app.outputs.token }} STALE: ${{ steps.detect.outputs.stale }} BRANCH: ${{ steps.detect.outputs.branch }} run: | diff --git a/.github/workflows/tor-bump.yml b/.github/workflows/tor-bump.yml index 4514207277..f6aa7c45f1 100644 --- a/.github/workflows/tor-bump.yml +++ b/.github/workflows/tor-bump.yml @@ -13,10 +13,31 @@ jobs: name: Open a PR when Alpine carries a newer tor runs-on: ubuntu-latest timeout-minutes: 10 + environment: pin-bump permissions: - contents: write - pull-requests: write + contents: read steps: + - name: Check the pin-bump App settings + env: + APP_ID: ${{ vars.PIN_BUMP_APP_ID }} + APP_KEY_SET: ${{ secrets.PIN_BUMP_APP_KEY != '' }} + run: | + if [ -z "$APP_ID" ]; then + echo "::error::The pin-bump environment has no PIN_BUMP_APP_ID variable, so this run cannot open its pull request." + exit 1 + fi + if [ "$APP_KEY_SET" != true ]; then + echo "::error::The pin-bump environment has no PIN_BUMP_APP_KEY secret, so this run cannot open its pull request." + exit 1 + fi + - name: Mint the developer App token for this repository + id: app + uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc + with: + app-id: ${{ vars.PIN_BUMP_APP_ID }} + private-key: ${{ secrets.PIN_BUMP_APP_KEY }} + permission-contents: write + permission-pull-requests: write - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: ref: develop @@ -27,7 +48,7 @@ jobs: - name: Push the bump and open its PR if: steps.detect.outputs.stale == 'true' env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app.outputs.token }} CURRENT: ${{ steps.detect.outputs.current }} LATEST: ${{ steps.detect.outputs.latest }} BRANCH: ${{ steps.detect.outputs.branch }} @@ -80,13 +101,13 @@ jobs: ## Here is the proof - Pending: the \`tier4-kvm\` \`tor-heal\` phase must be green at this head before merge, as \`docs/dev/releasing.md\` requires for a Tor pin bump — it is the live proof of Tor's state-file behaviour. Tiers 1 to 3 run from the first push to this branch; a PR opened with the Actions token triggers no \`pull_request\` checks of its own. + Pending: the \`tier4-kvm\` \`tor-heal\` phase must be green at this head before merge, as \`docs/dev/releasing.md\` requires for a Tor pin bump — it is the live proof of Tor's state-file behaviour. Tiers 1 to 3 run as this PR's own checks: the developer App opens it. EOF gh pr create --base develop --head "$branch" --label dependencies \ --title "build/tor: bump the Tor pin to ${LATEST}" --body-file pr-body.md - name: Close bump PRs this run supersedes env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app.outputs.token }} STALE: ${{ steps.detect.outputs.stale }} LATEST: ${{ steps.detect.outputs.latest }} run: | diff --git a/Makefile b/Makefile index f6c48d6c35..adeac93b08 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,7 @@ test-tools: ## Build-tool contracts and CI workflow guards (no live services) python3 tests/stack/standalone/test_appliance_release_docs.py bash scripts/watch/tor-bump.sh --self-test bash scripts/watch/pin-bump.sh --self-test + for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Fq 'github.token' $$f && awk '/name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(c && p && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first and write only with the App token" >&2; exit 1; }; done bash tests/watch/test-find-open-issue.sh sed -n '/^ shell-block:$$/,/^ shell-fragment:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' sed -n '/^ shell-fragment:$$/,/^ shell:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' diff --git a/docs/dev/releasing.md b/docs/dev/releasing.md index 4744e54d5d..b379a55dbe 100644 --- a/docs/dev/releasing.md +++ b/docs/dev/releasing.md @@ -67,10 +67,19 @@ refuses to go on unless its sha256 equals the digest GitHub publishes for it (Mo `hashes.txt`, whose signature is not verified), then opens one `dependencies`-labelled PR per upstream version that moves the version and hash together, so a stale hash never lands. `RIGFORGE_REF` is resolved from the release tag to its commit. Monero only moves within its pinned minor: a release in -a new minor is reported and never proposed, because that move stays a human decision (#1129). The Actions token -opens these PRs, so they trigger no checks of their own: a maintainer pushes to the branch to start -tiers 1 to 3, and the PR body names the `tier4-e2e` or `tier4-kvm` proof it needs before merge. A newer -release supersedes the open PR for an older one of the same component, and a closed PR is taken as declined. +a new minor is reported and never proposed, because that move stays a human decision (#1129). The developer +App opens these PRs, so tiers 1 to 3 run as their own checks, and the PR body names the `tier4-e2e` or +`tier4-kvm` proof it needs before merge. A newer release supersedes the open PR for an older one of the +same component, and a closed PR is taken as declined. + +Both bump workflows, this one and `tor-bump.yml` below, push their branch and open their PR with a +token for the developer App, minted in each run by `actions/create-github-app-token` for this +repository only; the repository setting that lets the Actions token create pull requests stays off +(#4677). They need a one-time setup by the owner: an environment named `pin-bump`, limited to the +`develop` branch, with the variable `PIN_BUMP_APP_ID` (the App's ID) and the secret `PIN_BUMP_APP_KEY` +(a private key of the App made for this use alone, so it can be revoked without touching its other +keys). Until both are set, each run fails at its first step and names the missing setting, before +it pushes anything; a run on any other branch never receives the key. Advisories are the one thing the watch cannot see: `monerod`, `p2pool` and `xmrig-proxy` install sha256-verified static binaries with no package metadata, so the Trivy sweep reports no CVEs for diff --git a/scripts/watch/pin-bump-selftest.sh b/scripts/watch/pin-bump-selftest.sh index 744c2d70d4..be068bdd00 100755 --- a/scripts/watch/pin-bump-selftest.sh +++ b/scripts/watch/pin-bump-selftest.sh @@ -120,6 +120,9 @@ self_test() { "$(superseded p2pool bot/p2pool-v4.19.0 <"$t/prs.json")" $'1\tbot/p2pool-v4.19.0\tkeep\n2\tbot/p2pool-v4.18.9\tclose' check "superseded with no want closes every own head of the component" "$(superseded p2pool '' <"$t/prs.json" | grep -c close)" 2 check "superseded leaves another component alone" "$(superseded monero bot/monero-v0.18.5.2 <"$t/prs.json")" $'3\tbot/monero-v0.18.5.2\tkeep' + check "superseded treats the developer App's bump PRs as its own" \ + "$(printf '[{"number":8,"headRefName":"bot/p2pool-v4.19.0","author":{"login":"app/pithead-developer"}},{"number":9,"headRefName":"bot/p2pool-v4.18.9","author":{"login":"pithead-developer[bot]"}}]' | superseded p2pool bot/p2pool-v4.19.0)" \ + $'8\tbot/p2pool-v4.19.0\tkeep\n9\tbot/p2pool-v4.18.9\tclose' check "pr body has the three house sections" "$(pr_body p2pool v4.18.1 v4.19.0 | grep -c '^## ')" 3 check "pr body for p2pool requires the advisory check" "$(pr_body p2pool v4.18.1 v4.19.0 | grep -c 'security advisories for v4.19.0')" 1 check "pr body for monero requires the advisory check" "$(pr_body monero 0.18.4.5 0.18.4.6 | grep -c 'security advisories for 0.18.4.6')" 1 diff --git a/scripts/watch/pin-bump.sh b/scripts/watch/pin-bump.sh index cc82f16015..dcdcad6989 100755 --- a/scripts/watch/pin-bump.sh +++ b/scripts/watch/pin-bump.sh @@ -244,7 +244,7 @@ apply_pin() { superseded() { local c="$1" want="${2:-}" jq -r --arg want "$want" --arg prefix "bot/$c-" ' - def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions"; + def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) | IN("github-actions", "pithead-developer"); def ours: ((.headRefName // "") | startswith($prefix)); (map(select(trusted and ours and .headRefName == $want)) | .[0].headRefName // "") as $keep | map(select(trusted and ours))[] | @@ -281,7 +281,7 @@ Automated bump of the $c pin to ${latest} only, opened by \`.github/workflows/pi ## Here is the proof -Pending: ${proof}. A PR opened with the Actions token triggers no \`pull_request\` checks of its own, so tiers 1 to 3 run once a maintainer pushes to this branch.${advisory} +Pending: ${proof}. Tiers 1 to 3 run as this PR's own checks: the developer App opens it.${advisory} EOF } diff --git a/scripts/watch/tor-bump.sh b/scripts/watch/tor-bump.sh index 1fbcce7d74..88ecd695ec 100755 --- a/scripts/watch/tor-bump.sh +++ b/scripts/watch/tor-bump.sh @@ -58,7 +58,7 @@ apply_pin() { superseded() { local want="${1:-}" jq -r --arg want "$want" ' - def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions"; + def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) | IN("github-actions", "pithead-developer"); def ours: ((.headRefName // "") | startswith("bot/tor-")); (map(select(trusted and ours and .headRefName == $want)) | .[0].headRefName // "") as $keep | map(select(trusted and ours))[] | @@ -143,6 +143,9 @@ self_test() { "$(superseded bot/tor-0.4.9.18-r1 <"$t/prs.json" | grep -cE '^[4567]')" "0" check "superseded on an empty list prints nothing" \ "$(printf '[]' | superseded bot/tor-0.4.9.18-r1 | wc -l | tr -d ' ')" "0" + check "superseded treats the developer App's bump PRs as its own" \ + "$(printf '[{"number":8,"headRefName":"bot/tor-0.4.9.18-r1","author":{"login":"app/pithead-developer"}},{"number":9,"headRefName":"bot/tor-0.4.9.17-r0","author":{"login":"pithead-developer[bot]"}}]' | superseded bot/tor-0.4.9.18-r1)" \ + $'8\tbot/tor-0.4.9.18-r1\tkeep\n9\tbot/tor-0.4.9.17-r0\tclose' [ "$fail" = 0 ] && echo "tor-bump self-test OK" return "$fail" } From 974d6ae9cf7962d6b5ddd00cd6861b7dc8ab0274 Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <328836012+pithead-developer[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 02:01:02 -0600 Subject: [PATCH 2/6] Match only same-repo bump PRs and report a failed bump run The App token is minted with the client ID (PIN_BUMP_APP_CLIENT_ID), the current input of create-github-app-token. The PR lookups and the superseded helpers take only pull requests from this repository, and the helpers trust the developer App only in its app/ and [bot] logins. A run that fails after the token is minted comments on, or opens, an infra tracking issue named after the workflow. The test-tools check also refuses secrets.GITHUB_TOKEN and requires the pull-request permission and the failure report, and the self-tests cover fork PRs, a bare login and App PRs on other heads. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pin-bump.yml | 30 +++++++++++++++++++++++------- .github/workflows/tor-bump.yml | 30 +++++++++++++++++++++++------- Makefile | 2 +- docs/dev/releasing.md | 6 ++++-- scripts/watch/pin-bump-selftest.sh | 4 ++++ scripts/watch/pin-bump.sh | 4 ++-- scripts/watch/tor-bump.sh | 8 ++++++-- 7 files changed, 63 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pin-bump.yml b/.github/workflows/pin-bump.yml index 0e1d91f312..0a181b6455 100644 --- a/.github/workflows/pin-bump.yml +++ b/.github/workflows/pin-bump.yml @@ -33,11 +33,11 @@ jobs: steps: - name: Check the pin-bump App settings env: - APP_ID: ${{ vars.PIN_BUMP_APP_ID }} + APP_CLIENT_ID: ${{ vars.PIN_BUMP_APP_CLIENT_ID }} APP_KEY_SET: ${{ secrets.PIN_BUMP_APP_KEY != '' }} run: | - if [ -z "$APP_ID" ]; then - echo "::error::The pin-bump environment has no PIN_BUMP_APP_ID variable, so this run cannot open its pull request." + if [ -z "$APP_CLIENT_ID" ]; then + echo "::error::The pin-bump environment has no PIN_BUMP_APP_CLIENT_ID variable, so this run cannot open its pull request." exit 1 fi if [ "$APP_KEY_SET" != true ]; then @@ -48,10 +48,11 @@ jobs: id: app uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc with: - app-id: ${{ vars.PIN_BUMP_APP_ID }} + client-id: ${{ vars.PIN_BUMP_APP_CLIENT_ID }} private-key: ${{ secrets.PIN_BUMP_APP_KEY }} permission-contents: write permission-pull-requests: write + permission-issues: write - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: ref: develop @@ -73,8 +74,8 @@ jobs: BRANCH: ${{ steps.detect.outputs.branch }} run: | set -Eeuo pipefail - state="$(gh pr list --state all --head "$BRANCH" --json state \ - --jq 'map(.state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')" + state="$(gh pr list --state all --head "$BRANCH" --json state,isCrossRepository \ + --jq 'map(select(.isCrossRepository | not) | .state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')" if [ "$state" != none ]; then echo "PR for ${COMPONENT} ${LATEST} is ${state}; not opening another" exit 0 @@ -116,7 +117,7 @@ jobs: if [ "$STALE" = true ]; then want="$BRANCH" fi - rows="$(gh pr list --state open --limit 200 --json number,headRefName,author | + rows="$(gh pr list --state open --limit 200 --json number,headRefName,author,isCrossRepository | bash scripts/watch/pin-bump.sh superseded "$COMPONENT" "$want")" keep="$(printf '%s\n' "$rows" | awk -F'\t' '$3 == "keep" { print $2; exit }')" if [ -n "$keep" ]; then @@ -129,3 +130,18 @@ jobs: gh pr close "$number" --comment "$reason" fi done <<< "$rows" + - name: Report the failed run on its tracking issue + if: failure() && steps.app.outputs.token != '' + env: + GH_TOKEN: ${{ steps.app.outputs.token }} + TITLE: Shipped pin bump run failed for ${{ matrix.component }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -Eeuo pipefail + body="The ${COMPONENT} pin bump failed in [run ${GITHUB_RUN_ID}](${RUN_URL}); its log names the failed step. Close this issue once a run succeeds again." + n="$(bash scripts/watch/find-open-issue.sh "$TITLE")" + if [ -n "$n" ]; then + gh issue comment "$n" --body "$body" + else + gh issue create --title "$TITLE" --label infra --body "$body" + fi diff --git a/.github/workflows/tor-bump.yml b/.github/workflows/tor-bump.yml index f6aa7c45f1..1a588e3c9c 100644 --- a/.github/workflows/tor-bump.yml +++ b/.github/workflows/tor-bump.yml @@ -19,11 +19,11 @@ jobs: steps: - name: Check the pin-bump App settings env: - APP_ID: ${{ vars.PIN_BUMP_APP_ID }} + APP_CLIENT_ID: ${{ vars.PIN_BUMP_APP_CLIENT_ID }} APP_KEY_SET: ${{ secrets.PIN_BUMP_APP_KEY != '' }} run: | - if [ -z "$APP_ID" ]; then - echo "::error::The pin-bump environment has no PIN_BUMP_APP_ID variable, so this run cannot open its pull request." + if [ -z "$APP_CLIENT_ID" ]; then + echo "::error::The pin-bump environment has no PIN_BUMP_APP_CLIENT_ID variable, so this run cannot open its pull request." exit 1 fi if [ "$APP_KEY_SET" != true ]; then @@ -34,10 +34,11 @@ jobs: id: app uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc with: - app-id: ${{ vars.PIN_BUMP_APP_ID }} + client-id: ${{ vars.PIN_BUMP_APP_CLIENT_ID }} private-key: ${{ secrets.PIN_BUMP_APP_KEY }} permission-contents: write permission-pull-requests: write + permission-issues: write - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: ref: develop @@ -55,8 +56,8 @@ jobs: run: | set -Eeuo pipefail branch="bot/tor-${LATEST}" - state="$(gh pr list --state all --head "$branch" --json state \ - --jq 'map(.state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')" + state="$(gh pr list --state all --head "$branch" --json state,isCrossRepository \ + --jq 'map(select(.isCrossRepository | not) | .state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')" if [ "$state" = OPEN ]; then echo "PR for ${LATEST} is already open" exit 0 @@ -116,7 +117,7 @@ jobs: if [ "$STALE" = true ]; then want="bot/tor-${LATEST}" fi - rows="$(gh pr list --state open --limit 200 --json number,headRefName,author | + rows="$(gh pr list --state open --limit 200 --json number,headRefName,author,isCrossRepository | bash scripts/watch/tor-bump.sh superseded "$want")" keep="$(printf '%s\n' "$rows" | awk -F'\t' '$3 == "keep" { print $2; exit }')" if [ -n "$keep" ]; then @@ -131,3 +132,18 @@ jobs: gh pr close "$number" --comment "$reason" fi done <<< "$rows" + - name: Report the failed run on its tracking issue + if: failure() && steps.app.outputs.token != '' + env: + GH_TOKEN: ${{ steps.app.outputs.token }} + TITLE: Tor pin bump run failed + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -Eeuo pipefail + body="The Tor pin bump failed in [run ${GITHUB_RUN_ID}](${RUN_URL}); its log names the failed step. Close this issue once a run succeeds again." + n="$(bash scripts/watch/find-open-issue.sh "$TITLE")" + if [ -n "$n" ]; then + gh issue comment "$n" --body "$body" + else + gh issue create --title "$TITLE" --label infra --body "$body" + fi diff --git a/Makefile b/Makefile index adeac93b08..fc39420bc7 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ test-tools: ## Build-tool contracts and CI workflow guards (no live services) python3 tests/stack/standalone/test_appliance_release_docs.py bash scripts/watch/tor-bump.sh --self-test bash scripts/watch/pin-bump.sh --self-test - for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Fq 'github.token' $$f && awk '/name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(c && p && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first and write only with the App token" >&2; exit 1; }; done + for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Eq 'github\.token|GITHUB_TOKEN' $$f && grep -Fq 'permission-pull-requests: write' $$f && grep -Fq "if: failure() && steps.app.outputs.token != ''" $$f && awk '/name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(c && p && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first, write only with the App token and report a failed run" >&2; exit 1; }; done bash tests/watch/test-find-open-issue.sh sed -n '/^ shell-block:$$/,/^ shell-fragment:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' sed -n '/^ shell-fragment:$$/,/^ shell:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' diff --git a/docs/dev/releasing.md b/docs/dev/releasing.md index b379a55dbe..8fe638bf0d 100644 --- a/docs/dev/releasing.md +++ b/docs/dev/releasing.md @@ -76,10 +76,12 @@ Both bump workflows, this one and `tor-bump.yml` below, push their branch and op token for the developer App, minted in each run by `actions/create-github-app-token` for this repository only; the repository setting that lets the Actions token create pull requests stays off (#4677). They need a one-time setup by the owner: an environment named `pin-bump`, limited to the -`develop` branch, with the variable `PIN_BUMP_APP_ID` (the App's ID) and the secret `PIN_BUMP_APP_KEY` +`develop` branch, with the variable `PIN_BUMP_APP_CLIENT_ID` (the App's client ID) and the secret `PIN_BUMP_APP_KEY` (a private key of the App made for this use alone, so it can be revoked without touching its other keys). Until both are set, each run fails at its first step and names the missing setting, before -it pushes anything; a run on any other branch never receives the key. +it pushes anything; a run on any other branch never receives the key, so a dry run works only from +`develop`. A failed run comments on, or opens, an `infra` tracking issue named after the workflow +(per component for the shipped pins). Advisories are the one thing the watch cannot see: `monerod`, `p2pool` and `xmrig-proxy` install sha256-verified static binaries with no package metadata, so the Trivy sweep reports no CVEs for diff --git a/scripts/watch/pin-bump-selftest.sh b/scripts/watch/pin-bump-selftest.sh index be068bdd00..b24d388927 100755 --- a/scripts/watch/pin-bump-selftest.sh +++ b/scripts/watch/pin-bump-selftest.sh @@ -123,6 +123,10 @@ self_test() { check "superseded treats the developer App's bump PRs as its own" \ "$(printf '[{"number":8,"headRefName":"bot/p2pool-v4.19.0","author":{"login":"app/pithead-developer"}},{"number":9,"headRefName":"bot/p2pool-v4.18.9","author":{"login":"pithead-developer[bot]"}}]' | superseded p2pool bot/p2pool-v4.19.0)" \ $'8\tbot/p2pool-v4.19.0\tkeep\n9\tbot/p2pool-v4.18.9\tclose' + check "superseded skips PRs from forks and a bare login that only looks like the App" \ + "$(printf '[{"number":13,"headRefName":"bot/p2pool-v4.19.0","author":{"login":"app/pithead-developer"},"isCrossRepository":true},{"number":14,"headRefName":"bot/p2pool-v4.18.9","author":{"login":"pithead-developer"}}]' | superseded p2pool bot/p2pool-v4.19.0 | wc -l | tr -d ' ')" "0" + check "superseded never touches the developer App's other PRs" \ + "$(printf '[{"number":10,"headRefName":"fix/p2pool-pin","author":{"login":"app/pithead-developer"}},{"number":11,"headRefName":"agent/bot/p2pool-v4.19.0","author":{"login":"app/pithead-developer"}},{"number":12,"headRefName":"bot/monero-v0.18.5.4","author":{"login":"app/pithead-developer"}}]' | superseded p2pool '' | wc -l | tr -d ' ')" "0" check "pr body has the three house sections" "$(pr_body p2pool v4.18.1 v4.19.0 | grep -c '^## ')" 3 check "pr body for p2pool requires the advisory check" "$(pr_body p2pool v4.18.1 v4.19.0 | grep -c 'security advisories for v4.19.0')" 1 check "pr body for monero requires the advisory check" "$(pr_body monero 0.18.4.5 0.18.4.6 | grep -c 'security advisories for 0.18.4.6')" 1 diff --git a/scripts/watch/pin-bump.sh b/scripts/watch/pin-bump.sh index dcdcad6989..49f05cefa2 100755 --- a/scripts/watch/pin-bump.sh +++ b/scripts/watch/pin-bump.sh @@ -244,8 +244,8 @@ apply_pin() { superseded() { local c="$1" want="${2:-}" jq -r --arg want "$want" --arg prefix "bot/$c-" ' - def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) | IN("github-actions", "pithead-developer"); - def ours: ((.headRefName // "") | startswith($prefix)); + def trusted: (.author.login // "") as $l | ($l | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions" or $l == "app/pithead-developer" or $l == "pithead-developer[bot]"; + def ours: ((.headRefName // "") | startswith($prefix)) and (.isCrossRepository // false | not); (map(select(trusted and ours and .headRefName == $want)) | .[0].headRefName // "") as $keep | map(select(trusted and ours))[] | [ (.number | tostring), .headRefName, (if .headRefName == $keep then "keep" else "close" end) ] | @tsv' diff --git a/scripts/watch/tor-bump.sh b/scripts/watch/tor-bump.sh index 88ecd695ec..5edf1fd0ef 100755 --- a/scripts/watch/tor-bump.sh +++ b/scripts/watch/tor-bump.sh @@ -58,8 +58,8 @@ apply_pin() { superseded() { local want="${1:-}" jq -r --arg want "$want" ' - def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) | IN("github-actions", "pithead-developer"); - def ours: ((.headRefName // "") | startswith("bot/tor-")); + def trusted: (.author.login // "") as $l | ($l | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions" or $l == "app/pithead-developer" or $l == "pithead-developer[bot]"; + def ours: ((.headRefName // "") | startswith("bot/tor-")) and (.isCrossRepository // false | not); (map(select(trusted and ours and .headRefName == $want)) | .[0].headRefName // "") as $keep | map(select(trusted and ours))[] | [ (.number | tostring), .headRefName, (if .headRefName == $keep then "keep" else "close" end) ] | @tsv' @@ -146,6 +146,10 @@ self_test() { check "superseded treats the developer App's bump PRs as its own" \ "$(printf '[{"number":8,"headRefName":"bot/tor-0.4.9.18-r1","author":{"login":"app/pithead-developer"}},{"number":9,"headRefName":"bot/tor-0.4.9.17-r0","author":{"login":"pithead-developer[bot]"}}]' | superseded bot/tor-0.4.9.18-r1)" \ $'8\tbot/tor-0.4.9.18-r1\tkeep\n9\tbot/tor-0.4.9.17-r0\tclose' + check "superseded skips PRs from forks and a bare login that only looks like the App" \ + "$(printf '[{"number":13,"headRefName":"bot/tor-0.4.9.18-r1","author":{"login":"app/pithead-developer"},"isCrossRepository":true},{"number":14,"headRefName":"bot/tor-0.4.9.17-r0","author":{"login":"pithead-developer"}}]' | superseded bot/tor-0.4.9.18-r1 | wc -l | tr -d ' ')" "0" + check "superseded never touches the developer App's other PRs" \ + "$(printf '[{"number":10,"headRefName":"fix/tor-egress","author":{"login":"app/pithead-developer"}},{"number":11,"headRefName":"agent/bot/tor-0.4.9.18-r1","author":{"login":"app/pithead-developer"}},{"number":12,"headRefName":"bot/monero-v0.18.5.4","author":{"login":"app/pithead-developer"}}]' | superseded '' | wc -l | tr -d ' ')" "0" [ "$fail" = 0 ] && echo "tor-bump self-test OK" return "$fail" } From d97e404b61c353034bc67cfc1b4243198006ea94 Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <328836012+pithead-developer[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 02:14:19 -0600 Subject: [PATCH 3/6] Report every failed bump run, also before the App token exists Checkout is the first step of both bump jobs, and the failure report runs on any failure: it uses the App token when the run minted one and the Actions token otherwise, with the job's issues permission, so a missing setting or a revoked key also reaches the infra tracking issue. The state lookups read up to 200 pull requests before they drop the ones from forks. The test-tools check allows github.token only in that one fallback line and requires the issues permission and checkout before the settings check. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pin-bump.yml | 15 ++++++++------- .github/workflows/tor-bump.yml | 15 ++++++++------- Makefile | 2 +- docs/dev/releasing.md | 5 +++-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pin-bump.yml b/.github/workflows/pin-bump.yml index 0a181b6455..2d2de86b93 100644 --- a/.github/workflows/pin-bump.yml +++ b/.github/workflows/pin-bump.yml @@ -28,9 +28,14 @@ jobs: environment: pin-bump permissions: contents: read + issues: write env: COMPONENT: ${{ matrix.component }} steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + ref: develop + persist-credentials: false - name: Check the pin-bump App settings env: APP_CLIENT_ID: ${{ vars.PIN_BUMP_APP_CLIENT_ID }} @@ -53,10 +58,6 @@ jobs: permission-contents: write permission-pull-requests: write permission-issues: write - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - with: - ref: develop - persist-credentials: false - name: Resolve the newest release and its hash id: detect env: @@ -74,7 +75,7 @@ jobs: BRANCH: ${{ steps.detect.outputs.branch }} run: | set -Eeuo pipefail - state="$(gh pr list --state all --head "$BRANCH" --json state,isCrossRepository \ + state="$(gh pr list --state all --head "$BRANCH" --limit 200 --json state,isCrossRepository \ --jq 'map(select(.isCrossRepository | not) | .state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')" if [ "$state" != none ]; then echo "PR for ${COMPONENT} ${LATEST} is ${state}; not opening another" @@ -131,9 +132,9 @@ jobs: fi done <<< "$rows" - name: Report the failed run on its tracking issue - if: failure() && steps.app.outputs.token != '' + if: failure() env: - GH_TOKEN: ${{ steps.app.outputs.token }} + GH_TOKEN: ${{ steps.app.outputs.token || github.token }} TITLE: Shipped pin bump run failed for ${{ matrix.component }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | diff --git a/.github/workflows/tor-bump.yml b/.github/workflows/tor-bump.yml index 1a588e3c9c..3a974b8cef 100644 --- a/.github/workflows/tor-bump.yml +++ b/.github/workflows/tor-bump.yml @@ -16,7 +16,12 @@ jobs: environment: pin-bump permissions: contents: read + issues: write steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + ref: develop + persist-credentials: false - name: Check the pin-bump App settings env: APP_CLIENT_ID: ${{ vars.PIN_BUMP_APP_CLIENT_ID }} @@ -39,10 +44,6 @@ jobs: permission-contents: write permission-pull-requests: write permission-issues: write - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - with: - ref: develop - persist-credentials: false - name: Detect a newer tor in the Alpine repository id: detect run: bash scripts/watch/tor-bump.sh detect >>"$GITHUB_OUTPUT" @@ -56,7 +57,7 @@ jobs: run: | set -Eeuo pipefail branch="bot/tor-${LATEST}" - state="$(gh pr list --state all --head "$branch" --json state,isCrossRepository \ + state="$(gh pr list --state all --head "$branch" --limit 200 --json state,isCrossRepository \ --jq 'map(select(.isCrossRepository | not) | .state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')" if [ "$state" = OPEN ]; then echo "PR for ${LATEST} is already open" @@ -133,9 +134,9 @@ jobs: fi done <<< "$rows" - name: Report the failed run on its tracking issue - if: failure() && steps.app.outputs.token != '' + if: failure() env: - GH_TOKEN: ${{ steps.app.outputs.token }} + GH_TOKEN: ${{ steps.app.outputs.token || github.token }} TITLE: Tor pin bump run failed RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | diff --git a/Makefile b/Makefile index fc39420bc7..b4ac4d6100 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ test-tools: ## Build-tool contracts and CI workflow guards (no live services) python3 tests/stack/standalone/test_appliance_release_docs.py bash scripts/watch/tor-bump.sh --self-test bash scripts/watch/pin-bump.sh --self-test - for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Eq 'github\.token|GITHUB_TOKEN' $$f && grep -Fq 'permission-pull-requests: write' $$f && grep -Fq "if: failure() && steps.app.outputs.token != ''" $$f && awk '/name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(c && p && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first, write only with the App token and report a failed run" >&2; exit 1; }; done + for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Fvx ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f | grep -Eq 'github\.token|GITHUB_TOKEN' && grep -Fxq ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f && grep -Fq 'permission-pull-requests: write' $$f && grep -Fq 'permission-issues: write' $$f && grep -Fxq ' if: failure()' $$f && awk '/uses: actions\/checkout@/ { k = NR } /name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(k && c && p && k < c && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first, write only with the App token and report a failed run" >&2; exit 1; }; done bash tests/watch/test-find-open-issue.sh sed -n '/^ shell-block:$$/,/^ shell-fragment:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' sed -n '/^ shell-fragment:$$/,/^ shell:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' diff --git a/docs/dev/releasing.md b/docs/dev/releasing.md index 8fe638bf0d..39f2b75052 100644 --- a/docs/dev/releasing.md +++ b/docs/dev/releasing.md @@ -80,8 +80,9 @@ repository only; the repository setting that lets the Actions token create pull (a private key of the App made for this use alone, so it can be revoked without touching its other keys). Until both are set, each run fails at its first step and names the missing setting, before it pushes anything; a run on any other branch never receives the key, so a dry run works only from -`develop`. A failed run comments on, or opens, an `infra` tracking issue named after the workflow -(per component for the shipped pins). +`develop`. Every failed run comments on, or opens, an `infra` tracking issue named after the workflow +(per component for the shipped pins), a missing setting or a revoked key included: the report uses +the App token when the run minted one and the Actions token, which may open issues, when it did not. Advisories are the one thing the watch cannot see: `monerod`, `p2pool` and `xmrig-proxy` install sha256-verified static binaries with no package metadata, so the Trivy sweep reports no CVEs for From bd35be9420c0a18486c858736c46056e4bd5c22a Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <328836012+pithead-developer[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 02:28:44 -0600 Subject: [PATCH 4/6] Pin the job issues permission and the single token fallback The test-tools check now requires the job-level issues permission the failure report falls back on, and the fallback GH_TOKEN line exactly once. docs/dev/releasing.md says a missing setting fails the run at the settings check. Co-Authored-By: Claude Opus 5.5 --- Makefile | 2 +- docs/dev/releasing.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b4ac4d6100..983c98df87 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ test-tools: ## Build-tool contracts and CI workflow guards (no live services) python3 tests/stack/standalone/test_appliance_release_docs.py bash scripts/watch/tor-bump.sh --self-test bash scripts/watch/pin-bump.sh --self-test - for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Fvx ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f | grep -Eq 'github\.token|GITHUB_TOKEN' && grep -Fxq ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f && grep -Fq 'permission-pull-requests: write' $$f && grep -Fq 'permission-issues: write' $$f && grep -Fxq ' if: failure()' $$f && awk '/uses: actions\/checkout@/ { k = NR } /name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(k && c && p && k < c && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first, write only with the App token and report a failed run" >&2; exit 1; }; done + for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Fvx ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f | grep -Eq 'github\.token|GITHUB_TOKEN' && [ "$$(grep -Fxc ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f)" = 1 ] && grep -Eq '^ issues: write$$' $$f && grep -Fq 'permission-pull-requests: write' $$f && grep -Fq 'permission-issues: write' $$f && grep -Fxq ' if: failure()' $$f && awk '/uses: actions\/checkout@/ { k = NR } /name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(k && c && p && k < c && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first, write only with the App token and report a failed run" >&2; exit 1; }; done bash tests/watch/test-find-open-issue.sh sed -n '/^ shell-block:$$/,/^ shell-fragment:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' sed -n '/^ shell-fragment:$$/,/^ shell:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)' diff --git a/docs/dev/releasing.md b/docs/dev/releasing.md index 39f2b75052..5e64cad49d 100644 --- a/docs/dev/releasing.md +++ b/docs/dev/releasing.md @@ -78,7 +78,7 @@ repository only; the repository setting that lets the Actions token create pull (#4677). They need a one-time setup by the owner: an environment named `pin-bump`, limited to the `develop` branch, with the variable `PIN_BUMP_APP_CLIENT_ID` (the App's client ID) and the secret `PIN_BUMP_APP_KEY` (a private key of the App made for this use alone, so it can be revoked without touching its other -keys). Until both are set, each run fails at its first step and names the missing setting, before +keys). Until both are set, each run fails at the settings check and names the missing setting, before it pushes anything; a run on any other branch never receives the key, so a dry run works only from `develop`. Every failed run comments on, or opens, an `infra` tracking issue named after the workflow (per component for the shipped pins), a missing setting or a revoked key included: the report uses From c5ae3207dd9ce1c4f6c8e1e657797817052bb721 Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <4933481+pithead-developer[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 10:39:59 -0600 Subject: [PATCH 5/6] build/tor: move the apk pin to 0.4.9.18-r0, the version Alpine 3.24 now serves Co-Authored-By: Claude Sonnet 5.5 --- build/tor/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tor/Dockerfile b/build/tor/Dockerfile index 1901d30064..a6fc6488f6 100644 --- a/build/tor/Dockerfile +++ b/build/tor/Dockerfile @@ -2,7 +2,7 @@ # names the Alpine minor line (3.24) so Dependabot's patch-update policy has a real version to track. FROM alpine:3.24@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf -ARG TOR_VERSION=0.4.9.17-r0 +ARG TOR_VERSION=0.4.9.18-r0 RUN apk add --no-cache --upgrade libcrypto3 libssl3 musl musl-utils "tor=${TOR_VERSION}" netcat-openbsd \ && tor --version | grep -F "Tor version ${TOR_VERSION%-r*}." From 8a8d8bc12bd0f623dcc8f0c17b715850a7cbe006 Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <4933481+pithead-developer[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 10:49:01 -0600 Subject: [PATCH 6/6] build/tor: upgrade busybox past the base digest to clear the fixable HIGH finding Co-Authored-By: Claude Sonnet 5.5 --- build/tor/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tor/Dockerfile b/build/tor/Dockerfile index a6fc6488f6..367b8d0fba 100644 --- a/build/tor/Dockerfile +++ b/build/tor/Dockerfile @@ -3,7 +3,7 @@ FROM alpine:3.24@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf ARG TOR_VERSION=0.4.9.18-r0 -RUN apk add --no-cache --upgrade libcrypto3 libssl3 musl musl-utils "tor=${TOR_VERSION}" netcat-openbsd \ +RUN apk add --no-cache --upgrade libcrypto3 libssl3 musl musl-utils busybox "tor=${TOR_VERSION}" netcat-openbsd \ && tor --version | grep -F "Tor version ${TOR_VERSION%-r*}." COPY torrc.template /etc/tor/torrc.template