From c743efd8cd01d2c8bf8a26edfb33af0ae90b9d9c Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Mon, 16 Nov 2026 08:08:40 +0000 Subject: [PATCH 1/4] fix(ci): accept AsciiDoc guides and grant Scorecard job read access --- .github/workflows/estate-rules.yml | 4 ++ .github/workflows/rsr-compliance-canary.yml | 6 ++- .github/workflows/scorecard.yml | 1 + docs/status/ROADMAP.adoc | 14 ++++++ secret-types_chora.deed | 9 ++-- tests/workflows/rhodibot_canary_test.sh | 46 +++++++++++++++++++ tests/workflows/scorecard_permissions_test.sh | 34 ++++++++++++++ 7 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 tests/workflows/rhodibot_canary_test.sh create mode 100644 tests/workflows/scorecard_permissions_test.sh diff --git a/.github/workflows/estate-rules.yml b/.github/workflows/estate-rules.yml index 82843c6..58ede93 100644 --- a/.github/workflows/estate-rules.yml +++ b/.github/workflows/estate-rules.yml @@ -121,6 +121,10 @@ jobs: https://raw.githubusercontent.com/metadatastician/standards/e064539116c2dcfdf282a4749dbd58c69961c7e6/scripts/kyaml-format.sh \ --output "$RUNNER_TEMP/kyaml-format.sh" echo "5fddd58fc8cbd2b68766ef5b4b5ba39f299da3f27252ae6cdcff0a641bbaef18 $RUNNER_TEMP/kyaml-format.sh" | sha256sum --check --strict + - name: Rhodibot guide formats and missing or duplicate controls + run: bash tests/workflows/rhodibot_canary_test.sh + - name: Scorecard calling-job permission contract controls + run: bash tests/workflows/scorecard_permissions_test.sh - name: Non-interactive mint resolves every prompt from the environment run: bash tests/workflows/non_interactive_mint_test.sh # repo-init recorded the CHILD's own HEAD as the template commit whenever diff --git a/.github/workflows/rsr-compliance-canary.yml b/.github/workflows/rsr-compliance-canary.yml index e03cd32..5995bce 100644 --- a/.github/workflows/rsr-compliance-canary.yml +++ b/.github/workflows/rsr-compliance-canary.yml @@ -70,7 +70,11 @@ jobs: done # would-CREATE: missing required files [ -f "SECURITY.md" ] || [ -f ".github/SECURITY.md" ] || warn "no SECURITY.md (would be created)" - [ -f "CONTRIBUTING.md" ] || [ -f ".github/CONTRIBUTING.md" ] || warn "no CONTRIBUTING.md (would be created)" + # The estate writes its prose in AsciiDoc: CONTRIBUTING.adoc is the guide, + # not a gap (the .md was dropped in 1486d06 and the canary tripped on + # a rule that had diverged from the norm). Either form, root or .github/. + [ -f "CONTRIBUTING.md" ] || [ -f ".github/CONTRIBUTING.md" ] || [ -f "CONTRIBUTING.adoc" ] || [ -f ".github/CONTRIBUTING.adoc" ] \ + || warn "no CONTRIBUTING.adoc or CONTRIBUTING.md (would be created)" # --- unfixable compliance gaps (also drift) --- ls *_chora.deed >/dev/null 2>&1 || warn "missing repo deed (*_chora.deed at the root)" diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index b9c565e..9c45f3a 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -21,6 +21,7 @@ jobs: # without security-events: write here the scorecard SARIF upload fails with # startup_failure (hypatia WF018). id-token: write enables OIDC publish. permissions: + actions: read contents: read security-events: write id-token: write diff --git a/docs/status/ROADMAP.adoc b/docs/status/ROADMAP.adoc index 3ca011c..bc1f01b 100644 --- a/docs/status/ROADMAP.adoc +++ b/docs/status/ROADMAP.adoc @@ -6,6 +6,20 @@ Initial development phase. +=== Bounded CI maintenance, 2026-11-16 + +The RSR canary now accepts CONTRIBUTING.adoc as well as CONTRIBUTING.md, +at the root or in .github/, using the rsr-template-repo fix at e67ee001. +The existing duplicate-guide detection remains in place. Scorecard now grants +actions: read on its calling job, as its pinned reusable workflow requires; +the reusable path and commit, including native-lock reconciliation, are unchanged. +Both regression controls run in the existing Estate Rules job after its verified +yq installation. Local checks are recorded separately from hosted execution. + +* Must: Acceptance: repaired jobs must start and pass on GitHub before CI recovery is claimed. +* Intend: resolve the separate Pages action-policy migration in + https://github.com/hyperpolymath/secret-types/issues/49[issue #49]. + == Milestones === v0.1.0 - Foundation diff --git a/secret-types_chora.deed b/secret-types_chora.deed index 4dd0c14..207a61c 100644 --- a/secret-types_chora.deed +++ b/secret-types_chora.deed @@ -610,7 +610,7 @@ (coverage (metadata :version "1.0.0" - :last-updated "2026-11-04") + :last-updated "2026-11-16") ; ============================================================================ ; COVERAGE STATE ; ============================================================================ @@ -628,7 +628,7 @@ (debt (metadata :version "1.0.0" - :last-updated "2026-11-04")) + :last-updated "2026-11-16")) ; rra — directives for Robot Repo Automaton (RRA) enforcing the Platonic Ideal root. (rra :target "robot-repo-automaton" @@ -1097,7 +1097,7 @@ (variant :project "secret-types" :schema-version "0.1.0" - :last-updated "2026-11-04" + :last-updated "2026-11-16" :parent "hyperpolymath/rsr-template-repo" ; template tip at mint :parent-pin "c48107311e652093efdc71deac3867f3f92c3a77" @@ -1165,6 +1165,8 @@ "tests/workflows/chain_tree_of_test.sh" "tests/workflows/replay_mint_env_test.sh" "tests/workflows/repo_map_newline_test.sh" + "tests/workflows/rhodibot_canary_test.sh" + "tests/workflows/scorecard_permissions_test.sh" "tests/workflows/secret_scanner_contract_test.sh" "verification/legs/README.adoc" "verification/legs/lean/.gitignore" @@ -1205,6 +1207,7 @@ ".github/workflows/proven-tests.yml" ".github/workflows/push-email-notify.yml" ".github/workflows/release.yml" + ".github/workflows/rsr-compliance-canary.yml" ".github/workflows/rust-ci.yml" ".github/workflows/scorecard.yml" ".github/workflows/secret-scanner.yml" diff --git a/tests/workflows/rhodibot_canary_test.sh b/tests/workflows/rhodibot_canary_test.sh new file mode 100644 index 0000000..9bd5722 --- /dev/null +++ b/tests/workflows/rhodibot_canary_test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# The Rhodibot canary fails the run when it would create or delete a file. Its +# would-create rule asked for CONTRIBUTING.md only, so a repository whose guide +# is CONTRIBUTING.adoc (the estate writes prose in AsciiDoc) tripped it every +# week. This runs the canary's own script, taken from the workflow, on +# fixtures: an .adoc guide is enough, either form at the root or in .github/; +# no guide at all, and both forms at once, still trip it. +set -euo pipefail +yq --version 2>&1 | grep -q mikefarah || { echo "FAIL: this test needs Mike Farah yq (Go, 4.53.3+); the yq on PATH is a different tool" >&2; exit 1; } +repo=$(git rev-parse --show-toplevel) +work=$(mktemp -d); trap 'rm -rf "$work"' EXIT +fail() { echo "FAIL: $*" >&2; exit 1; } +yq '.jobs.canary.steps[] | select(.name == "Rhodibot — detect drift (no mutations)") | .run' \ + "$repo/.github/workflows/rsr-compliance-canary.yml" > "$work/canary.sh" +grep -q 'CONTRIBUTING' "$work/canary.sh" || fail 'fixture: the canary step was not extracted' + +# fixture NAME FILES… — a repository that is clean but for its guide. +fixture() { + local d="$work/$1"; shift + mkdir -p "$d/.github" + : > "$d/x_chora.deed"; : > "$d/LICENSE"; : > "$d/README.adoc"; : > "$d/SECURITY.md" + local f; for f in "$@"; do : > "$d/$f"; done + echo "$d" +} +# run DIR — the canary's exit status; its output in $work/out. +run() { (cd "$1" && GITHUB_STEP_SUMMARY=/dev/null bash "$work/canary.sh") > "$work/out" 2>&1; } + +for guide in CONTRIBUTING.adoc .github/CONTRIBUTING.adoc CONTRIBUTING.md .github/CONTRIBUTING.md; do + d=$(fixture "ok-${guide//\//_}" "$guide") + run "$d" || { cat "$work/out" >&2; fail "the canary tripped on a repository whose guide is $guide"; } +done +echo 'PASS: a CONTRIBUTING guide in AsciiDoc or Markdown, at the root or in .github/, is not drift' + +d=$(fixture none) +if run "$d"; then fail 'the canary passed a repository with no CONTRIBUTING guide'; fi +grep -q 'no CONTRIBUTING.adoc or CONTRIBUTING.md (would be created)' "$work/out" || { cat "$work/out" >&2; fail 'the missing guide was not named'; } +d=$(fixture both CONTRIBUTING.adoc CONTRIBUTING.md) +if run "$d"; then fail 'the canary passed both CONTRIBUTING.md and CONTRIBUTING.adoc'; fi +grep -q 'duplicate CONTRIBUTING.md + CONTRIBUTING.adoc' "$work/out" || { cat "$work/out" >&2; fail 'the duplicate guide was not named'; } +echo 'PASS: (-) no guide, and both forms at once, still trip the canary' + +# This repository itself is clean. +(cd "$repo" && GITHUB_STEP_SUMMARY=/dev/null bash "$work/canary.sh") > "$work/out" 2>&1 \ + || { cat "$work/out" >&2; fail 'the canary trips on this repository'; } +echo 'PASS: the canary is clean on this repository' diff --git a/tests/workflows/scorecard_permissions_test.sh b/tests/workflows/scorecard_permissions_test.sh new file mode 100644 index 0000000..f79feb5 --- /dev/null +++ b/tests/workflows/scorecard_permissions_test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# The pinned Scorecard reusable requires these grants on the calling job. +# A job permissions map replaces the workflow map; top-level actions: read +# alone cannot satisfy the callee. Exercise the YAML map and negative controls. +set -euo pipefail +yq --version 2>&1 | grep -q mikefarah || { echo 'FAIL: Mike Farah yq required' >&2; exit 2; } +repo=$(git rev-parse --show-toplevel) +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT +wf="$repo/.github/workflows/scorecard.yml" +fail() { echo "FAIL: $*" >&2; exit 1; } +check() { + yq -e ' + .jobs.scorecard.uses == "metadatastician/standards/.github/workflows/scorecard-reusable.yml@46ee18323305d5b36e2eef936e47dd54c39ea736" and + (.jobs.scorecard.permissions | length) == 4 and + .jobs.scorecard.permissions.actions == "read" and + .jobs.scorecard.permissions.contents == "read" and + .jobs.scorecard.permissions."security-events" == "write" and + .jobs.scorecard.permissions."id-token" == "write" + ' "$1" >/dev/null 2>&1 +} +check "$wf" || fail 'calling job does not satisfy its pinned reusable contract' +echo 'PASS: Scorecard keeps the pinned reconciliation workflow and exact job grants' + +yq 'del(.jobs.scorecard.permissions.actions)' "$wf" > "$work/top-level-only.yml" +if check "$work/top-level-only.yml"; then fail 'top-level actions grant hid the missing job grant'; fi +yq '.jobs.scorecard.permissions.actions = "write"' "$wf" > "$work/overgrant.yml" +if check "$work/overgrant.yml"; then fail 'unneeded actions: write was accepted'; fi +yq '.jobs.scorecard.permissions."security-events" = "read"' "$wf" > "$work/no-upload.yml" +if check "$work/no-upload.yml"; then fail 'missing SARIF upload permission was accepted'; fi +yq '.jobs.scorecard.uses = "hyperpolymath/rsr-template-repo/.github/workflows/scorecard.yml@e67ee0013777509a198977b840c0f0fabfa8ce75"' "$wf" > "$work/changed-reusable.yml" +if check "$work/changed-reusable.yml"; then fail 'replacement reusable escaped the reconciliation contract'; fi +echo 'PASS: missing or excessive grants and a replacement reusable fail the contract' From b2edb23d84f9f61929e803e1b4a3e228967810b4 Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Mon, 16 Nov 2026 08:39:07 +0000 Subject: [PATCH 2/4] fix(ci): adopt canonical Hypatia oracle runtime and compiler fix --- .github/workflows/dogfood-gate.yml | 15 +++++++++++---- docs/status/ROADMAP.adoc | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dogfood-gate.yml b/.github/workflows/dogfood-gate.yml index a4bf9b5..b3b02dd 100644 --- a/.github/workflows/dogfood-gate.yml +++ b/.github/workflows/dogfood-gate.yml @@ -625,14 +625,21 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: hyperpolymath/hypatia - ref: be98f74ce93df200752f3798efa1305bfa3e0e10 + # Pinned to a Hypatia commit that contains hypatia#1062 (the PinSites miscompile + # fix, merged as 37b8d01). The earlier pin be98f74 lacks it. + ref: 51539abf3d2472b955da9b051a68c5971f6cfa22 path: _hypatia persist-credentials: false - - name: Setup Elixir 1.19.4 / OTP 28.3 for Hypatia oracle + # OTP 28.x (28.1 to 28.5.0.8) crashes this step with SIGSEGV in + # sweep_off_heap, called from the JIT's bs_init_bits, on trees whose + # workflow content trips it (rsr-template-repo#333). OTP 27.3 scored all + # of them cleanly. Do not move to 28.x until a pinned 28.x build scores + # the #333 trees (af8665c, a55669e, 6ad5378) with no crash. + - name: Setup Elixir 1.19.4 / OTP 27.3.4.19 for Hypatia oracle uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1 with: elixir-version: '1.19.4' - otp-version: '28.3' + otp-version: '27.3.4.19' - name: Cache Hypatia Mix deps and build uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -641,7 +648,7 @@ jobs: _hypatia/_build ~/.hex ~/.mix - key: hypatia-oracle-${{ runner.os }}-otp28-elx1194-be98f74ce93df200752f3798efa1305bfa3e0e10 + key: hypatia-oracle-${{ runner.os }}-otp27.3.4.19-elx1194-51539abf3d2472b955da9b051a68c5971f6cfa22 - name: Compile the oracle working-directory: _hypatia run: mix local.hex --force && mix local.rebar --force && mix deps.get && mix compile diff --git a/docs/status/ROADMAP.adoc b/docs/status/ROADMAP.adoc index bc1f01b..d57e94c 100644 --- a/docs/status/ROADMAP.adoc +++ b/docs/status/ROADMAP.adoc @@ -20,6 +20,21 @@ yq installation. Local checks are recorded separately from hosted execution. * Intend: resolve the separate Pages action-policy migration in https://github.com/hyperpolymath/secret-types/issues/49[issue #49]. +The PR's RSR oracle subsequently segfaulted twice under OTP 28.3 while +the unchanged main tree passed a current rerun. The owning template documents +this content-dependent VM crash in +https://github.com/hyperpolymath/rsr-template-repo/pull/335[PR #335]: changing +workflow content can trigger it without changing the scorer. This repair adopts +the template's OTP 27.3.4.19 runtime and fixed Hypatia pin 51539abf, following +https://github.com/hyperpolymath/rsr-template-repo/pull/369[PR #369]. The pin +contains https://github.com/hyperpolymath/hypatia/pull/1062[the PinSites compiler +guard]; the runtime and guard are both retained because the template later +observed crashes with OTP 27.3 and the old Hypatia pin. The distinct cache key +includes both the runtime and source pin, preventing reuse of the old build. +The oracle command and gating behavior are preserved. Resolution requires a +passing hosted oracle run on the exact new head; local structural checks alone +do not establish that the crash is resolved. + == Milestones === v0.1.0 - Foundation From 83363da45e4bfcad136dc73b56c7e8f3f1f1cbef Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:18:19 +0000 Subject: [PATCH 3/4] Enforce contribution uniqueness and coherent Hypatia checkout pins --- .github/workflows/dogfood-gate.yml | 4 +- .github/workflows/fork-governance.yml | 2 +- .github/workflows/hypatia-scan.yml | 2 +- .github/workflows/rsr-compliance-canary.yml | 9 +- .github/workflows/verdict-grid-publish.yml | 2 +- .hypatia-ignore | 5 - .../policies/hypatia-rule-order.json | 2 +- docs/HYPATIA-RULE-ORDER.adoc | 41 +++++- docs/status/ROADMAP.adoc | 16 ++- scripts/check-workflow-edges.sh | 117 +++++++++++++++++- tests/workflows/rhodibot_canary_test.sh | 21 +++- tests/workflows/verdict_grid_test.sh | 2 +- tests/workflows/workflow_edges_test.sh | 93 ++++++++++++++ 13 files changed, 288 insertions(+), 28 deletions(-) diff --git a/.github/workflows/dogfood-gate.yml b/.github/workflows/dogfood-gate.yml index b3b02dd..e9e9525 100644 --- a/.github/workflows/dogfood-gate.yml +++ b/.github/workflows/dogfood-gate.yml @@ -627,7 +627,7 @@ jobs: repository: hyperpolymath/hypatia # Pinned to a Hypatia commit that contains hypatia#1062 (the PinSites miscompile # fix, merged as 37b8d01). The earlier pin be98f74 lacks it. - ref: 51539abf3d2472b955da9b051a68c5971f6cfa22 + ref: 6693f9aed8e4383f78a3d01b600b32663bf7a45c path: _hypatia persist-credentials: false # OTP 28.x (28.1 to 28.5.0.8) crashes this step with SIGSEGV in @@ -648,7 +648,7 @@ jobs: _hypatia/_build ~/.hex ~/.mix - key: hypatia-oracle-${{ runner.os }}-otp27.3.4.19-elx1194-51539abf3d2472b955da9b051a68c5971f6cfa22 + key: hypatia-oracle-${{ runner.os }}-otp27.3.4.19-elx1194-6693f9aed8e4383f78a3d01b600b32663bf7a45c - name: Compile the oracle working-directory: _hypatia run: mix local.hex --force && mix local.rebar --force && mix deps.get && mix compile diff --git a/.github/workflows/fork-governance.yml b/.github/workflows/fork-governance.yml index ea2ec57..bdaefbd 100644 --- a/.github/workflows/fork-governance.yml +++ b/.github/workflows/fork-governance.yml @@ -438,7 +438,7 @@ jobs: --hypatia "$ev/hypatia-scan-findings/hypatia-findings.relativized.json" --panic "$ev/static-analysis-findings/panic-attack-findings.json" --pons "$ev/static-analysis-findings/pons-findings.json" - --hypatia-ref be98f74ce93df200752f3798efa1305bfa3e0e10 + --hypatia-ref 6693f9aed8e4383f78a3d01b600b32663bf7a45c --panic-ref b5530834a839734d1d181bfe6edb0d43d4233cf4 --pons-ref 51b8920f541782ceb9465ea3f0d33c96104fc1fb ) diff --git a/.github/workflows/hypatia-scan.yml b/.github/workflows/hypatia-scan.yml index 0dd9b95..44d7dbf 100644 --- a/.github/workflows/hypatia-scan.yml +++ b/.github/workflows/hypatia-scan.yml @@ -50,7 +50,7 @@ jobs: security-events: write vulnerability-alerts: read # Dependabot alerts, for Hypatia's DA rules env: - HYPATIA_SHA: 'be98f74ce93df200752f3798efa1305bfa3e0e10' + HYPATIA_SHA: '6693f9aed8e4383f78a3d01b600b32663bf7a45c' steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/rsr-compliance-canary.yml b/.github/workflows/rsr-compliance-canary.yml index 5995bce..a3c22b7 100644 --- a/.github/workflows/rsr-compliance-canary.yml +++ b/.github/workflows/rsr-compliance-canary.yml @@ -58,7 +58,12 @@ jobs: a2ml_left=$(find . -path ./.git -prune -o -type f -name '*.a2ml' -print | head -5) [ -z "$a2ml_left" ] || warn "retired .a2ml files present (move their facts into the repo deed): $(echo $a2ml_left)" # would-DELETE: duplicate community files - [ -f "CONTRIBUTING.md" ] && [ -f "CONTRIBUTING.adoc" ] && warn "duplicate CONTRIBUTING.md + CONTRIBUTING.adoc (one would be removed)" + contributing_guides=() + for guide in CONTRIBUTING.md CONTRIBUTING.adoc .github/CONTRIBUTING.md .github/CONTRIBUTING.adoc; do + [ ! -f "$guide" ] || contributing_guides+=("$guide") + done + [ "${#contributing_guides[@]}" -le 1 ] \ + || warn "duplicate CONTRIBUTING guides: ${contributing_guides[*]} (keep exactly one)" if [ -f "README.md" ] && [ -f "README.adoc" ] && [ "$(wc -l < README.md)" -lt 5 ]; then warn "stub README.md alongside README.adoc (would be removed)" fi @@ -73,7 +78,7 @@ jobs: # The estate writes its prose in AsciiDoc: CONTRIBUTING.adoc is the guide, # not a gap (the .md was dropped in 1486d06 and the canary tripped on # a rule that had diverged from the norm). Either form, root or .github/. - [ -f "CONTRIBUTING.md" ] || [ -f ".github/CONTRIBUTING.md" ] || [ -f "CONTRIBUTING.adoc" ] || [ -f ".github/CONTRIBUTING.adoc" ] \ + [ "${#contributing_guides[@]}" -gt 0 ] \ || warn "no CONTRIBUTING.adoc or CONTRIBUTING.md (would be created)" # --- unfixable compliance gaps (also drift) --- diff --git a/.github/workflows/verdict-grid-publish.yml b/.github/workflows/verdict-grid-publish.yml index 7a67d17..d39ff8a 100644 --- a/.github/workflows/verdict-grid-publish.yml +++ b/.github/workflows/verdict-grid-publish.yml @@ -135,7 +135,7 @@ jobs: --hypatia "$ev/hypatia-scan-findings/hypatia-findings.relativized.json" \ --panic "$ev/static-analysis-findings/panic-attack-findings.json" \ --pons "$ev/static-analysis-findings/pons-findings.json" \ - --hypatia-ref be98f74ce93df200752f3798efa1305bfa3e0e10 \ + --hypatia-ref 6693f9aed8e4383f78a3d01b600b32663bf7a45c \ --panic-ref b5530834a839734d1d181bfe6edb0d43d4233cf4 \ --pons-ref 51b8920f541782ceb9465ea3f0d33c96104fc1fb) [ ! -d "$ev/fleet-report-backs" ] || args+=(--report-backs "$ev/fleet-report-backs") diff --git a/.hypatia-ignore b/.hypatia-ignore index b4c79dc..1223056 100644 --- a/.hypatia-ignore +++ b/.hypatia-ignore @@ -37,11 +37,6 @@ research_extensions/RE005:.github/workflows/quality.yml research_extensions/RE005:.github/workflows/dot-wellknown-enforcement.yml research_extensions/RE005:.github/workflows/static-analysis-gate.yml -# RE008 assumes the actor-name comparison is used with pull_request_target. The -# Dependabot workflow uses the unprivileged pull_request event and also verifies -# github.event.pull_request.user.login, so that threat model does not apply. -research_extensions/RE008:.github/workflows/dependabot-automerge.yml - # wrong_sha_pin compares 40-hex action pins against Hypatia's static May-2026 # @sha_pins table (e.g. actions/checkout@v4 vs the current actions/checkout@v7.0.1 # and ossf/scorecard-action@v2.5.0). Authoritative pin verification is enforced by diff --git a/.machine_readable/policies/hypatia-rule-order.json b/.machine_readable/policies/hypatia-rule-order.json index 6304f1e..1ccb61e 100644 --- a/.machine_readable/policies/hypatia-rule-order.json +++ b/.machine_readable/policies/hypatia-rule-order.json @@ -1 +1 @@ -{"SPDX-License-Identifier":"MPL-2.0","clashes":[{"id":"C1","resolution":"single producer; scripts/check-workflow-edges.sh fails on a dead edge","summary":"one scanner, two workflows"},{"id":"C2","resolution":"one pin per tool per repository; the verdict job names the producer's commit","summary":"one tool, two pins"},{"id":"C3","resolution":"panicbot stays unenrolled; the grid's own row is the authority","summary":"panicbot versus the direct panic-attack row"},{"id":"C4","resolution":"every fragment must end on a path boundary","summary":"substring fragments suppress more than they name"},{"id":"C5","resolution":"subsumed entries are refused","summary":"a broad entry makes narrower ones dead"},{"id":"C6","resolution":"the named path must exist in the tree","summary":"an exemption outlives the file it names"},{"id":"C7","resolution":"stated, not worked around; un-suppression is an upstream change","summary":"a repository cannot narrow a built-in default"},{"id":"C8","resolution":"producers own their gates; a failed fleet is orange rows, not a block","summary":"the reporter must not re-gate"}],"concerns":[{"id":"hypatia-execution","owner":".github/workflows/hypatia-scan.yml","rationale":"Two workflows built and ran the same scanner at the same pin (clash C1)."},{"id":"hypatia-gate","owner":".github/workflows/hypatia-scan.yml","rationale":"The producer owns its gate; the verdict grid is not a gate (clash C8)."},{"id":"panic-attack-gate","owner":".github/workflows/static-analysis-gate.yml","rationale":"Blocks on critical exactly once, in the workflow that runs it."},{"id":"pons-asinorum","owner":".github/workflows/static-analysis-gate.yml","rationale":"Advisory by design: pons classifies evidence, it does not prove."},{"id":"verdict-grid-render","owner":".github/workflows/fork-governance.yml","rationale":"The reporter collects evidence and never scans (clash C8)."},{"id":"verdict-grid-comment","owner":".github/workflows/verdict-grid-publish.yml","rationale":"Only the trusted default-branch workflow_run publisher may write the single bot-owned verdict comment; PR rendering remains read-only."},{"id":"fleet-report-backs","owner":".github/workflows/fork-governance.yml","rationale":"The fleet job is the only producer of .gitbot-fleet evidence."},{"id":"exemption-policy","owner":".hypatia-ignore","rationale":"One file, checked by scripts/check-hypatia-ignore.sh."}],"grid":{"commit":"8e48b1caade08a552646adeab66558ac43b4360d","library":"scripts/lib/verdict-grid.jq","library_sha256":"5681fcefe09480d82b7fa13a6fcb0c389f16467fe7abbace66986cca83114544","renderer":"scripts/verdict-grid.sh","renderer_sha256":"3ee93552920dfc7c472e763a040cbaed8f38ed4b8af151f5d5076d3124211388","repository":"metadatastician/standards","specification":"docs/VERDICT-GRID-SPEC.adoc"},"layer_owners":["hypatia","this-repository","the-gate","the-grid"],"layers":[{"description":"Python, Go, Makefile and Gemfile are refused by a dedicated clause; no exemption reaches it.","id":"rule-total-ban","overrides":"nothing: every other layer is unreachable for this rule","owner":"hypatia","rank":1,"repository_can_change":false,"scope":"cicd_rules/banned_language_file"},{"description":"Applied to every rule before any module-specific table.","id":"universal-excludes","overrides":"every layer below it, for the paths it names","owner":"hypatia","rank":2,"repository_can_change":false,"scope":"vendored and generated paths: .git/, node_modules/, _build/, deps/, target/, dist/, .hypatia-baseline.json"},{"description":"Training corpora and fixtures are provenance, not signal.","id":"builtin-defaults","overrides":"every layer below it; a repository cannot narrow it (clash C7)","owner":"hypatia","rank":3,"repository_can_change":false,"scope":"@training_corpus_paths keyed per module, plus benches/ for code_safety only"},{"description":"Scoped, reasoned exemptions. Fragments are substring matches, so each must end on a path boundary.","id":"repository-ignore","overrides":"nothing above it; it may only widen layer 3","owner":"this-repository","rank":4,"repository_can_change":true,"scope":".hypatia-ignore"},{"description":"Line- or file-scoped. The narrowest layer, and the one to use when only one line is affected.","id":"inline-directive","overrides":"layers 3 and 4, for the line that carries it","owner":"this-repository","rank":5,"repository_can_change":true,"scope":"# hypatia: allow / -- "},{"description":"Applied at gate time only. The verdict grid ignores it, so standing debt stays visible.","id":"baseline","overrides":"the gate's decision, never a scanner's output","owner":"the-gate","rank":6,"repository_can_change":true,"scope":".hypatia-baseline.json"},{"description":"Presentation and grading. It never suppresses a finding.","id":"grid-normalisation","overrides":"nothing; it may not change what a scanner reported","owner":"the-grid","rank":7,"repository_can_change":false,"scope":"severity words, suppressed:true, the row's colour"}],"observed_modules":[{"layer":4,"module":"research_extensions","rationale":"RE001/RE005/RE008 are advisory recommendations for workflows that deliberately hold a credential or render an annotation non-fatally; each exemption is file-scoped."},{"layer":4,"module":"workflow_audit","rationale":"wrong_sha_pin compares against a static May-2026 table; authoritative pin verification is actions.lock plus check-lock-sync.sh, which runs on every pull request."}],"scanner":{"commit":"be98f74ce93df200752f3798efa1305bfa3e0e10","repository":"hyperpolymath/hypatia","sources":["lib/hypatia/scanner_suppression.ex","lib/rules/"]},"schema":"hypatia-rule-order/1"} +{"SPDX-License-Identifier":"MPL-2.0","clashes":[{"id":"C1","resolution":"single producer; scripts/check-workflow-edges.sh fails on a dead edge","summary":"one scanner, two workflows"},{"id":"C2","resolution":"one pin per tool per repository, including Hypatia checkouts; the verdict job names the producer's commit","summary":"one tool, two pins"},{"id":"C3","resolution":"panicbot stays unenrolled; the grid's own row is the authority","summary":"panicbot versus the direct panic-attack row"},{"id":"C4","resolution":"every fragment must end on a path boundary","summary":"substring fragments suppress more than they name"},{"id":"C5","resolution":"subsumed entries are refused","summary":"a broad entry makes narrower ones dead"},{"id":"C6","resolution":"the named path must exist in the tree","summary":"an exemption outlives the file it names"},{"id":"C7","resolution":"stated, not worked around; un-suppression is an upstream change","summary":"a repository cannot narrow a built-in default"},{"id":"C8","resolution":"producers own their gates; a failed fleet is orange rows, not a block","summary":"the reporter must not re-gate"}],"concerns":[{"id":"hypatia-execution","owner":".github/workflows/hypatia-scan.yml","rationale":"Two workflows built and ran the same scanner at the same pin (clash C1)."},{"id":"hypatia-gate","owner":".github/workflows/hypatia-scan.yml","rationale":"The producer owns its gate; the verdict grid is not a gate (clash C8)."},{"id":"panic-attack-gate","owner":".github/workflows/static-analysis-gate.yml","rationale":"Blocks on critical exactly once, in the workflow that runs it."},{"id":"pons-asinorum","owner":".github/workflows/static-analysis-gate.yml","rationale":"Advisory by design: pons classifies evidence, it does not prove."},{"id":"verdict-grid-render","owner":".github/workflows/fork-governance.yml","rationale":"The reporter collects evidence and never scans (clash C8)."},{"id":"verdict-grid-comment","owner":".github/workflows/verdict-grid-publish.yml","rationale":"Only the trusted default-branch workflow_run publisher may write the single bot-owned verdict comment; PR rendering remains read-only."},{"id":"fleet-report-backs","owner":".github/workflows/fork-governance.yml","rationale":"The fleet job is the only producer of .gitbot-fleet evidence."},{"id":"exemption-policy","owner":".hypatia-ignore","rationale":"One file, checked by scripts/check-hypatia-ignore.sh."}],"grid":{"commit":"8e48b1caade08a552646adeab66558ac43b4360d","library":"scripts/lib/verdict-grid.jq","library_sha256":"5681fcefe09480d82b7fa13a6fcb0c389f16467fe7abbace66986cca83114544","renderer":"scripts/verdict-grid.sh","renderer_sha256":"3ee93552920dfc7c472e763a040cbaed8f38ed4b8af151f5d5076d3124211388","repository":"metadatastician/standards","specification":"docs/VERDICT-GRID-SPEC.adoc"},"layer_owners":["hypatia","this-repository","the-gate","the-grid"],"layers":[{"description":"Python, Go, Makefile and Gemfile are refused by a dedicated clause; no exemption reaches it.","id":"rule-total-ban","overrides":"nothing: every other layer is unreachable for this rule","owner":"hypatia","rank":1,"repository_can_change":false,"scope":"cicd_rules/banned_language_file"},{"description":"Applied to every rule before any module-specific table.","id":"universal-excludes","overrides":"every layer below it, for the paths it names","owner":"hypatia","rank":2,"repository_can_change":false,"scope":"vendored and generated paths: .git/, node_modules/, _build/, deps/, target/, dist/, .hypatia-exemptions.md, .hypatia-baseline.json"},{"description":"Training corpora and fixtures are provenance, not signal.","id":"builtin-defaults","overrides":"every layer below it; a repository cannot narrow it (clash C7)","owner":"hypatia","rank":3,"repository_can_change":false,"scope":"@training_corpus_paths keyed per module (security_errors, code_safety, migration_rules, structural_drift, content_patterns, dogfooding), plus benches/ for code_safety only, and for security_errors also .github/workflows/integration.yml and, for secret_detected only, harvested-registry/"},{"description":"Scoped, reasoned exemptions. Fragments are substring matches, so each must end on a path boundary.","id":"repository-ignore","overrides":"nothing above it; it may only widen layer 3","owner":"this-repository","rank":4,"repository_can_change":true,"scope":".hypatia-ignore"},{"description":"Line- or file-scoped. The narrowest layer, and the one to use when only one line is affected.","id":"inline-directive","overrides":"layers 3 and 4, for the line that carries it","owner":"this-repository","rank":5,"repository_can_change":true,"scope":"# hypatia: allow / -- "},{"description":"Applied at gate time only. The verdict grid ignores it, so standing debt stays visible.","id":"baseline","overrides":"the gate's decision, never a scanner's output","owner":"the-gate","rank":6,"repository_can_change":true,"scope":".hypatia-baseline.json"},{"description":"Presentation and grading. It never suppresses a finding.","id":"grid-normalisation","overrides":"nothing; it may not change what a scanner reported","owner":"the-grid","rank":7,"repository_can_change":false,"scope":"severity words, suppressed:true, the row's colour"}],"observed_modules":[{"layer":4,"module":"research_extensions","rationale":"RE001 and RE005 exemptions are file-scoped for deliberate credential-bearing or non-fatal reporting workflows. The former RE008 entry is removed: the Dependabot job pins the PR author by login and numeric id and performs no actor comparison."},{"layer":4,"module":"workflow_audit","rationale":"wrong_sha_pin compares against a static May-2026 table; authoritative pin verification is actions.lock plus check-lock-sync.sh, which runs on every pull request."}],"scanner":{"commit":"6693f9aed8e4383f78a3d01b600b32663bf7a45c","repository":"hyperpolymath/hypatia","sources":["lib/hypatia/scanner_suppression.ex","lib/rules/"]},"schema":"hypatia-rule-order/1"} diff --git a/docs/HYPATIA-RULE-ORDER.adoc b/docs/HYPATIA-RULE-ORDER.adoc index 8e57efe..6b492df 100644 --- a/docs/HYPATIA-RULE-ORDER.adoc +++ b/docs/HYPATIA-RULE-ORDER.adoc @@ -8,9 +8,9 @@ This is the repository's statement of *which* rule layer wins when two of them speak about the same file, *which* clashes exist today, and *what resolves each one*. It is local policy about tools that live elsewhere: Hypatia at -`hyperpolymath/hypatia@be98f74ce93df200752f3798efa1305bfa3e0e10` +`hyperpolymath/hypatia@6693f9aed8e4383f78a3d01b600b32663bf7a45c` (`lib/hypatia/scanner_suppression.ex`, `lib/rules/`), and the verdict grid at -`metadatastician/standards@e064539116c2dcfdf282a4749dbd58c69961c7e6` +`metadatastician/standards@8e48b1caade08a552646adeab66558ac43b4360d` (`docs/VERDICT-GRID-SPEC.adoc`). Nothing here changes what a scanner finds. It states the order the layers are @@ -47,11 +47,11 @@ ambiguous: |Hypatia (`scanner_suppression.ex`). Not this repository's to change. A repository cannot exempt it, and must not try. |2 -|**Universal excludes** — `.git/`, `node_modules/`, `_build/`, `deps/`, `target/`, `dist/`, `.hypatia-baseline.json`. +|**Universal excludes** — `.git/`, `node_modules/`, `_build/`, `deps/`, `target/`, `dist/`, `.hypatia-exemptions.md`, `.hypatia-baseline.json`. |Hypatia. Applied to every rule. |3 -|**Built-in default exemptions** — `@training_corpus_paths` (`lib/rules/`, `test/`, `tests/`, `scripts/fix-scripts/`, `.audittraining/`, `integration/fixtures/`) keyed per module, plus `benches/` for `code_safety` only. +|**Built-in default exemptions** — `@training_corpus_paths` (`lib/rules/`, `test/`, `tests/`, `scripts/fix-scripts/`, `.audittraining/`, `integration/fixtures/`) for `security_errors`, `code_safety`, `migration_rules`, `structural_drift`, `content_patterns` and `dogfooding`; plus `benches/` for `code_safety` only. `security_errors` also excludes `.github/workflows/integration.yml`, and `harvested-registry/` for `secret_detected` only. |Hypatia. A repository cannot narrow these (see clash C7). |4 @@ -114,7 +114,38 @@ not silently copied: a repository that adopts the reusable adopts its pins, and must then change `scripts/check-workflow-edges.sh`'s expectation deliberately. *Enforced by.* `scripts/check-workflow-edges.sh` (identical-ref check plus the -duplicate-pin scan). +duplicate-pin scan). This includes Hypatia's RSR oracle checkout, its SARIF +scanner and both verdict reporters. A checkout ref must be a literal full SHA +or an exact `env.NAME` expression with one literal declaration in workflow env +or the same job's env. Missing or duplicate checkout inputs, unresolved or +ambiguous bindings, and unsupported checkout mapping forms fail closed. Shell +block examples are not checkout inputs. No YAML runtime dependency is needed. + +=== Source audit for the common Hypatia pin (2026-11-16) + +The oracle, scanner and reporters use the same `6693f9aed8e4383f78a3d01b600b32663bf7a45c` +source. Comparing `scanner_suppression.ex` at the former `be98f74` pin and this +pin found two changes: `dogfooding` now receives the existing training-corpus +defaults, and `Token assignment` joins the form-ambiguous secret labels whose +commented documentation examples are masked. The total language ban, universal +exclude list, module-scoped defaults and OR combination of built-in and +repository exemptions are otherwise unchanged. The layer descriptions above +now name the existing `.hypatia-exemptions.md`, integration-workflow and +rule-specific harvested-registry exclusions explicitly. No repository +exemption was added or broadened. The grid pin and renderer/library digests +remain independent and unchanged. + +The retained research-extension exemptions are RE001/RE005, not an advisory +classification of the module. At this pin RE001 is high or warning depending on +job context, RE005 is warning, and RE008 is critical. The old RE008 exemption +for `dependabot-automerge.yml` is removed: the workflow contains no bot comparison +using `github.actor`. Its `pull_request` job checks both PR-author login and +immutable id `49699333`, executes a pinned metadata action and fixed scripts, +checks GitHub Advisory data and semver before requesting native auto-merge with +`--match-head-commit`, and has no checkout or artifact consumer. PR body and +metadata enter scripts through environment variables. The job requests contents +and pull-request write access; this audit does not call it read-only. The +obsolete exemption would otherwise hide a future critical actor-gate regression. === C3 — panicbot versus the direct panic-attack row diff --git a/docs/status/ROADMAP.adoc b/docs/status/ROADMAP.adoc index d57e94c..aaab30c 100644 --- a/docs/status/ROADMAP.adoc +++ b/docs/status/ROADMAP.adoc @@ -10,7 +10,9 @@ Initial development phase. The RSR canary now accepts CONTRIBUTING.adoc as well as CONTRIBUTING.md, at the root or in .github/, using the rsr-template-repo fix at e67ee001. -The existing duplicate-guide detection remains in place. Scorecard now grants +Exactly one guide is required across all four supported paths; duplicate +warnings name the offending paths. Controls cover all six guide pairs. +Scorecard now grants actions: read on its calling job, as its pinned reusable workflow requires; the reusable path and commit, including native-lock reconciliation, are unchanged. Both regression controls run in the existing Estate Rules job after its verified @@ -25,7 +27,7 @@ the unchanged main tree passed a current rerun. The owning template documents this content-dependent VM crash in https://github.com/hyperpolymath/rsr-template-repo/pull/335[PR #335]: changing workflow content can trigger it without changing the scorer. This repair adopts -the template's OTP 27.3.4.19 runtime and fixed Hypatia pin 51539abf, following +the template's OTP 27.3.4.19 oracle runtime and fixed Hypatia source, following https://github.com/hyperpolymath/rsr-template-repo/pull/369[PR #369]. The pin contains https://github.com/hyperpolymath/hypatia/pull/1062[the PinSites compiler guard]; the runtime and guard are both retained because the template later @@ -35,6 +37,16 @@ The oracle command and gating behavior are preserved. Resolution requires a passing hosted oracle run on the exact new head; local structural checks alone do not establish that the crash is resolved. +The oracle, SARIF scanner and both verdict reporters now share the canonical +Hypatia pin `6693f9aed8e4383f78a3d01b600b32663bf7a45c`, satisfying the existing +one-pin-per-tool contract (C2). The workflow-edge checker now reads real Hypatia +checkout refs as well as declared scanner pins; wrong literal refs cannot hide +behind a correct environment variable. Its controls cover missing and duplicate +inputs, exact environment bindings and shell examples that resemble YAML. +The scanner runtime and gate remain as configured. The suppression-layer source +audit and its limited changes are recorded in `docs/HYPATIA-RULE-ORDER.adoc`; +no repository exemption was added. + == Milestones === v0.1.0 - Foundation diff --git a/scripts/check-workflow-edges.sh b/scripts/check-workflow-edges.sh index 07a8f19..5a4e84a 100755 --- a/scripts/check-workflow-edges.sh +++ b/scripts/check-workflow-edges.sh @@ -102,6 +102,108 @@ env_pin() { } +# hypatia_checkouts FILE — literal checkout pins, including the RSR oracle. +# Supported form: block-mapping checkout steps, one with/repository/ref each; +# sequence items may be indentless or further indented under steps. Step keys +# follow the inline list-item key column; flow/aliased mappings fail closed. +# A ref may be a full SHA or exactly env.NAME with one literal declaration in +# workflow env or this job's env. Other expressions and ambiguous bindings fail. +# Block scalar bodies are skipped: a shell example is not a checkout input. +hypatia_checkouts() { + awk ' + function trim(s) { sub(/^[[:space:]]+/, "", s); sub(/[[:space:]]+$/, "", s); return s } + function scalar(s) { + sub(/[[:space:]]+#.*$/, "", s); s = trim(s) + if ((substr(s,1,1) == "\047" && substr(s,length(s),1) == "\047") || + (substr(s,1,1) == "\"" && substr(s,length(s),1) == "\"")) s = substr(s,2,length(s)-2) + return s + } + function flush() { + if (checkout && unsupported) target = 1 + if (target && checkout) { + n++; refs[n] = ref; scopes[n] = job; sites[n] = start + if (uses != 1 || !checkout || withs != 1 || repos != 1 || nrefs != 1 || unsupported) + reasons[n] = "ambiguous or unsupported with/repository/ref checkout mapping" + } + target = checkout = uses = withs = repos = nrefs = unsupported = 0 + ref = ""; wi = -1 + } + BEGIN { si = step = seq = block = ei = -1; job = 0 } + { + line = $0; sub(/\r$/, "", line) + match(line,/^[ ]*/); ind = RLENGTH + if (line ~ /^[[:space:]]*(#|$)/) next + if (block >= 0 && ind > block) next + block = -1 + body = substr(line, ind + 1); dash = "" + if (body ~ /^-[[:space:]]+/) { dash = "- "; sub(/^-[[:space:]]+/, "", body) } + if (body ~ /^["\047][A-Za-z_][A-Za-z0-9_-]*["\047]:/) { + at = index(body, ":") + if (substr(body,1,1) == substr(body,at-1,1)) + body = substr(body,2,at-3) substr(body,at) + } + line = substr(line,1,ind) dash body + if (line ~ /:[[:space:]]*[|>][-+0-9]*([[:space:]]+#.*)?[[:space:]]*$/) block = ind + if (line ~ /^ [A-Za-z0-9_-]+:[[:space:]]*$/) { flush(); job++; si = step = seq = -1 } + if (ei >= 0 && ind <= ei) ei = -1 + if (line ~ /^[ ]*env:[[:space:]]*$/) { ei = ind; es = (ind == 0 ? 0 : (ind == 4 ? job : -1)); next } + if (ei >= 0 && ind == ei + 2 && line ~ /^[ ]*[A-Z_][A-Z0-9_]*:/) { + key = trim(line); sub(/:.*/, "", key); value = line; sub(/^[^:]*:/,"",value) + counts[key]++; values[key] = scalar(value); owners[key] = es + } + if (si >= 0 && (ind < si || (ind == si && line !~ /^[ ]*-/))) { flush(); si = step = seq = -1 } + if (line ~ /^[ ]*steps:[[:space:]]*$/) { si = ind; seq = -1; next } + if (si < 0) next + if (ind >= si && (seq < 0 || ind == seq) && line ~ /^[ ]*-[[:space:]]/) { flush(); seq = step = ind; start = FNR } + if (step < 0) next + if (wi >= 0 && ind <= wi) wi = -1 + text = trim(line); sub(/^-[[:space:]]+/, "", text) + if ((ind == step || ind == step + 2) && text ~ /^uses:/) { + uses++; value = text; sub(/^uses:[[:space:]]*/, "", value) + if (tolower(scalar(value)) ~ /^actions\/checkout@/) checkout = 1 + } + if (ind == step + 2 && text ~ /^with:/) { + withs++; wi = ind + if (text !~ /^with:[[:space:]]*(#.*)?$/) { + unsupported = 1 + if (index(text,"hyperpolymath/hypatia")) target = 1 + } + next + } + if (wi >= 0 && text ~ /^(repository|ref):/) { + key = text; sub(/:.*/, "", key); value = text; sub(/^[^:]*:/,"",value); value = scalar(value) + if (ind != wi + 2) unsupported = 1 + if (key == "repository") { + repos++ + if (tolower(value) == "hyperpolymath/hypatia") target = 1 + else if (value !~ /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/) { target = 1; unsupported = 1 } + } + else { nrefs++; ref = value } + } else if (wi >= 0 && index(tolower(text),"hyperpolymath/hypatia")) { + target = 1; unsupported = 1 + } else if (wi >= 0 && text ~ /^<<:/) { + unsupported = 1 + } + } + END { + flush() + for (i=1; i<=n; i++) { + value = refs[i] + if (value ~ /^\$\{\{[[:space:]]*env\.[A-Z_][A-Z0-9_]*[[:space:]]*\}\}$/) { + key = value; sub(/^\$\{\{[[:space:]]*env\./,"",key); sub(/[[:space:]]*\}\}$/, "", key) + if (counts[key] != 1 || (owners[key] != 0 && owners[key] != scopes[i])) + reasons[i] = "missing or ambiguous env binding for checkout ref" + value = values[key] + } + if (length(value) != 40 || value ~ /[^0-9a-f]/) + reasons[i] = "missing or non-literal full-SHA checkout ref (or unresolved env binding)" + if (reasons[i] != "") print "!\tline " sites[i] ": " reasons[i] + else print value "\tline " sites[i] + } + } + ' "$1" +} + # reusable_calls FILE — every job-level reusable-workflow call in FILE # (`uses: OWNER/REPO/.github/workflows/X.yml@REF` outside every job's `steps:` # block), one per line. A producer may delegate its scan to such a call, and @@ -281,8 +383,21 @@ for wf in "$WORKFLOWS_DIR"/*.yml "$WORKFLOWS_DIR"/*.yaml; do case "$v" in *'${{'* | 'latest' | 'HEAD') continue ;; # floating by design, documented at the pin esac - printf '%s\t%s\t%s\n' "$var" "$v" "$(basename "$wf")" >> "$pins_file" + pin_name="$var"; [ "$var" != HYPATIA_REF ] || pin_name=HYPATIA_SHA + printf '%s\t%s\t%s\n' "$pin_name" "$v" "$(basename "$wf")" >> "$pins_file" done + checkout_rows="$(hypatia_checkouts "$wf")" || { + fail "$(basename "$wf") checkout refs could not be inspected" + continue + } + while IFS=$'\t' read -r pin site; do + [ -n "$pin" ] || continue + if [ "$pin" = '!' ]; then + fail "$(basename "$wf") Hypatia checkout ${site}" + else + printf '%s\t%s\t%s\n' HYPATIA_SHA "$pin" "$(basename "$wf") (Hypatia checkout ${site})" >> "$pins_file" + fi + done <<< "$checkout_rows" # A reusable call's hypatia-ref input pins the same scanner as HYPATIA_SHA. if [ -n "$(reusable_calls "$wf")" ]; then v="$(env_pin "$wf" hypatia-ref | head -n1)" diff --git a/tests/workflows/rhodibot_canary_test.sh b/tests/workflows/rhodibot_canary_test.sh index 9bd5722..fffead4 100644 --- a/tests/workflows/rhodibot_canary_test.sh +++ b/tests/workflows/rhodibot_canary_test.sh @@ -5,7 +5,7 @@ # is CONTRIBUTING.adoc (the estate writes prose in AsciiDoc) tripped it every # week. This runs the canary's own script, taken from the workflow, on # fixtures: an .adoc guide is enough, either form at the root or in .github/; -# no guide at all, and both forms at once, still trip it. +# no guide at all, and any pair of supported guides, still trip it. set -euo pipefail yq --version 2>&1 | grep -q mikefarah || { echo "FAIL: this test needs Mike Farah yq (Go, 4.53.3+); the yq on PATH is a different tool" >&2; exit 1; } repo=$(git rev-parse --show-toplevel) @@ -26,7 +26,8 @@ fixture() { # run DIR — the canary's exit status; its output in $work/out. run() { (cd "$1" && GITHUB_STEP_SUMMARY=/dev/null bash "$work/canary.sh") > "$work/out" 2>&1; } -for guide in CONTRIBUTING.adoc .github/CONTRIBUTING.adoc CONTRIBUTING.md .github/CONTRIBUTING.md; do +guides=(CONTRIBUTING.md CONTRIBUTING.adoc .github/CONTRIBUTING.md .github/CONTRIBUTING.adoc) +for guide in "${guides[@]}"; do d=$(fixture "ok-${guide//\//_}" "$guide") run "$d" || { cat "$work/out" >&2; fail "the canary tripped on a repository whose guide is $guide"; } done @@ -35,10 +36,18 @@ echo 'PASS: a CONTRIBUTING guide in AsciiDoc or Markdown, at the root or in .git d=$(fixture none) if run "$d"; then fail 'the canary passed a repository with no CONTRIBUTING guide'; fi grep -q 'no CONTRIBUTING.adoc or CONTRIBUTING.md (would be created)' "$work/out" || { cat "$work/out" >&2; fail 'the missing guide was not named'; } -d=$(fixture both CONTRIBUTING.adoc CONTRIBUTING.md) -if run "$d"; then fail 'the canary passed both CONTRIBUTING.md and CONTRIBUTING.adoc'; fi -grep -q 'duplicate CONTRIBUTING.md + CONTRIBUTING.adoc' "$work/out" || { cat "$work/out" >&2; fail 'the duplicate guide was not named'; } -echo 'PASS: (-) no guide, and both forms at once, still trip the canary' +echo 'PASS: (-) no CONTRIBUTING guide trips the canary' + +# Every pair covers cross-directory, cross-format, and same-format duplicates. +for ((i=0; i<${#guides[@]}; i++)); do + for ((j=i+1; j<${#guides[@]}; j++)); do + d=$(fixture "duplicate-$i-$j" "${guides[i]}" "${guides[j]}") + if run "$d"; then fail "the canary passed both ${guides[i]} and ${guides[j]}"; fi + grep -qF "duplicate CONTRIBUTING guides: ${guides[i]} ${guides[j]} (keep exactly one)" "$work/out" \ + || { cat "$work/out" >&2; fail 'the duplicate warning did not name both paths'; } + echo "PASS: (-) duplicate ${guides[i]} and ${guides[j]} trip the canary" + done +done # This repository itself is clean. (cd "$repo" && GITHUB_STEP_SUMMARY=/dev/null bash "$work/canary.sh") > "$work/out" 2>&1 \ diff --git a/tests/workflows/verdict_grid_test.sh b/tests/workflows/verdict_grid_test.sh index 1740099..6d8d451 100755 --- a/tests/workflows/verdict_grid_test.sh +++ b/tests/workflows/verdict_grid_test.sh @@ -399,7 +399,7 @@ render_args=(render --out "$WORK/grid" --renderer-dir "$FX/renderer" --report-backs "$FX/report-backs" --enrolment "$FX/enrolment.json" --sha 0123456789abcdef0123456789abcdef01234567 --run 42 --pr 7 --repo example/template --lane hypatia - --hypatia-ref be98f74ce93df200752f3798efa1305bfa3e0e10 + --hypatia-ref 6693f9aed8e4383f78a3d01b600b32663bf7a45c --panic-ref b689a74d2762a1c19839ae3fbd59b7fe5ef920ea --pons-ref 32e55677d8fd1f3010848dee22e822c2f385c2a0 --url https://github.com/example/template/actions/runs/42 diff --git a/tests/workflows/workflow_edges_test.sh b/tests/workflows/workflow_edges_test.sh index c6370fc..0d17d66 100755 --- a/tests/workflows/workflow_edges_test.sh +++ b/tests/workflows/workflow_edges_test.sh @@ -233,6 +233,99 @@ cat >> "$WORK/repo/.github/workflows/hypatia-scan.yml" <<'YML' YML expect_rc 0 "a step action with a workflow-shaped path is not followed as a reusable call" unset EDGES_REUSABLE_DIR + +echo "=== 12. Hypatia checkout refs participate in the one-tool pin contract ===" +checkout_fixture() { + local ref="$1" binding="${2:-}" + cat > "$WORK/repo/.github/workflows/oracle-pin-control.yml" </dev/null; checkout_fixture "$HSHA" +expect_rc 0 "a matching literal Hypatia checkout ref is accepted" +fresh >/dev/null; checkout_fixture 1111111111111111111111111111111111111111 +sed -i '/ - uses:/,$s/^ //' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a wrong Hypatia pin in an indentless steps sequence is refused" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i '/ - uses:/,$s/^ //' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 0 "a matching pin in an indentless steps sequence is accepted" +fresh >/dev/null; checkout_fixture 1111111111111111111111111111111111111111 +sed -i '/ - uses:/,$s/^/ /' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a more-indented steps sequence cannot hide a wrong Hypatia pin" +fresh >/dev/null; checkout_fixture 1111111111111111111111111111111111111111 +sed -i -e 's|hyperpolymath/hypatia|Hyperpolymath/Hypatia|' -e 's|actions/checkout@|Actions/Checkout@|' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "repository name casing cannot hide a different Hypatia checkout pin" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i -e "s/with:/'with':/" -e 's/repository:/"repository":/' -e "s/ref:/'ref':/" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 0 "matching checkout refs with quoted mapping keys are recognized" +sed -i "s/$HSHA/1111111111111111111111111111111111111111/" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "quoted mapping keys cannot hide a different Hypatia checkout pin" +fresh >/dev/null; checkout_fixture 1111111111111111111111111111111111111111 "$(printf 'env:\n HYPATIA_SHA: %s' "$HSHA")" +expect_rc 1 "a wrong literal checkout ref is caught even with the correct env pin" +says "the disagreement identifies the actual checkout" "Hypatia checkout" +fresh >/dev/null; checkout_fixture '${{ env.HYPATIA_SHA }}' "$(printf 'env:\n HYPATIA_SHA: %s' "$HSHA")" +expect_rc 0 "an exact, uniquely declared workflow env binding resolves" +fresh >/dev/null; checkout_fixture '${{ env.HYPATIA_SHA }}' +sed -i "/ runs-on:/i\ env:\n HYPATIA_SHA: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 0 "an exact, uniquely declared binding in the same job resolves" +fresh >/dev/null; checkout_fixture '${{ env.HYPATIA_SHA }}' +expect_rc 1 "an undefined checkout env binding is refused" +fresh >/dev/null; checkout_fixture '${{ env.HYPATIA_SHA }}' "$(printf 'env:\n HYPATIA_SHA: %s\n HYPATIA_SHA: %s' "$HSHA" "$HSHA")" +expect_rc 1 "duplicate identical checkout env bindings are ambiguous" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i '/ ref:/d' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a Hypatia checkout with no ref is refused" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i "/ ref:/a\ ref: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "duplicate checkout ref inputs are refused" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i '/ repository:/a\ repository: hyperpolymath/hypatia' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "duplicate checkout repository inputs are refused" +fresh >/dev/null; checkout_fixture "$HSHA" +printf ' with:\n repository: hyperpolymath/hypatia\n ref: %s\n' "$HSHA" >> "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "duplicate checkout with maps are refused" +fresh >/dev/null; checkout_fixture main +expect_rc 1 "a floating Hypatia checkout ref is refused" +fresh >/dev/null; checkout_fixture '${{ inputs.hypatia-ref }}' +expect_rc 1 "an unresolved checkout expression is refused" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i 's|repository: hyperpolymath/hypatia|repository: \&repo hyperpolymath/hypatia|' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "an unsupported anchored checkout repository fails closed" +fresh >/dev/null; checkout_fixture "$HSHA" +cat >> "$WORK/repo/.github/workflows/oracle-pin-control.yml" <<'YML' + - name: 'repository: hyperpolymath/hypatia ref: wrong' + run: | + cat <<'EXAMPLE' + - uses: actions/checkout@a-decoy + with: + repository: hyperpolymath/hypatia + ref: a-shell-example-is-not-a-pin + EXAMPLE +YML +expect_rc 0 "quoted labels and shell block checkout examples are not pin inputs" +fresh >/dev/null; checkout_fixture "$HSHA" +cat >> "$WORK/repo/.github/workflows/oracle-pin-control.yml" <<'YML' + - uses: owner/reporter@1111111111111111111111111111111111111111 + with: + repository: hyperpolymath/hypatia +YML +expect_rc 0 "a non-checkout action repository input is not a checkout pin" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i "s| with:| with: {repository: hyperpolymath/hypatia, ref: $HSHA}|" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "an unsupported flow-form checkout mapping fails closed" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i 's/ with:/ with: *checkout-options/' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "an aliased checkout with mapping fails closed" + echo "" if [ "$fail" -ne 0 ]; then echo "FAIL: workflow edges suite (${pass} passed, ${fail} failed)" >&2 From 902388131e2890259384a8a2368f2accc77820fe Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:59:32 +0000 Subject: [PATCH 4/4] Close checkout scope and YAML boundary gaps found in review --- docs/HYPATIA-RULE-ORDER.adoc | 6 +- scripts/check-workflow-edges.sh | 65 +++++++++++++++------ tests/workflows/workflow_edges_test.sh | 80 ++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 21 deletions(-) diff --git a/docs/HYPATIA-RULE-ORDER.adoc b/docs/HYPATIA-RULE-ORDER.adoc index 6b492df..f375d8c 100644 --- a/docs/HYPATIA-RULE-ORDER.adoc +++ b/docs/HYPATIA-RULE-ORDER.adoc @@ -116,8 +116,10 @@ must then change `scripts/check-workflow-edges.sh`'s expectation deliberately. *Enforced by.* `scripts/check-workflow-edges.sh` (identical-ref check plus the duplicate-pin scan). This includes Hypatia's RSR oracle checkout, its SARIF scanner and both verdict reporters. A checkout ref must be a literal full SHA -or an exact `env.NAME` expression with one literal declaration in workflow env -or the same job's env. Missing or duplicate checkout inputs, unresolved or +or an exact `env.NAME` expression with one literal declaration in the applicable +workflow or job scope. Job env overrides workflow env; siblings remain isolated. +A referenced checkout-step env binding is rejected as unsupported. Complete flow, +aliased and anchored steps are also explicitly unsupported. Missing or duplicate checkout inputs, unresolved or ambiguous bindings, and unsupported checkout mapping forms fail closed. Shell block examples are not checkout inputs. No YAML runtime dependency is needed. diff --git a/scripts/check-workflow-edges.sh b/scripts/check-workflow-edges.sh index 5a4e84a..9613b70 100755 --- a/scripts/check-workflow-edges.sh +++ b/scripts/check-workflow-edges.sh @@ -106,8 +106,10 @@ env_pin() { # Supported form: block-mapping checkout steps, one with/repository/ref each; # sequence items may be indentless or further indented under steps. Step keys # follow the inline list-item key column; flow/aliased mappings fail closed. -# A ref may be a full SHA or exactly env.NAME with one literal declaration in -# workflow env or this job's env. Other expressions and ambiguous bindings fail. +# A ref may be a full SHA or exactly env.NAME in workflow env or this job's env. +# A unique job declaration overrides workflow env; sibling jobs cannot supply +# values. Duplicate declarations in the selected scope and step-env bindings +# fail closed. Whole-step flow mappings, aliases and anchors are unsupported. # Block scalar bodies are skipped: a shell example is not a checkout input. hypatia_checkouts() { awk ' @@ -120,12 +122,13 @@ hypatia_checkouts() { } function flush() { if (checkout && unsupported) target = 1 - if (target && checkout) { - n++; refs[n] = ref; scopes[n] = job; sites[n] = start - if (uses != 1 || !checkout || withs != 1 || repos != 1 || nrefs != 1 || unsupported) + if (whole_unsupported || (target && checkout)) { + n++; refs[n] = ref; scopes[n] = job; step_scopes[n] = step_no; sites[n] = start + if (whole_unsupported) reasons[n] = "unsupported complete step mapping (flow, alias, anchor or non-inline key)" + else if (uses != 1 || !checkout || withs != 1 || repos != 1 || nrefs != 1 || unsupported) reasons[n] = "ambiguous or unsupported with/repository/ref checkout mapping" } - target = checkout = uses = withs = repos = nrefs = unsupported = 0 + target = checkout = uses = withs = repos = nrefs = unsupported = whole_unsupported = 0 ref = ""; wi = -1 } BEGIN { si = step = seq = block = ei = -1; job = 0 } @@ -136,34 +139,52 @@ hypatia_checkouts() { if (block >= 0 && ind > block) next block = -1 body = substr(line, ind + 1); dash = "" - if (body ~ /^-[[:space:]]+/) { dash = "- "; sub(/^-[[:space:]]+/, "", body) } + if (body ~ /^-[[:space:]]+/) { match(body,/^-[[:space:]]+/); dash = substr(body,1,RLENGTH); sub(/^-[[:space:]]+/, "", body) } if (body ~ /^["\047][A-Za-z_][A-Za-z0-9_-]*["\047]:/) { at = index(body, ":") if (substr(body,1,1) == substr(body,at-1,1)) body = substr(body,2,at-3) substr(body,at) } line = substr(line,1,ind) dash body - if (line ~ /:[[:space:]]*[|>][-+0-9]*([[:space:]]+#.*)?[[:space:]]*$/) block = ind - if (line ~ /^ [A-Za-z0-9_-]+:[[:space:]]*$/) { flush(); job++; si = step = seq = -1 } + header = line; sub(/[[:space:]]+#.*$/, "", header); sub(/[[:space:]]+$/, "", header) + if (line ~ /:[[:space:]]*[|>][-+0-9]*([[:space:]]+#.*)?[[:space:]]*$/) block = ind + length(dash) + if (header ~ /^ [A-Za-z0-9_-]+:[[:space:]]*$/) { flush(); job++; si = step = seq = -1 } if (ei >= 0 && ind <= ei) ei = -1 - if (line ~ /^[ ]*env:[[:space:]]*$/) { ei = ind; es = (ind == 0 ? 0 : (ind == 4 ? job : -1)); next } + if (header ~ /^[ ]*env:[[:space:]]*$/) { + ei = ind + es = (ind == 0 ? 0 : (step >= 0 && ind == keycol ? "step-" step_no : (ind == 4 ? job : "unsupported"))) + next + } + if (header ~ /^[ ]*env:/ && (ind == 0 || ind == 4)) { + unknown_env[(ind == 0 ? 0 : job)] = 1; next + } if (ei >= 0 && ind == ei + 2 && line ~ /^[ ]*[A-Z_][A-Z0-9_]*:/) { key = trim(line); sub(/:.*/, "", key); value = line; sub(/^[^:]*:/,"",value) - counts[key]++; values[key] = scalar(value); owners[key] = es + binding = es SUBSEP key; counts[binding]++; values[binding] = scalar(value) } if (si >= 0 && (ind < si || (ind == si && line !~ /^[ ]*-/))) { flush(); si = step = seq = -1 } - if (line ~ /^[ ]*steps:[[:space:]]*$/) { si = ind; seq = -1; next } + if (header ~ /^[ ]*steps:[[:space:]]*$/) { si = ind; seq = -1; next } if (si < 0) next - if (ind >= si && (seq < 0 || ind == seq) && line ~ /^[ ]*-[[:space:]]/) { flush(); seq = step = ind; start = FNR } + if (ind >= si && (seq < 0 || ind == seq) && line ~ /^[ ]*-([[:space:]]|$)/) { + flush(); seq = step = ind; keycol = ind + length(dash); start = FNR; step_no++ + item = header; sub(/^[ ]*-[[:space:]]*/, "", item) + if (item !~ /^[A-Za-z_][A-Za-z0-9_-]*:/) whole_unsupported = 1 + } if (step < 0) next if (wi >= 0 && ind <= wi) wi = -1 text = trim(line); sub(/^-[[:space:]]+/, "", text) - if ((ind == step || ind == step + 2) && text ~ /^uses:/) { + if ((ind == step || ind == keycol) && text ~ /^env:/) { + env_header = text; sub(/[[:space:]]+#.*$/, "", env_header) + if (env_header ~ /^env:[[:space:]]*$/) { ei = keycol; es = "step-" step_no } + else unknown_step_env[step_no] = 1 + next + } + if ((ind == step || ind == keycol) && text ~ /^uses:/) { uses++; value = text; sub(/^uses:[[:space:]]*/, "", value) if (tolower(scalar(value)) ~ /^actions\/checkout@/) checkout = 1 } - if (ind == step + 2 && text ~ /^with:/) { - withs++; wi = ind + if ((ind == step || ind == keycol) && text ~ /^with:/) { + withs++; wi = keycol if (text !~ /^with:[[:space:]]*(#.*)?$/) { unsupported = 1 if (index(text,"hyperpolymath/hypatia")) target = 1 @@ -191,11 +212,17 @@ hypatia_checkouts() { value = refs[i] if (value ~ /^\$\{\{[[:space:]]*env\.[A-Z_][A-Z0-9_]*[[:space:]]*\}\}$/) { key = value; sub(/^\$\{\{[[:space:]]*env\./,"",key); sub(/[[:space:]]*\}\}$/, "", key) - if (counts[key] != 1 || (owners[key] != 0 && owners[key] != scopes[i])) + local_binding = scopes[i] SUBSEP key; global_binding = 0 SUBSEP key + binding = (counts[local_binding] > 0 ? local_binding : global_binding) + if (unknown_step_env[step_scopes[i]] || counts["step-" step_scopes[i] SUBSEP key] > 0) + reasons[i] = "unsupported step-env binding for checkout ref" + else if (unknown_env[scopes[i]] || (binding == global_binding && unknown_env[0])) + reasons[i] = "unsupported env mapping in the applicable checkout scope" + else if (counts[binding] != 1) reasons[i] = "missing or ambiguous env binding for checkout ref" - value = values[key] + value = values[binding] } - if (length(value) != 40 || value ~ /[^0-9a-f]/) + if (reasons[i] == "" && (length(value) != 40 || value ~ /[^0-9a-f]/)) reasons[i] = "missing or non-literal full-SHA checkout ref (or unresolved env binding)" if (reasons[i] != "") print "!\tline " sites[i] ": " reasons[i] else print value "\tline " sites[i] diff --git a/tests/workflows/workflow_edges_test.sh b/tests/workflows/workflow_edges_test.sh index 0d17d66..410fe4d 100755 --- a/tests/workflows/workflow_edges_test.sh +++ b/tests/workflows/workflow_edges_test.sh @@ -261,6 +261,18 @@ expect_rc 0 "a matching pin in an indentless steps sequence is accepted" fresh >/dev/null; checkout_fixture 1111111111111111111111111111111111111111 sed -i '/ - uses:/,$s/^/ /' "$WORK/repo/.github/workflows/oracle-pin-control.yml" expect_rc 1 "a more-indented steps sequence cannot hide a wrong Hypatia pin" +fresh >/dev/null; checkout_fixture main +sed -i 's/ - uses:/ - name: |\n Oracle checkout\n uses:/' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a multiline initial step name cannot hide a floating checkout ref" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i 's/ - uses:/ - name: |\n Oracle checkout\n uses:/' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 0 "a multiline initial name preserves sibling checkout key boundaries" +fresh >/dev/null; checkout_fixture main +sed -i -e 's/ - uses:/ - uses:/' -e '/ with:/,$s/^/ /' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "extra spaces after the list dash cannot hide a floating checkout ref" +fresh >/dev/null; checkout_fixture "$HSHA" +sed -i -e 's/ - uses:/ - uses:/' -e '/ with:/,$s/^/ /' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 0 "checkout mappings use the actual inline key column after the dash" fresh >/dev/null; checkout_fixture 1111111111111111111111111111111111111111 sed -i -e 's|hyperpolymath/hypatia|Hyperpolymath/Hypatia|' -e 's|actions/checkout@|Actions/Checkout@|' "$WORK/repo/.github/workflows/oracle-pin-control.yml" expect_rc 1 "repository name casing cannot hide a different Hypatia checkout pin" @@ -277,6 +289,74 @@ expect_rc 0 "an exact, uniquely declared workflow env binding resolves" fresh >/dev/null; checkout_fixture '${{ env.HYPATIA_SHA }}' sed -i "/ runs-on:/i\ env:\n HYPATIA_SHA: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" expect_rc 0 "an exact, uniquely declared binding in the same job resolves" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' +sed -i "/^ score:/i\ sibling:\n env:\n PIN: $HSHA\n runs-on: ubuntu-24.04" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +sed -i 's/^ score:$/ score: # scanner/' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a commented job header cannot borrow a sibling job env binding" +says "the missing applicable binding is named" "env binding" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' +sed -i "/ runs-on:/i\ env:\n PIN: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +cat >> "$WORK/repo/.github/workflows/oracle-pin-control.yml" </dev/null; checkout_fixture '${{ env.PIN }}' "$(printf 'env: # workflow binding\n PIN: %s' "$HSHA")" +expect_rc 0 "an env header with a trailing comment still supplies workflow scope" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' 'env: + PIN: 1111111111111111111111111111111111111111' +sed -i "/ runs-on:/i\ env: # job overrides workflow\n PIN: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 0 "a unique job binding overrides the same workflow env name" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' "$(printf 'env:\n PIN: %s' "$HSHA")" +sed -i '/ runs-on:/i\ env:\n PIN: 1111111111111111111111111111111111111111' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "the job override determines the checked ref, not the workflow value" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' +sed -i "/ runs-on:/i\ env:\n PIN: $HSHA\n PIN: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "duplicate declarations in the applicable job scope remain ambiguous" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' +sed -i "/ runs-on:/i\ env:\n PIN: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +cat >> "$WORK/repo/.github/workflows/oracle-pin-control.yml" <<'YML' + env: + PIN: 1111111111111111111111111111111111111111 +YML +expect_rc 1 "a wrong step binding cannot hide behind the correct job binding" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' +sed -i "/ runs-on:/i\ env:\n PIN: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +sed -i 's/ - uses:/ - env:\n PIN: 1111111111111111111111111111111111111111\n uses:/' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a first-key step env override cannot borrow the correct job value" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' +sed -i "/ runs-on:/i\ env:\n PIN: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +printf ' env: {PIN: 1111111111111111111111111111111111111111}\n' >> "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "an unsupported flow step env cannot hide a potentially overriding value" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' +sed -i "/ runs-on:/i\ env:\n PIN: $HSHA" "$WORK/repo/.github/workflows/oracle-pin-control.yml" +sed -i 's/ - uses:/ - env: {PIN: 1111111111111111111111111111111111111111}\n uses:/' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a first-key flow step env is refused rather than ignored" +fresh >/dev/null; checkout_fixture '${{ env.PIN }}' "$(printf 'env:\n PIN: %s' "$HSHA")" +sed -i '/ runs-on:/i\ env: {PIN: 1111111111111111111111111111111111111111}' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "an unsupported job env map cannot fall back to a correct workflow value" +fresh >/dev/null; checkout_fixture main +sed -i 's/ steps:/ steps: # oracle/' "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "a commented steps header cannot hide a floating checkout ref" +fresh >/dev/null +cat > "$WORK/repo/.github/workflows/oracle-pin-control.yml" <<'YML' +name: Oracle checkout control +jobs: + score: + steps: + - {uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1, with: {repository: hyperpolymath/hypatia, ref: main}} +YML +expect_rc 1 "an unsupported complete flow step is refused rather than ignored" +says "the unsupported complete step syntax is named" "unsupported complete step mapping" +fresh >/dev/null; checkout_fixture "$HSHA" +printf ' - *checkout-options\n' >> "$WORK/repo/.github/workflows/oracle-pin-control.yml" +expect_rc 1 "an unsupported whole-step alias is explicitly refused" fresh >/dev/null; checkout_fixture '${{ env.HYPATIA_SHA }}' expect_rc 1 "an undefined checkout env binding is refused" fresh >/dev/null; checkout_fixture '${{ env.HYPATIA_SHA }}' "$(printf 'env:\n HYPATIA_SHA: %s\n HYPATIA_SHA: %s' "$HSHA" "$HSHA")"