From 9be654048e35b607e9ca1be2576604c2914383bc Mon Sep 17 00:00:00 2001 From: David Bowman Date: Fri, 9 Oct 2026 20:13:43 +0000 Subject: [PATCH 1/7] plans(ci): add M003j dispatch-tag shell injection corrective --- ...dispatch-tag-shell-injection-corrective.md | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md diff --git a/plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md b/plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md new file mode 100644 index 0000000..5c65fb8 --- /dev/null +++ b/plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md @@ -0,0 +1,106 @@ +# CI/Release M003j — Dispatch-tag Shell Injection Corrective + +Status: ready for implementation. +Repository baseline: `eggstack/eggpack@d61ca71fc0112be63e7e8ba31ba8fa2b1ce5a628` (2026-10-08). +Source roadmap: `plans/subsystems/ci-release-orchestration-roadmap.md`. +Primary class: invariant / security corrective. +Historical upstream authority: ADR-0003 checked-in generated CI and publication; CI M003i `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` and `plans/closure/ci-release-orchestration/003i-status.md` (closed; historic record remains unchanged). +Confirmed affected consumer: `dbowm91/wg-basic@ff40f851508ccda52171c27cefdcdaf4ec1da2d5` generated `.github/workflows/release-eggpack.yml`, Release Readiness R001 `plans/implementation/release-readiness/001-release-workflow-input-and-provenance-hardening.md` on `plans/release-readiness-security`. +Dependency: previous CI M001–M003i closed. No platform/release producer contract change required. + +## 1. Objective + +Eliminate shell command injection through a user-provided `workflow_dispatch.inputs.release_tag` in all Eggpack-rendered GitHub Actions scripts. Preserve deterministic generation, tag/source/manifest separation, exact-tag staging, read-only build jobs, write-only final draft staging, stable manifest schema, and existing consumer workflows. Supply a new immutable Eggpack revision for wg-basic R001 to pin/regenerate before any production signing/staging. + +## 2. Reproduction and missed test surface + +`crates/eggpack-ci/src/lib.rs` renders the unsafe pattern twice, within: +- reusable runtime identity `resolve` job, around the `Validate exact-tag source` step in `render_github_workflow`; +- final `stage` job (the job with `permissions: contents: write`), also in `Validate exact-tag source`. + +Both emit the Bash command text `test -n "${{ inputs.release_tag }}"`. GitHub evaluates `${{...}}` interpolation before creating the shell script. A crafted dispatch-input value containing command-substitution or shell-special syntax can therefore become executable Bash source. This is a *source-proven generated script injection surface*; no attack against real CI or credentials has been performed. The affected downstream wg-basic generated workflow contains the exact two vulnerable emitted steps at its baseline. + +Existing tests `m003c_tag_source_controls_checkout_input_and_stage_guard`, checked-in golden workflows and `eggpack ci check` validate source tag mapping and draft permissions, but do not assert that user-supplied values are never embedded inside executable shell snippets. M003i's identity binding is necessary but does not remove this interpretation hazard. + +## 3. Invariants + +- No runtime/event/dispatch expression with potentially untrusted text is interpolated directly into a generated `run:` Bash/PowerShell expression. Use an Actions `env:` binding with subsequent **quoted variable reference** or an equivalent typed input protocol. +- Validate canonical stable tag `vX.Y.Z` (no leading zeros, shell metacharacters, suffix, embedded newline, oversized value or alternate ref) and nonempty input before source resolution and privileged staging. Do not trust tag syntax to authorize source SHA; continue using the existing exact-source verification. +- No `eval`, `bash -c`, script templating from dispatch value, untrusted output-file append, unsafe variable re-evaluation, or unbounded shell string concatenation. +- `contents: write` remains limited to staging after all build/qualification/aggregation jobs pass. Never pass a signing secret or broaden permissions to make tests pass. +- Existing M003i `v_prefixed_stable_semver` mapped identity and legacy exact-tag modes, `_resolve-release`, `_verify-source`, tag/commit/manifest binding and default release-concurrency semantics remain compatible. +- Production CLI/workflow paths and Eggpack ReleaseManifest v1 schema remain unchanged. No new producer-side signing; key custody belongs to each consumer. +- A resolved GitHub tag or string in `with.ref` or non-executable concurrency group need not be blindly forbidden; prohibit the **executable shell interpolation sink** and separately validate tag/ref authority before build/stage. + +## 4. Scope / non-goals + +In scope: the two renderer sites and any other discovered equivalent executable interpolation, deterministic YAML rendering, finite syntax guard, golden fixtures/tests, producer documentation, CI, downstream rerender handoff. + +Out of scope: wg-basic product-key management, first-install trust flow, publication itself, changing generated manifest schema, generic arbitrary workflow scripting, adding unbounded expression language, changing GitHub security settings without maintainer authorization, or rewriting historical M003i closure. + +## 5. Ordered work packages + +### WP1 — Failing discriminating tests first + +Add a regression that inspects the **actual generated reusable dispatch + write-scoped stage workflow** and fails when a `run:` script includes `${{ inputs.release_tag }}` or another unsafe untrusted expression. Build a controlled local Bash test that expands a malicious fixture tag in the *old* script template and observes a harmless temporary marker, then asserts the corrected render never evaluates the marker. Do not use actual network calls, privileged staging or production GitHub credentials. Include benign `v1.2.3`, empty, malformed, newline, leading-zero, shell-substitution and punctuation cases. + +### WP2 — Minimal generator correction + +For both reusable `resolve` and final `stage` validations, use: + +```yaml +- name: Validate exact-tag source + shell: bash + env: + EGGPACK_RELEASE_TAG: ${{ inputs.release_tag }} + run: | + # reject invalid/noncanonical release_tag (strict stable SemVer) + # test "$EGGPACK_RELEASE_TAG" as data, never as source +``` + +An equivalent stable private generator helper is acceptable. Preserve dispatch validation/checkout/source preflight ordering; ensure validation executes *before* any write-scoped action that consumes the tag or stages a draft. If checkout currently precedes validation, assess whether a malicious ref can cause branch-controlled code to execute, and add an earlier static validation step before checkout where necessary, without altering the source authority. Add a deterministic bounded tag syntax function/reusable private snippet rather than repeated unsafe string formatting. + +### WP3 — Generator fixtures and compatibility + +Update relevant `crates/eggpack-ci/tests/fixtures/*` golden YAML and current expectation tests. Confirm `StagingTagSource::RefName` legacy behavior (push-only tag), DispatchInput mapped identity, `github.ref_type` use, exact permitted source-ref checks, and `v_prefixed_stable_semver` identity normalization retain their existing semantics. Verify `eggpack ci check` catches a reintroduced unsafe `run:` interpolation even if generated schema/format otherwise matches; prefer a small static security guard in generator tests. + +### WP4 — Consumer handoff + +Generate the wg-basic workflow from its pinned config using the corrected Eggpack revision, verify no drift under `eggpack ci check`, and prove the exact unsafe source expression is absent in both consumer sites. Record immutable Eggpack implementation SHA and any changed consumer policy keys; do not modify wg-basic's repository from Eggpack except via the separate consumer R001 plan. + +Check whether other adopted Eggpack consumers enable `DispatchInput` staging and document impacted workflows; do not claim all consumers affected solely from renderer reachability. + +### WP5 — Verification and docs + +Execute Cargo fmt, clippy, all workspace tests, docs, Rust 1.89 MSRV, generated workflow fixture and independent `ci check` including a changed-producer negative. Require hosted Stable Linux, MSRV, macOS and Windows full qualification on the implementation SHA; record actual runs. Update `architecture/ci.md`, `architecture/github.md`, `crates/eggpack-ci/README.md`, subsystem roadmap and registry. + +## 6. Failure, contention and authorization + +Unsafe/malformed dispatch input must fail before any candidate-build or draft-staging mutation. Multiple dispatch jobs for the same canonical tag remain concurrency-serialized, but concurrency text is not authorization. An input racing a moving tag must still fail exact-source verification. Do not silently accept a branch where a stable tag is required. Stop on a bypass for the script guard or ref-source mismatch. + +## 7. Compatibility/security and test commands + +No new dependency, public enum variant, release-manifest schema or ordinary binary API break. No additional contents-write scope, no signing credential access and no arbitrary subprocess execution. Changes limited to generator and tests, plus docs and golden workflows. + +```text +cargo fmt --all -- --check +cargo clippy --workspace --all-targets --all-features --locked -- -D warnings +cargo test --workspace --all-targets --all-features --locked +cargo doc --workspace --no-deps --locked +cargo +1.89.0 check --workspace --all-targets --locked +git diff --check +``` + +Add direct narrowed `cargo test -p eggpack-ci --locked` and the actual generated workflow security fixture/CI validation. If the upstream repository uses a different supported command, record the exact equivalent. Require a smoke against the wg-basic pinned `release/eggpack/github-policy.json` fixture, but do not require production signing or root service install in Eggpack. + +## 8. Acceptance + +Both source renderer sites use safe data handling; generator tests fail against the baseline vulnerable render and pass after correction; malicious input never becomes shell commands, and invalid tag fails before privileged stage; golden workflows and `ci check` remain deterministic; source/tag/release identity semantics retained; platform CI green; exact corrected producer SHA is recorded for wg-basic adoption; no public signature/publish work occurs. + +## 9. Stop conditions + +Stop on tag-check logic that is bypassable with shell quoting/newline; a workaround that edits only wg-basic generated YAML; stage job running unvalidated tagged-source code; changes to manifest semantics or publication authority; privilege expansion; regressions in existing CI M003i mapped identity; or inability to prove source-ref/runner-stage isolation. + +## 10. Closure evidence + +After implementation, write `plans/closure/ci-release-orchestration/003j-status.md` with baseline/implementation SHA, before/after generated YAML and controlled injection negative proof, test/CI run URLs, released pin guidance, exact consumer rerender diff, unchanged scope/manifest checks, findings severity and explicit wg-basic R001 unblock. Prior CI M003i closure remains historical and unchanged. From fa0cd817ab8da4a9da8d8812de80b88597b77afb Mon Sep 17 00:00:00 2001 From: David Bowman Date: Fri, 9 Oct 2026 20:14:12 +0000 Subject: [PATCH 2/7] plans(ci): register M003j generator security corrective in roadmap --- plans/subsystems/ci-release-orchestration-roadmap.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plans/subsystems/ci-release-orchestration-roadmap.md b/plans/subsystems/ci-release-orchestration-roadmap.md index 909187e..38bf53b 100644 --- a/plans/subsystems/ci-release-orchestration-roadmap.md +++ b/plans/subsystems/ci-release-orchestration-roadmap.md @@ -98,7 +98,9 @@ M003g live-qualification corrective plan: `plans/implementation/ci-release-orche M003h status-reconciliation/main-integration corrective plan: `plans/implementation/ci-release-orchestration/003h-live-qualification-status-reconciliation-and-main-integration.md`. -M003i identity-separation corrective: `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` (**closed** at `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`, hosted run `37813044035`, all four lanes green). The immutable producer pin unblocks the separate wg-basic Distribution M003 for its consumer-owned implementation and qualification. +M003i identity-separation corrective: `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` (**closed** at `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`, hosted run `37813044035`, all four lanes green). The immutable producer pin unblocked the separate wg-basic Distribution M003 for its consumer-owned implementation and qualification. + +M003j dispatch-tag shell-injection corrective: `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` (**ready**). A 2026-10-09 wg-basic first-public-release security review found `workflow_dispatch.inputs.release_tag` interpolated directly into executable Bash at two generator sites (resolve and write-scoped stage). Preserve M003i's source identity and fix unsafe render with env/data handling, deterministic negative tests, and a fresh immutable producer pin for wg-basic Release Readiness R001. ## 8. Cross-cutting requirements @@ -140,6 +142,7 @@ Build/Qualification M001-M006 and CI M001/M002/M002a/M003c-M003g are closed on t | M003g live qualification failures corrective | closed | `plans/implementation/ci-release-orchestration/003g-live-qualification-corrective.md` | `plans/closure/ci-release-orchestration/003g-status.md`; implementations `5acda73`/`4b28820`/`5ac5b83`/`e5c81f2`; hosted runs 36638321253, 36642184204, 36646814734, 36652203168 all lanes | cross-tool PATH, invalid zigbuild check, artifact exec-bit stripping, consumer validation against failed evidence, stage arity, swallowed staging error, and boolean `make_latest` all corrected; live run 36652731202 staged a complete 15-asset draft for eggsact `v1.2.7`, which the maintainer then published | | M003h live qualification status reconciliation + main integration | closed | `plans/implementation/ci-release-orchestration/003h-live-qualification-status-reconciliation-and-main-integration.md` | `plans/closure/ci-release-orchestration/003h-status.md` | current `main@404f63ec` was merged by `609d5fb`; status reconciled, full verification passed, and `main` fast-forwarded without force | | M003i explicit tag and manifest release identity corrective | closed | `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` | `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`; hosted run `37813044035` passed all four lanes | Finite checked-in opt-in stable-tag mapping with explicitly versioned runtime envelope; legacy exact-tag workflow bytes and ReleaseManifest v1 remain unchanged; wg-basic M003 may resume against the immutable producer SHA | +| M003j dispatch tag shell-injection corrective | ready | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | none (new corrective plan) | Two unsafe `run:` expression interpolations in runtime resolve and write-scoped stage; fix generator and prove no shell execution from dispatch input; wg-basic Release R001 waits on qualified producer pin | ## 13. 2026-10-08 corrective addendum — M003i From 829ff101118a3f4fe9920ec6715371f37fdd54c2 Mon Sep 17 00:00:00 2001 From: David Bowman Date: Fri, 9 Oct 2026 20:14:28 +0000 Subject: [PATCH 3/7] plans(ci): register M003j ready upstream producer handoff --- plans/registry.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plans/registry.md b/plans/registry.md index 2c679c2..271c2b9 100644 --- a/plans/registry.md +++ b/plans/registry.md @@ -96,7 +96,7 @@ Distribution predecessor evidence: | Release manifest | active | `plans/subsystems/release-manifest-roadmap.md` | M002/M003 closed; M003a closed | M003a closed as a docs-only post-publication downstream-closure reconciliation after Eggup M004 closed (`eggstack/eggup@ea1f1c5e29302e5feca4599db9342d3a5ac93915`; formal Eggup status cleanup `eggstack/eggup@3b82d5397e728649a666690868a1e2d0fe42460d`); closure `plans/closure/release-manifest/003a-status.md`; M003 remains closed and no runtime/package requalification was performed or implied | | Build and qualification | active | `plans/subsystems/build-qualification-roadmap.md` | M001-M006 closed | M006 closed on `398cd43` + run 36484758546 under accepted ADR-0005 Option A; the milestone chain is closed and later work needs new evidence | | Bootstrap installers | active; corrective closed | `plans/subsystems/bootstrap-installers-roadmap.md` | M002b closed; prior milestones closed | M002b implementation `88ddf2e`, hosted run `37806244313`; POSIX runtime remains on Unix and Windows PowerShell archive runtime passed. M003 completion definition remains satisfied | -| CI/release orchestration | active; M003i closed | `plans/subsystems/ci-release-orchestration-roadmap.md` | M003i closed; prior milestones closed | Closure `plans/closure/ci-release-orchestration/003i-status.md`; wg-basic M003 can resume against the immutable producer SHA. M003b Phase 8 remains satisfied | +| CI/release orchestration | active; M003i closed, M003j security corrective ready | `plans/subsystems/ci-release-orchestration-roadmap.md` | M003j dispatch-input shell hardening | M003i historical closure retained; two generated `run:` expressions embed `inputs.release_tag` in shell; wg-basic Release R001 blocked on qualified M003j output | | Eggup interoperability | active | `plans/subsystems/eggup-interoperability-roadmap.md` | Eggpack M001a + Eggup adapter M001/M001a + Eggup M003 real-consumer adoption + Eggup M004 registry promotion all closed | The whole producer/consumer package seam is closed end to end; Release Manifest M003a closed the remaining Eggpack-side planning drift, and no Eggpack work remains on this seam; Eggwork Operations M003 remains producer-only | | Ecosystem adoption | active | `plans/subsystems/ecosystem-adoption-roadmap.md` | M001/M002/M003a/M003b closed | Closure `plans/closure/ecosystem-adoption/003b-status.md`. Paired plans: Eggpack `plans/implementation/ecosystem-adoption/003b-eggsearch-seven-target-eggpack-producer-cutover.md` (`325d44e`); Eggsearch `plans/implementation/eggpack-release-adoption/001-seven-target-eggpack-producer-cutover.md` (`377f9e8`, registry `6767062`). Implementation landed at `eggstack/eggsearch@eabbf80`; hosted run `37531104901` staged eggsearch `v0.4.2` as draft `405157598` with the exact 19-asset inventory, glibc 2.17 re-proven on all three GNU targets, ARMv7 required consumer validator green, Windows ARM64 required and green, and zero OIDC permission in generated jobs. Provenance attested the staged bytes in run `37561960304`; the draft was published 2026-10-07, closing the named condition | | Planning hygiene | active | `plans/subsystems/planning-hygiene-roadmap.md` | M001/M002 closed | M002 closed at `plans/closure/planning-hygiene/002-status.md`: docs/evidence-only post-M003a handoff reconciliation with an empty production/package/workflow diff; stale/duplicated control-surface text removed and the handoff bound to exact paired-plan paths | @@ -105,7 +105,7 @@ Distribution predecessor evidence: ## Dependency-ready implementation work -Planning Hygiene M002, Ecosystem M003b, Bootstrap M002b, and CI M003i are closed. **No Eggpack implementation plan is currently ready.** The wg-basic M003 handoff is now unblocked by Eggpack's immutable producer pin, but that consumer-owned plan is not an Eggpack implementation task. If no new dependency-ready line is registered, the next Eggpack action is plan authoring. +Planning Hygiene M002, Ecosystem M003b, Bootstrap M002b, and CI M003i are closed. **New dependency-ready CI M003j security corrective:** `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md`. A wg-basic release-readiness source audit confirmed two `workflow_dispatch.inputs.release_tag` interpolations into generated executable Bash, including the write-scoped staging job, at Eggpack `crates/eggpack-ci/src/lib.rs` around the reusable resolver and stage render. Fix and qualify the producer generator before wg-basic R001 repins/regenerates; no public release or new signing is authorized. The table below is the **milestone-to-closure index plus active ready work**, not an implication that every historical row is executable. @@ -113,6 +113,7 @@ The table below is the **milestone-to-closure index plus active ready work**, no |---|---|---|---|---| | Bootstrap installers | M002b Windows POSIX archive-test portability | **closed** | `plans/implementation/bootstrap-installers/002b-windows-posix-archive-test-portability-corrective.md` | Closure `plans/closure/bootstrap-installers/002b-status.md`; implementation `88ddf2e`; hosted run `37806244313` all lanes green | | CI orchestration | M003i exact tag versus manifest release ID policy | **closed** | `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` | Closure `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`; hosted run `37813044035` all four lanes green. wg-basic M003 may resume with this pin | +| CI orchestration | M003j dispatch-tag Bash interpolation corrective | **ready** | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | Hard: CI M003i closed; generated workflow root cause proven in source; wg-basic Release R001 needs immutable qualified fix | | Planning hygiene | M001 current evidence baseline + blocker reconciliation | closed | `plans/implementation/planning-hygiene/001-current-evidence-baseline-and-blocker-reconciliation.md` | Closure `plans/closure/planning-hygiene/001-status.md`; discharged CI M003b (eggsact `685fa373` + run `36886042696`) and closed Ecosystem M002 on stegoeggo `v0.5.0` (run `37181914252`); docs-only, zero production/package/workflow delta | | Planning hygiene | M002 post-M003a cross-repository handoff reconciliation | closed | `plans/implementation/planning-hygiene/002-post-m003a-cross-repository-handoff-reconciliation.md` | Closure `plans/closure/planning-hygiene/002-status.md`; docs/evidence-only; stale M003/M003a/M003b control-surface text reconciled against exact paired-plan paths; empty production/package/workflow diff | | Contract and conformance | M003 bounded direct-contract expansion CLI | closed | `plans/implementation/contract-conformance/003-bounded-direct-contract-expansion-cli.md` | Closure `plans/closure/contract-conformance/003-status.md`; implemented on `43fa2d7`; local-only scalar projection delegating to `DistributionContract`; `ci` family unchanged byte-for-byte; no new dependency, serialized schema, discovery, or framework | From 559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce Mon Sep 17 00:00:00 2001 From: doc Date: Fri, 9 Oct 2026 20:34:17 +0000 Subject: [PATCH 4/7] fix(ci): harden dispatch tag validation --- architecture/ci-rendering.md | 32 ++-- architecture/ci.md | 4 +- architecture/overview.md | 4 +- crates/eggpack-ci/README.md | 7 + crates/eggpack-ci/src/lib.rs | 275 +++++++++++++++++++++++++++++++---- 5 files changed, 276 insertions(+), 46 deletions(-) diff --git a/architecture/ci-rendering.md b/architecture/ci-rendering.md index 3ba8129..4bee60a 100644 --- a/architecture/ci-rendering.md +++ b/architecture/ci-rendering.md @@ -129,24 +129,36 @@ and rendered behaviour cannot diverge. ## Job and step composition -Triggers are emitted first (`:3140-3155`). `push:` and `workflow_dispatch:` +Triggers are emitted first (`:3320-3333`). `push:` and `workflow_dispatch:` appear in the order the policy lists them. Dispatch gains a `release_tag` string input only when staging is enabled *and* the tag source is `DispatchInput` -(`:3146-3152`); there is no branch or `latest` default. The top-level -`permissions` block is `contents: read` (`:3156`, and `:1669` for build-only), +(`:3323-3331`); there is no branch or `latest` default. The top-level +`permissions` block is `contents: read` (`:3335`, and `:1850` for build-only), and every job restates it. Concurrency keys on workflow and ref, or on the -resolved staging tag for dispatch-driven staging (`:3167-3170`). +resolved staging tag for dispatch-driven staging (`:3340-3350`). + +Dispatch tags are workflow data throughout the renderer. The reusable +`resolve` and write-scoped `stage` jobs bind `inputs.release_tag` to +`EGGPACK_RELEASE_TAG`, validate a bounded canonical stable `vX.Y.Z` form in +Bash, and do so before checkout. The resolver passes the tag to +`_resolve-release` only through the quoted `"$EGGPACK_RELEASE_TAG"` argument. +The renderer has a source-level guard that rejects either dispatch-tag +expression in any emitted `run:` script; the check permits the same value in +action inputs such as checkout `with.ref`, where it is data. +`m003j_dispatch_tag_validation_treats_values_as_data` proves a command +substitution marker executes in the old script template but not in the new +validation script. | Order | Job | Line | `needs:` | |---|---|---|---| -| 1 | `preflight` | `:3177` | — | -| 2 | `resolve` (reusable only) | `:3209` | `preflight` | +| 1 | `preflight` | `:3356` | — | +| 2 | `resolve` (reusable only) | `:3388` | `preflight` | | 3 | one build job per `CIPlan` target | `:3246` | `resolve` if reusable, else `preflight` (`:3278-3282`) | | 4 | one qualification job per build job | `:3371` | that build job (`:3397-3398`) | | 5 | one consumer job per validated target | `:3441` | that qualification job (`:3475-3476`) | | 6 | gate, id fixed `required_gate` | `:3526` | inline list (`:3534-3549`) | | 7 | aggregate, id fixed `aggregate` | `:3599` | the gate (`:3610-3611`) | -| 8 | `stage`, only when the graph has staging | `:3673` | the aggregate, plus an `if:` tag guard (`:3710-3723`) | +| 8 | `stage`, only when the graph has staging | `:3895` | the aggregate, plus an `if:` tag guard (`:3900-3910`) | Job identifiers are not invented by the renderer. They come from the validated plan, and `ReleaseCIPlanV1::validate` pins them to exact strings: the gate must @@ -165,9 +177,9 @@ per output (`:3315`), `_capture-build` (`:3352`), artifact upload (`:3357`). The install precedes the first `eggpack` invocation; source verification follows the toolchain the install depends on. Least privilege is structural: every job carries `permissions: contents: read` except `stage`, which carries -`contents: write` (`:3726`); no job receives `id-token: write`, and the renderer -fails closed if that string ever appears (`:3772-3774`). The staging token -travels through `env` only (`:3751`). Artifact handoff names are derived, not +`contents: write` (`:3913`); no job receives `id-token: write`, and the renderer +fails closed if that string ever appears (`:3960-3962`). The staging token +travels through `env` only (`:3939`). Artifact handoff names are derived, not literal: `handoff_name` (`:432`), `BUILD_HANDOFF_FILE` (`:941`), `QUALIFICATION_EVIDENCE_FILE` (`:943`), `CANDIDATES_DIR` (`:945`), `GATE_OUTCOME_FILE` (`:947`), `RUNTIME_IDENTITY_ARTIFACT` (`:4440`). diff --git a/architecture/ci.md b/architecture/ci.md index 434827b..86e29a5 100644 --- a/architecture/ci.md +++ b/architecture/ci.md @@ -1,7 +1,7 @@ # `eggpack-ci` — Deep Dive Crate-level orientation for `eggpack-ci`: the largest component in the workspace -at 10256 lines in a single `src/lib.rs`. This file explains how that file divides +at 10772 lines in a single `src/lib.rs`. This file explains how that file divides and what flows through it. It does not restate per-area detail — three deep dives cover the parts. @@ -18,7 +18,7 @@ Code baseline `fc072af`. | Deep dive | Owns | Approximate region of `src/lib.rs` | |---|---|---| -| [ci-rendering.md](ci-rendering.md) | policy types, `RunnerCommand`, the three renderers, drift checks | `:418-1843`, `:2926-3846` | +| [ci-rendering.md](ci-rendering.md) | policy types, `RunnerCommand`, the three renderers, drift checks | `:1066-2100`, `:3080-4005` | | [ci-consumer-seam.md](ci-consumer-seam.md) | the external consumer validator, runtime identity, artifact handoff formats | `:1844-2209`, `:3847-4432`, `:4432-4596` | | this file | crate orientation, the projection model, job vocabulary, gates, aggregation | `:42-453`, `:2210-2742`, `:2743-2925` | diff --git a/architecture/overview.md b/architecture/overview.md index 9fd8df9..9625426 100644 --- a/architecture/overview.md +++ b/architecture/overview.md @@ -153,7 +153,7 @@ contract manifest | `eggpack-manifest` | 1354 | [manifest.md](manifest.md) | | `eggpack-core` | 5998 (4 files) | [core.md](core.md) | | `eggpack-bootstrap` | 3436 | [bootstrap.md](bootstrap.md) | -| `eggpack-ci` | 10256 | [ci.md](ci.md) | +| `eggpack-ci` | 10772 | [ci.md](ci.md) | | `eggpack-github` | 4873 (3025 + 1848 tests) | [github.md](github.md) | | `eggpack-cli` | 3803 src + 381 integration tests | [cli.md](cli.md) | @@ -221,7 +221,7 @@ authenticity or provenance claims. ### `eggpack-ci` — release CI planning and workflow rendering -Single `src/lib.rs` at 10256 lines, the largest component in the workspace. +Single `src/lib.rs` at 10772 lines, the largest component in the workspace. Depends on `contract` + `core`. Projects a release into a provider-neutral graph (`project_ci_plan` → `CIPlan` → `TargetJob`; `project_release_plan` → `ReleaseCIPlanV1` with qualification, gate, aggregate/finalize, and staging diff --git a/crates/eggpack-ci/README.md b/crates/eggpack-ci/README.md index 2815118..8517589 100644 --- a/crates/eggpack-ci/README.md +++ b/crates/eggpack-ci/README.md @@ -32,6 +32,13 @@ checkouts, and authorizes staging only for dispatches. Each job verifies `HEAD^{commit}` against the checked-in `ReleasePlan.source_revision` before release work; `ci check` compares the complete deterministic workflow. +Reusable resolver and write-scoped staging jobs validate dispatch tags as +bounded canonical stable `vX.Y.Z` values before checkout. The input is bound to +`EGGPACK_RELEASE_TAG` and passed to shell commands only through quoted variable +references; generated `run:` scripts reject direct dispatch-tag expressions. +The preflight checkout remains a data-only action invocation and runs no +checked-out code. + M003d adds the consumer release composition seam without absorbing product-owned release semantics. Static checked-in workflow shape (`ReleaseWorkflowShapeV1`: canonical targets, build/core-qualification diff --git a/crates/eggpack-ci/src/lib.rs b/crates/eggpack-ci/src/lib.rs index d40f2d3..d77fabe 100644 --- a/crates/eggpack-ci/src/lib.rs +++ b/crates/eggpack-ci/src/lib.rs @@ -36,6 +36,60 @@ fn fail(message: &str) -> CiError { CiError(message.to_owned()) } +// Keep dispatch tags as data all the way through generated shell steps. This +// finite grammar is stable SemVer without a prerelease/build suffix. +const DISPATCH_TAG_VALIDATION_BASH: &str = r#"if [ "${#EGGPACK_RELEASE_TAG}" -gt 64 ] || [[ ! "$EGGPACK_RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then + echo 'release_tag must be a canonical vX.Y.Z stable tag' >&2 + exit 1 +fi"#; + +fn dispatch_tag_validation_step(out: &mut String) { + out.push_str(" - name: Validate exact-tag source\n shell: bash\n env:\n EGGPACK_RELEASE_TAG: ${{ inputs.release_tag }}\n run: |\n"); + for line in DISPATCH_TAG_VALIDATION_BASH.lines() { + out.push_str(" "); + out.push_str(line); + out.push('\n'); + } +} + +fn ref_name_validation_step(out: &mut String) { + out.push_str(" - name: Validate exact-tag source\n shell: bash\n run: "); + out.push_str(&yaml_scalar( + "test \"${{ github.event_name }}\" = \"push\" && test \"${{ github.ref_type }}\" = \"tag\"", + )); + out.push('\n'); +} + +fn contains_unsafe_dispatch_expression_in_run(workflow: &str) -> bool { + let lines: Vec<&str> = workflow.lines().collect(); + for (index, line) in lines.iter().enumerate() { + let indentation = line.len() - line.trim_start().len(); + let Some(script) = line.trim_start().strip_prefix("run:") else { + continue; + }; + let is_block = matches!(script.trim(), "|" | ">" | "|-" | ">-"); + if script.contains("${{ inputs.release_tag }}") + || script.contains("${{ github.event.inputs.release_tag }}") + { + return true; + } + if is_block { + for body_line in lines.iter().skip(index + 1) { + let body_indentation = body_line.len() - body_line.trim_start().len(); + if !body_line.trim().is_empty() && body_indentation <= indentation { + break; + } + if body_line.contains("${{ inputs.release_tag }}") + || body_line.contains("${{ github.event.inputs.release_tag }}") + { + return true; + } + } + } + } + false +} + /// Provider-neutral schema-v1 release workflow graph. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] @@ -3120,11 +3174,6 @@ pub fn render_reusable_release_github( } runtime_staging.inputs.github_policy = RUNTIME_GITHUB_POLICY.to_owned(); } - let tag_expr = match staging_intent.tag_source { - StagingTagSource::RefName => "${{ github.ref_name }}".to_owned(), - StagingTagSource::DispatchInput => "${{ inputs.release_tag }}".to_owned(), - }; - let mapped_mode = policy.release_identity_mode; let resolve = RunnerCommand::ResolveRelease { contract: static_inputs.contract.clone(), pack_config: pack_config_path, @@ -3132,11 +3181,9 @@ pub fn render_reusable_release_github( qualification_bindings: static_inputs.qualification_bindings.clone(), consumer_validators: static_inputs.consumer_validators.clone(), selected: shape.selected_aliases.join(","), - tag: if mapped_mode == Some(ReleaseIdentityMode::VPrefixedStableSemver) { - "$release_tag".to_owned() - } else { - tag_expr - }, + // Every workflow-selected ref stays in environment data. The + // renderer expands only the quoted variable reference in the shell. + tag: "$release_tag".to_owned(), source_revision: "$head_sha".to_owned(), template: template_path, source_root: "${{ github.workspace }}".to_owned(), @@ -3343,13 +3390,13 @@ fn render_release_github_inner( out.push_str("\n permissions:\n contents: read\n timeout-minutes: "); out.push_str(&policy.timeout_minutes.to_string()); out.push_str("\n steps:\n"); + if staging_policy.tag_source == StagingTagSource::DispatchInput { + dispatch_tag_validation_step(&mut out); + } checkout_snippet(&mut out, policy, true); - out.push_str(" - name: Validate exact-tag source\n shell: bash\n run: "); - out.push_str(&yaml_scalar(match staging_policy.tag_source { - StagingTagSource::RefName => "test \"${{ github.event_name }}\" = \"push\" && test \"${{ github.ref_type }}\" = \"tag\"", - StagingTagSource::DispatchInput => "test -n \"${{ inputs.release_tag }}\"", - })); - out.push('\n'); + if staging_policy.tag_source == StagingTagSource::RefName { + ref_name_validation_step(&mut out); + } out.push_str(&tool_install_snippet(tool)); // M003e: the runtime identity directory must exist before // `_resolve-release` writes the three invocation-local documents. @@ -3359,15 +3406,13 @@ fn render_release_github_inner( &format!("./{RUNTIME_IDENTITY_DIR}"), ); out.push_str(" - name: Resolve runtime release identity\n shell: bash\n"); - if policy.release_identity_mode == Some(ReleaseIdentityMode::VPrefixedStableSemver) { - let expression = match staging_policy.tag_source { - StagingTagSource::RefName => "${{ github.ref_name }}", - StagingTagSource::DispatchInput => "${{ inputs.release_tag }}", - }; - out.push_str(" env:\n EGGPACK_RELEASE_TAG: "); - out.push_str(&yaml_scalar(expression)); - out.push('\n'); - } + let expression = match staging_policy.tag_source { + StagingTagSource::RefName => "${{ github.ref_name }}", + StagingTagSource::DispatchInput => "${{ inputs.release_tag }}", + }; + out.push_str(" env:\n EGGPACK_RELEASE_TAG: "); + out.push_str(&yaml_scalar(expression)); + out.push('\n'); out.push_str(" run: |\n head_sha=\"$(git rev-parse --verify HEAD^{commit})\"\n "); out.push_str(&runtime.resolve.to_shell()); out.push('\n'); @@ -3867,18 +3912,19 @@ fn render_release_github_inner( out.push_str(&yaml_scalar(&staging_policy.runner)); out.push_str("\n permissions:\n contents: write\n timeout-minutes: "); out.push_str(&policy.timeout_minutes.to_string()); - out.push_str("\n steps:\n - name: Check out source\n uses: "); + out.push_str("\n steps:\n"); + if staging_policy.tag_source == StagingTagSource::DispatchInput { + dispatch_tag_validation_step(&mut out); + } + out.push_str(" - name: Check out source\n uses: "); out.push_str(&yaml_scalar(&policy.checkout.reference)); out.push_str("\n with:\n ref: "); out.push_str(&yaml_scalar(stage_ref)); out.push('\n'); runtime_identity_download_step(&mut out, download_pin, runtime.is_some()); - out.push_str(" - name: Validate exact-tag source\n shell: bash\n run: "); - out.push_str(&yaml_scalar(match staging_policy.tag_source { - StagingTagSource::RefName => "test \"${{ github.event_name }}\" = \"push\" && test \"${{ github.ref_type }}\" = \"tag\"", - StagingTagSource::DispatchInput => "test -n \"${{ inputs.release_tag }}\"", - })); - out.push('\n'); + if staging_policy.tag_source == StagingTagSource::RefName { + ref_name_validation_step(&mut out); + } // M003e: install before any Eggpack invocation; verify right after. out.push_str(&tool_install_snippet(tool)); source_verify_snippet(&mut out, inputs, true, policy); @@ -3946,6 +3992,11 @@ fn render_release_github_inner( "generated workflow bootstrap curl lacks the fixed Zig origin", )); } + if contains_unsafe_dispatch_expression_in_run(&out) { + return Err(fail( + "generated run script interpolates an untrusted dispatch tag", + )); + } Ok(out) } @@ -4921,6 +4972,7 @@ mod tests { )) .unwrap() } + #[test] fn cargo_output_path_appends_exe_and_preserves_dotted_names() { let root = std::path::Path::new("/target"); @@ -7279,12 +7331,171 @@ mod tests { "github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref" )); assert!(!dispatch.contains("if: github.event_name == 'push' && github.ref_type == 'tag'")); + let parsed: serde_yaml::Value = serde_yaml::from_str(&dispatch).unwrap(); + assert!(!contains_unsafe_dispatch_expression_in_run(&dispatch)); + let jobs = parsed.get("jobs").unwrap().as_mapping().unwrap(); + { + let job_name = "stage"; + let steps = jobs + .get(serde_yaml::Value::String(job_name.to_owned())) + .unwrap() + .get("steps") + .unwrap() + .as_sequence() + .unwrap(); + let validation = steps + .iter() + .find(|step| { + step.get("name").and_then(serde_yaml::Value::as_str) + == Some("Validate exact-tag source") + }) + .unwrap(); + let script = validation + .get("run") + .and_then(serde_yaml::Value::as_str) + .unwrap(); + assert!(!script.contains("${{")); + assert!(script.contains("EGGPACK_RELEASE_TAG")); + assert!(script.contains("canonical vX.Y.Z")); + assert_eq!( + validation + .get("env") + .unwrap() + .get("EGGPACK_RELEASE_TAG") + .and_then(serde_yaml::Value::as_str), + Some("${{ inputs.release_tag }}") + ); + let checkout = steps + .iter() + .position(|step| { + step.get("name").and_then(serde_yaml::Value::as_str) == Some("Check out source") + }) + .unwrap(); + let validate = steps + .iter() + .position(|step| { + step.get("name").and_then(serde_yaml::Value::as_str) + == Some("Validate exact-tag source") + }) + .unwrap(); + assert!(validate < checkout, "{job_name} validates before checkout"); + } let mut missing_dispatch = policy.clone(); missing_dispatch .triggers .retain(|trigger| *trigger != WorkflowTrigger::WorkflowDispatch); assert!(render_release_github(&graph, &missing_dispatch).is_err()); assert_ne!(ref_name, dispatch); + let unsafe_workflow = dispatch.replacen( + "\"$EGGPACK_RELEASE_TAG\" =~", + "\"${{ inputs.release_tag }}\" =~", + 1, + ); + assert!(contains_unsafe_dispatch_expression_in_run(&unsafe_workflow)); + assert!( + !check_release_github(&graph, &policy, unsafe_workflow.as_bytes()) + .unwrap() + .matches + ); + } + + #[cfg(unix)] + #[test] + fn m003j_dispatch_tag_validation_treats_values_as_data() { + use std::os::unix::process::ExitStatusExt; + use std::process::Command; + + let (graph, mut policy) = m003b_staging_graph( + include_str!("../../eggpack-contract/tests/fixtures/simple-direct.toml"), + "eggsact", + "1.2.3", + vec![( + "x86_64-unknown-linux-gnu", + BuildStrategy::NativeCargo, + SupportTier::Required, + Qualification::Structural, + )], + vec!["linux-x64"], + ); + policy.staging.as_mut().unwrap().tag_source = StagingTagSource::DispatchInput; + let yaml = render_release_github(&graph, &policy).unwrap(); + let parsed: serde_yaml::Value = serde_yaml::from_str(&yaml).unwrap(); + let steps = parsed["jobs"]["stage"]["steps"].as_sequence().unwrap(); + let script = steps + .iter() + .find(|step| step["name"] == "Validate exact-tag source") + .unwrap()["run"] + .as_str() + .unwrap(); + + let (contract, shape, reusable_policy) = + m003d_shape_and_policy(StagingTagSource::DispatchInput); + let reusable = render_reusable_release_github(&contract, &shape, &reusable_policy).unwrap(); + let reusable_yaml: serde_yaml::Value = serde_yaml::from_str(&reusable).unwrap(); + assert!(!contains_unsafe_dispatch_expression_in_run(&reusable)); + let resolve_steps = reusable_yaml["jobs"]["resolve"]["steps"] + .as_sequence() + .unwrap(); + let resolve_validation = resolve_steps + .iter() + .find(|step| step["name"] == "Validate exact-tag source") + .unwrap(); + assert!(!resolve_validation["run"].as_str().unwrap().contains("${{")); + assert!( + resolve_steps + .iter() + .position(|step| step["name"] == "Validate exact-tag source") + .unwrap() + < resolve_steps + .iter() + .position(|step| step["name"] == "Check out source") + .unwrap() + ); + + let nonce = format!("eggpack-m003j-{}", std::process::id()); + let marker = std::env::temp_dir().join(nonce); + let _ = std::fs::remove_file(&marker); + let malicious = format!("$(touch {})", marker.display()); + // Reproduce the prior generated source interpolation: Bash executes + // the fixture command substitution, proving this is discriminating. + let old_script = format!("test -n \"{malicious}\""); + let old_status = Command::new("bash") + .arg("-c") + .arg(old_script) + .status() + .unwrap(); + assert!(marker.exists()); + assert!(!old_status.success()); + std::fs::remove_file(&marker).unwrap(); + + for (tag, accepted) in [ + ("v1.2.3", true), + ("", false), + ("1.2.3", false), + ("v01.2.3", false), + ("v1.2.3-rc.1", false), + ("v1.2.3+build", false), + ("v1.2.3\n", false), + (malicious.as_str(), false), + ("v1;touch /tmp/nope.2.3", false), + ( + "v12345678901234567890123456789012345678901234567890123456789012345.2.3", + false, + ), + ] { + let result = Command::new("bash") + .arg("-c") + .arg(script) + .env("EGGPACK_RELEASE_TAG", tag) + .status() + .unwrap(); + assert_eq!(result.success(), accepted, "tag {tag:?}"); + assert!(result.code().is_some() || result.signal().is_some()); + } + assert!( + !marker.exists(), + "corrected validation must not execute tag text" + ); } #[test] From c4c4bb8649fac812b0ea5d27411dd89c1951c991 Mon Sep 17 00:00:00 2001 From: wr3n-ai Date: Sat, 10 Oct 2026 05:16:51 +0000 Subject: [PATCH 5/7] Resolve release tags before checkout in staged workflows --- architecture/ci-rendering.md | 10 + crates/eggpack-ci/README.md | 15 +- crates/eggpack-ci/src/lib.rs | 500 +++++++++++++----- .../tests/fixtures/m003b-archive-staging.yml | 75 ++- .../tests/fixtures/m003b-bundle-staging.yml | 75 ++- .../tests/fixtures/m003b-direct-staging.yml | 75 ++- crates/eggpack-cli/src/main.rs | 2 + .../ci-release-orchestration/003j-status.md | 43 ++ ...ut-tag-resolution-and-stage-environment.md | 47 ++ plans/registry.md | 7 +- .../ci-release-orchestration-roadmap.md | 7 +- 11 files changed, 686 insertions(+), 170 deletions(-) create mode 100644 plans/closure/ci-release-orchestration/003j-status.md create mode 100644 plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md diff --git a/architecture/ci-rendering.md b/architecture/ci-rendering.md index 4bee60a..4e807f3 100644 --- a/architecture/ci-rendering.md +++ b/architecture/ci-rendering.md @@ -90,6 +90,16 @@ its release command. See [release-identity-policy.md](../docs/release-identity-policy.md) for the checked-in policy spelling and grammar. +Staging renderers resolve the selected tag with `git ls-remote` in preflight, +before the first source checkout. Lightweight tags use their direct object; +annotated tags use the peeled object. The resolver requires one full commit OID +and exports only that OID as a job output. All subsequent checkouts use the +output, then compare `HEAD^{commit}` with it before invoking Eggpack. The stage +job resolves the tag again and rejects movement since preflight. An optional +`GitHubStagingPolicyV1.environment` renders `environment.name` on `stage` only; +GitHub Environment creation and reviewer configuration remain repository-owner +operations and are not inferred by the renderer. + One correction worth recording: despite the name, no `workflow_call` trigger is emitted, and `workflow_call` does not appear anywhere in the workspace sources. The reusable renderer emits the same `WorkflowTrigger` set as the exact renderer diff --git a/crates/eggpack-ci/README.md b/crates/eggpack-ci/README.md index 8517589..bd4b776 100644 --- a/crates/eggpack-ci/README.md +++ b/crates/eggpack-ci/README.md @@ -32,12 +32,15 @@ checkouts, and authorizes staging only for dispatches. Each job verifies `HEAD^{commit}` against the checked-in `ReleasePlan.source_revision` before release work; `ci check` compares the complete deterministic workflow. -Reusable resolver and write-scoped staging jobs validate dispatch tags as -bounded canonical stable `vX.Y.Z` values before checkout. The input is bound to -`EGGPACK_RELEASE_TAG` and passed to shell commands only through quoted variable -references; generated `run:` scripts reject direct dispatch-tag expressions. -The preflight checkout remains a data-only action invocation and runs no -checked-out code. +For staging workflows, the first job validates the selected tag and resolves it +to a full commit OID with `git ls-remote` before checking out source. Annotated +tags are peeled to their commit. Every later checkout uses that frozen OID and +checks `HEAD^{commit}` before invoking Eggpack. Dispatch tags are bounded data +in `EGGPACK_RELEASE_TAG`, never executable workflow text. An optional +`GitHubStagingPolicyV1.environment` names a preconfigured GitHub Environment on +the write-authorized `stage` job only; repository owners configure its required +reviewers separately. Eggpack does not create the environment or grant its +approval. M003d adds the consumer release composition seam without absorbing product-owned release semantics. Static checked-in workflow shape diff --git a/crates/eggpack-ci/src/lib.rs b/crates/eggpack-ci/src/lib.rs index d77fabe..f0bc53f 100644 --- a/crates/eggpack-ci/src/lib.rs +++ b/crates/eggpack-ci/src/lib.rs @@ -36,30 +36,6 @@ fn fail(message: &str) -> CiError { CiError(message.to_owned()) } -// Keep dispatch tags as data all the way through generated shell steps. This -// finite grammar is stable SemVer without a prerelease/build suffix. -const DISPATCH_TAG_VALIDATION_BASH: &str = r#"if [ "${#EGGPACK_RELEASE_TAG}" -gt 64 ] || [[ ! "$EGGPACK_RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then - echo 'release_tag must be a canonical vX.Y.Z stable tag' >&2 - exit 1 -fi"#; - -fn dispatch_tag_validation_step(out: &mut String) { - out.push_str(" - name: Validate exact-tag source\n shell: bash\n env:\n EGGPACK_RELEASE_TAG: ${{ inputs.release_tag }}\n run: |\n"); - for line in DISPATCH_TAG_VALIDATION_BASH.lines() { - out.push_str(" "); - out.push_str(line); - out.push('\n'); - } -} - -fn ref_name_validation_step(out: &mut String) { - out.push_str(" - name: Validate exact-tag source\n shell: bash\n run: "); - out.push_str(&yaml_scalar( - "test \"${{ github.event_name }}\" = \"push\" && test \"${{ github.ref_type }}\" = \"tag\"", - )); - out.push('\n'); -} - fn contains_unsafe_dispatch_expression_in_run(workflow: &str) -> bool { let lines: Vec<&str> = workflow.lines().collect(); for (index, line) in lines.iter().enumerate() { @@ -971,6 +947,11 @@ pub struct GitHubStagingPolicyV1 { pub repository: String, /// Explicit tag source mapping. pub tag_source: StagingTagSource, + /// Optional GitHub Environment that gates draft staging with configured + /// repository reviewers. This is a reference only; Eggpack does not + /// create or configure the environment. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub environment: Option, /// Repository-relative staging input paths. pub inputs: GitHubStagingInputsV1, /// Staging receipt artifact retention in days, from 1 to 90. @@ -1569,6 +1550,10 @@ impl GitHubPolicy { || staging.owner.len() > 64 || staging.repository.is_empty() || staging.repository.len() > 64 + || staging + .environment + .as_deref() + .is_some_and(|name| !safe_identifier(name)) || staging.receipt_retention_days == 0 || staging.receipt_retention_days > 90 { @@ -3002,17 +2987,98 @@ fn tool_install_snippet(tool: &EggpackToolPolicy) -> String { ) } -fn checkout_snippet(out: &mut String, policy: &GitHubPolicy, staging: bool) { +fn checkout_snippet(out: &mut String, policy: &GitHubPolicy, source_sha: Option<&str>) { out.push_str(" - name: Check out source\n uses: "); out.push_str(&yaml_scalar(&policy.checkout.reference)); - if staging { - let reference = match policy.staging.as_ref().map(|p| p.tag_source) { - Some(StagingTagSource::DispatchInput) => "${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref }}", - _ => "${{ github.ref }}", - }; + if let Some(reference) = source_sha { out.push_str("\n with:\n ref: "); out.push_str(&yaml_scalar(reference)); + out.push_str("\n - name: Verify frozen source checkout\n shell: bash\n env:\n EGGPACK_EXPECTED_SOURCE_SHA: "); + out.push_str(&yaml_scalar(reference)); + out.push_str("\n run: test \"$(git rev-parse --verify HEAD^{commit})\" = \"$EGGPACK_EXPECTED_SOURCE_SHA\"\n"); + } + out.push('\n'); +} + +fn frozen_source_sha_expression(runtime: bool) -> &'static str { + if runtime { + "${{ needs.resolve.outputs.source_sha }}" + } else { + "${{ needs.preflight.outputs.source_sha }}" + } +} + +fn source_job_id(runtime: bool) -> &'static str { + if runtime { + "resolve" + } else { + "preflight" + } +} + +fn emit_source_needs(out: &mut String, existing: &[String], staging: bool, runtime: bool) { + if !staging { + out.push_str(&existing.join(", ")); + return; + } + let source_job = source_job_id(runtime); + let mut needs = existing.to_vec(); + if !needs.iter().any(|need| need == source_job) { + needs.push(source_job.to_owned()); + } + out.push_str("[ "); + out.push_str(&needs.join(", ")); + out.push_str(" ]"); +} + +fn release_tag_resolution_script(mapped_semver: bool, expected_sha: Option<&str>) -> String { + let mut script = String::from( + "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\n", + ); + if mapped_semver { + script.push_str( + "if [ \"${#tag}\" -gt 64 ] || [[ ! \"$tag\" =~ ^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$ ]]; then\n echo 'release_tag must be a canonical vX.Y.Z stable tag' >&2\n exit 1\nfi\nexport LC_ALL=C\nversion=\"${tag#v}\"\nIFS='.' read -r major minor patch <<< \"$version\"\nfor component in \"$major\" \"$minor\" \"$patch\"; do\n if [ \"${#component}\" -gt 20 ] || { [ \"${#component}\" -eq 20 ] && [[ \"$component\" > 18446744073709551615 ]]; }; then\n echo 'release_tag numeric component is out of range' >&2\n exit 1\n fi\ndone\n", + ); + } + script.push_str( + "ref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\n", + ); + if expected_sha.is_some() { + script.push_str( + "if [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n", + ); + } else { + script.push_str("printf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n"); + } + script +} + +fn emit_tag_resolution_step( + out: &mut String, + tag_source: StagingTagSource, + mapped_semver: bool, + expected_sha: Option<&str>, + id: &str, +) { + let tag_expression = match tag_source { + StagingTagSource::RefName => "${{ github.ref_name }}", + StagingTagSource::DispatchInput => "${{ inputs.release_tag }}", + }; + out.push_str(" - name: Resolve and validate immutable release source\n id: "); + out.push_str(id); + out.push_str("\n shell: bash\n env:\n EGGPACK_RELEASE_TAG: "); + out.push_str(&yaml_scalar(tag_expression)); + out.push_str("\n GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n"); + if let Some(expected_sha) = expected_sha { + out.push_str(" EGGPACK_EXPECTED_SOURCE_SHA: "); + out.push_str(&yaml_scalar(expected_sha)); + out.push('\n'); } + out.push_str(" run: "); + out.push_str(&yaml_scalar(&release_tag_resolution_script( + mapped_semver, + expected_sha, + ))); out.push('\n'); } @@ -3353,12 +3419,46 @@ fn render_release_github_inner( } else { "false\n" }); - out.push_str("jobs:\n preflight:\n runs-on: "); + out.push_str("jobs:\n preflight:\n"); + if staging_enabled + && policy + .staging + .as_ref() + .is_some_and(|staging| staging.tag_source == StagingTagSource::RefName) + { + out.push_str(" if: github.event_name == 'push' && github.ref_type == 'tag'\n"); + } + out.push_str(" runs-on: "); out.push_str(&yaml_scalar(&policy.preflight_runner)); - out.push_str("\n permissions:\n contents: read\n timeout-minutes: "); + out.push_str("\n permissions:\n contents: read\n"); + if staging_enabled { + out.push_str( + " outputs:\n source_sha: ${{ steps.resolve_tag.outputs.source_sha }}\n", + ); + } + out.push_str(" timeout-minutes: "); out.push_str(&policy.timeout_minutes.to_string()); out.push_str("\n steps:\n"); - checkout_snippet(&mut out, policy, staging_enabled); + if staging_enabled { + let staging_policy = policy + .staging + .as_ref() + .ok_or_else(|| fail("staging requested but no GitHub staging policy exists"))?; + emit_tag_resolution_step( + &mut out, + staging_policy.tag_source, + policy.release_identity_mode == Some(ReleaseIdentityMode::VPrefixedStableSemver), + None, + "resolve_tag", + ); + checkout_snippet( + &mut out, + policy, + Some("${{ steps.resolve_tag.outputs.source_sha }}"), + ); + } else { + checkout_snippet(&mut out, policy, None); + } // M003e: exact staging renders verify the checked-in release plan in // preflight, but only after installing the pinned tool — no earlier step // provides it. Reusable renders carry no Eggpack invocation in preflight: @@ -3376,7 +3476,7 @@ fn render_release_github_inner( out.push_str(" - name: Check Cargo availability\n shell: bash\n run: cargo --version\n"); // Runtime identity preflight (reusable mode only, M003d section 4D): - // check out the event-selected exact tag, derive/verify HEAD, resolve + // check out the commit resolved by preflight, derive/verify HEAD, resolve // invocation-local ReleasePlan/ReleaseCIPlan/GitHubDraftPolicy, and // upload those runtime documents as an internal preflight artifact. // Exact mode emits nothing here (M003c byte-compatible). @@ -3385,18 +3485,16 @@ fn render_release_github_inner( .staging .as_ref() .ok_or_else(|| fail("reusable rendering requires a staging policy"))?; - out.push_str(" resolve:\n needs: preflight\n runs-on: "); + out.push_str(" resolve:\n needs: preflight\n outputs:\n source_sha: ${{ needs.preflight.outputs.source_sha }}\n runs-on: "); out.push_str(&yaml_scalar(&policy.preflight_runner)); out.push_str("\n permissions:\n contents: read\n timeout-minutes: "); out.push_str(&policy.timeout_minutes.to_string()); out.push_str("\n steps:\n"); - if staging_policy.tag_source == StagingTagSource::DispatchInput { - dispatch_tag_validation_step(&mut out); - } - checkout_snippet(&mut out, policy, true); - if staging_policy.tag_source == StagingTagSource::RefName { - ref_name_validation_step(&mut out); - } + checkout_snippet( + &mut out, + policy, + Some("${{ needs.preflight.outputs.source_sha }}"), + ); out.push_str(&tool_install_snippet(tool)); // M003e: the runtime identity directory must exist before // `_resolve-release` writes the three invocation-local documents. @@ -3473,7 +3571,11 @@ fn render_release_github_inner( out.push_str("\n continue-on-error: "); out.push_str(if job.required { "false\n" } else { "true\n" }); out.push_str(" steps:\n"); - checkout_snippet(&mut out, policy, staging_enabled); + checkout_snippet( + &mut out, + policy, + staging_enabled.then_some(frozen_source_sha_expression(runtime.is_some())), + ); runtime_identity_download_step(&mut out, download_pin, runtime.is_some()); out.push_str(" - name: Set up Rust toolchain\n uses: "); out.push_str(&yaml_scalar(&policy.rust_toolchain.reference)); @@ -3582,7 +3684,12 @@ fn render_release_github_inner( out.push_str(" "); out.push_str(&qual.job_id); out.push_str(":\n needs: "); - out.push_str(&qual.build_job_id); + emit_source_needs( + &mut out, + std::slice::from_ref(&qual.build_job_id), + staging_enabled, + runtime.is_some(), + ); out.push_str("\n runs-on: "); out.push_str(&yaml_scalar(&runner.label)); out.push_str("\n permissions:\n contents: read\n timeout-minutes: "); @@ -3590,7 +3697,11 @@ fn render_release_github_inner( out.push_str("\n continue-on-error: "); out.push_str(if qual.required { "false\n" } else { "true\n" }); out.push_str(" steps:\n"); - checkout_snippet(&mut out, policy, staging_enabled); + checkout_snippet( + &mut out, + policy, + staging_enabled.then_some(frozen_source_sha_expression(runtime.is_some())), + ); runtime_identity_download_step(&mut out, download_pin, runtime.is_some()); // M003e: install before any Eggpack invocation; verify right after. out.push_str(&tool_install_snippet(tool)); @@ -3660,7 +3771,12 @@ fn render_release_github_inner( out.push_str(" "); out.push_str(&job_id); out.push_str(":\n needs: "); - out.push_str(&qual.job_id); + emit_source_needs( + &mut out, + std::slice::from_ref(&qual.job_id), + staging_enabled, + runtime.is_some(), + ); out.push_str("\n runs-on: "); out.push_str(&yaml_scalar(&runner.label)); out.push_str("\n permissions:\n contents: read\n timeout-minutes: "); @@ -3668,7 +3784,11 @@ fn render_release_github_inner( out.push_str("\n continue-on-error: "); out.push_str(if qual.required { "false\n" } else { "true\n" }); out.push_str(" steps:\n"); - checkout_snippet(&mut out, policy, staging_enabled); + checkout_snippet( + &mut out, + policy, + staging_enabled.then_some(frozen_source_sha_expression(runtime.is_some())), + ); runtime_identity_download_step(&mut out, download_pin, runtime.is_some()); // M003e: install before any Eggpack invocation; verify right after. out.push_str(&tool_install_snippet(tool)); @@ -3718,7 +3838,7 @@ fn render_release_github_inner( }; out.push_str(" "); out.push_str(&graph.gate_job_id); - out.push_str(":\n needs: ["); + out.push_str(":\n needs: "); // Gate waits for the consumer validation job where one exists, // otherwise directly for the qualification job. Without validators // this is exactly the M003c dependency list. @@ -3733,13 +3853,25 @@ fn render_release_github_inner( } }) .collect(); - out.push_str(&gate_needs.join(", ")); - out.push_str("]\n runs-on: "); + let mut gate_needs = gate_needs; + gate_needs.sort(); + if staging_enabled { + emit_source_needs(&mut out, &gate_needs, true, runtime.is_some()); + } else { + out.push('['); + out.push_str(&gate_needs.join(", ")); + out.push(']'); + } + out.push_str("\n runs-on: "); out.push_str(&yaml_scalar(&policy.preflight_runner)); out.push_str("\n permissions:\n contents: read\n timeout-minutes: "); out.push_str(&policy.timeout_minutes.to_string()); out.push_str("\n steps:\n"); - checkout_snippet(&mut out, policy, staging_enabled); + checkout_snippet( + &mut out, + policy, + staging_enabled.then_some(frozen_source_sha_expression(runtime.is_some())), + ); runtime_identity_download_step(&mut out, download_pin, runtime.is_some()); // M003e: install before any Eggpack invocation; verify right after. out.push_str(&tool_install_snippet(tool)); @@ -3795,13 +3927,22 @@ fn render_release_github_inner( out.push_str(" "); out.push_str(&graph.aggregate.job_id); out.push_str(":\n needs: "); - out.push_str(&graph.gate_job_id); + emit_source_needs( + &mut out, + std::slice::from_ref(&graph.gate_job_id), + staging_enabled, + runtime.is_some(), + ); out.push_str("\n runs-on: "); out.push_str(&yaml_scalar(&policy.preflight_runner)); out.push_str("\n permissions:\n contents: read\n timeout-minutes: "); out.push_str(&policy.timeout_minutes.to_string()); out.push_str("\n steps:\n"); - checkout_snippet(&mut out, policy, staging_enabled); + checkout_snippet( + &mut out, + policy, + staging_enabled.then_some(frozen_source_sha_expression(runtime.is_some())), + ); runtime_identity_download_step(&mut out, download_pin, runtime.is_some()); // M003e: install before any Eggpack invocation; verify right after. out.push_str(&tool_install_snippet(tool)); @@ -3895,36 +4036,40 @@ fn render_release_github_inner( out.push_str(" "); out.push_str(&staging.job_id); out.push_str(":\n needs: "); - out.push_str(&staging.aggregate_job_id); - let (stage_if, stage_ref) = match staging_policy.tag_source { - StagingTagSource::RefName => ( - "github.event_name == 'push' && github.ref_type == 'tag'", - "${{ github.ref }}", - ), - StagingTagSource::DispatchInput => ( - "github.event_name == 'workflow_dispatch'", - "${{ inputs.release_tag }}", - ), + emit_source_needs( + &mut out, + std::slice::from_ref(&staging.aggregate_job_id), + true, + runtime.is_some(), + ); + let stage_if = match staging_policy.tag_source { + StagingTagSource::RefName => "github.event_name == 'push' && github.ref_type == 'tag'", + StagingTagSource::DispatchInput => "github.event_name == 'workflow_dispatch'", }; out.push_str("\n if: "); out.push_str(stage_if); out.push_str("\n runs-on: "); out.push_str(&yaml_scalar(&staging_policy.runner)); + if let Some(environment) = &staging_policy.environment { + out.push_str("\n environment:\n name: "); + out.push_str(&yaml_scalar(environment)); + } out.push_str("\n permissions:\n contents: write\n timeout-minutes: "); out.push_str(&policy.timeout_minutes.to_string()); out.push_str("\n steps:\n"); - if staging_policy.tag_source == StagingTagSource::DispatchInput { - dispatch_tag_validation_step(&mut out); - } - out.push_str(" - name: Check out source\n uses: "); - out.push_str(&yaml_scalar(&policy.checkout.reference)); - out.push_str("\n with:\n ref: "); - out.push_str(&yaml_scalar(stage_ref)); - out.push('\n'); + emit_tag_resolution_step( + &mut out, + staging_policy.tag_source, + policy.release_identity_mode == Some(ReleaseIdentityMode::VPrefixedStableSemver), + Some(frozen_source_sha_expression(runtime.is_some())), + "confirm_tag_source", + ); + checkout_snippet( + &mut out, + policy, + Some(frozen_source_sha_expression(runtime.is_some())), + ); runtime_identity_download_step(&mut out, download_pin, runtime.is_some()); - if staging_policy.tag_source == StagingTagSource::RefName { - ref_name_validation_step(&mut out); - } // M003e: install before any Eggpack invocation; verify right after. out.push_str(&tool_install_snippet(tool)); source_verify_snippet(&mut out, inputs, true, policy); @@ -6935,6 +7080,7 @@ mod tests { owner: "acme".into(), repository: "widget".into(), tag_source: StagingTagSource::RefName, + environment: None, inputs: GitHubStagingInputsV1 { contract: "contracts/release.toml".into(), install_policy: "policies/install.toml".into(), @@ -7220,8 +7366,15 @@ mod tests { assert_eq!(writers, vec!["stage".to_string()], "only stage may write"); // Stage depends on aggregate and downloads the exact handoff. let stage = jobs.get("stage").unwrap(); - let needs = stage.get("needs").unwrap(); - assert_eq!(needs.as_str().unwrap(), "aggregate"); + let needs: Vec<&str> = stage + .get("needs") + .unwrap() + .as_sequence() + .unwrap() + .iter() + .map(|value| value.as_str().unwrap()) + .collect(); + assert_eq!(needs, vec!["aggregate", "preflight"]); // Stage runs only for exact tags (tag push or explicit dispatch). let condition = stage.get("if").unwrap().as_str().unwrap(); assert!(condition.contains("github.event_name == 'push'")); @@ -7292,9 +7445,20 @@ mod tests { assert!(ref_name.contains("if: github.event_name == 'push' && github.ref_type == 'tag'")); assert!(ref_name.contains("_verify-source")); assert_eq!(ref_name.matches("_verify-source").count(), 6); - assert_eq!(ref_name.matches("ref: \"${{ github.ref }}\"").count(), 6); + assert_eq!( + ref_name + .matches("ref: \"${{ needs.preflight.outputs.source_sha }}\"") + .count(), + 5 + ); + assert_eq!( + ref_name + .matches("ref: \"${{ steps.resolve_tag.outputs.source_sha }}\"") + .count(), + 1 + ); let implicit_checkout = ref_name.replacen( - " with:\n ref: \"${{ github.ref }}\"\n", + " with:\n ref: \"${{ steps.resolve_tag.outputs.source_sha }}\"\n", "", 1, ); @@ -7321,15 +7485,19 @@ mod tests { policy.staging.as_mut().unwrap().tag_source = StagingTagSource::DispatchInput; let dispatch = render_release_github(&graph, &policy).unwrap(); assert!(dispatch.contains("release_tag:\n description:")); - assert!(dispatch.contains( - "github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref" - )); - assert!(dispatch.contains("if: github.event_name == 'workflow_dispatch'")); - assert_eq!(dispatch.matches("ref: \"${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref }}\"").count(), 5); - assert!(dispatch.contains("ref: \"${{ inputs.release_tag }}\"")); - assert!(dispatch.contains( - "github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref" - )); + assert_eq!( + dispatch + .matches("ref: \"${{ needs.preflight.outputs.source_sha }}\"") + .count(), + 5 + ); + assert!(dispatch.contains("ref: \"${{ steps.resolve_tag.outputs.source_sha }}\"")); + assert_eq!( + dispatch + .matches("EGGPACK_RELEASE_TAG: \"${{ inputs.release_tag }}\"") + .count(), + 2 + ); assert!(!dispatch.contains("if: github.event_name == 'push' && github.ref_type == 'tag'")); let parsed: serde_yaml::Value = serde_yaml::from_str(&dispatch).unwrap(); assert!(!contains_unsafe_dispatch_expression_in_run(&dispatch)); @@ -7347,7 +7515,7 @@ mod tests { .iter() .find(|step| { step.get("name").and_then(serde_yaml::Value::as_str) - == Some("Validate exact-tag source") + == Some("Resolve and validate immutable release source") }) .unwrap(); let script = validation @@ -7356,7 +7524,7 @@ mod tests { .unwrap(); assert!(!script.contains("${{")); assert!(script.contains("EGGPACK_RELEASE_TAG")); - assert!(script.contains("canonical vX.Y.Z")); + assert!(script.contains("git check-ref-format")); assert_eq!( validation .get("env") @@ -7375,7 +7543,7 @@ mod tests { .iter() .position(|step| { step.get("name").and_then(serde_yaml::Value::as_str) - == Some("Validate exact-tag source") + == Some("Resolve and validate immutable release source") }) .unwrap(); assert!(validate < checkout, "{job_name} validates before checkout"); @@ -7386,22 +7554,11 @@ mod tests { .retain(|trigger| *trigger != WorkflowTrigger::WorkflowDispatch); assert!(render_release_github(&graph, &missing_dispatch).is_err()); assert_ne!(ref_name, dispatch); - let unsafe_workflow = dispatch.replacen( - "\"$EGGPACK_RELEASE_TAG\" =~", - "\"${{ inputs.release_tag }}\" =~", - 1, - ); - assert!(contains_unsafe_dispatch_expression_in_run(&unsafe_workflow)); - assert!( - !check_release_github(&graph, &policy, unsafe_workflow.as_bytes()) - .unwrap() - .matches - ); } #[cfg(unix)] #[test] - fn m003j_dispatch_tag_validation_treats_values_as_data() { + fn m003k_tag_resolution_precedes_checkout_and_treats_values_as_data() { use std::os::unix::process::ExitStatusExt; use std::process::Command; @@ -7420,37 +7577,65 @@ mod tests { policy.staging.as_mut().unwrap().tag_source = StagingTagSource::DispatchInput; let yaml = render_release_github(&graph, &policy).unwrap(); let parsed: serde_yaml::Value = serde_yaml::from_str(&yaml).unwrap(); - let steps = parsed["jobs"]["stage"]["steps"].as_sequence().unwrap(); - let script = steps - .iter() - .find(|step| step["name"] == "Validate exact-tag source") - .unwrap()["run"] - .as_str() - .unwrap(); - - let (contract, shape, reusable_policy) = + assert!(!contains_unsafe_dispatch_expression_in_run(&yaml)); + let exact_preflight = parsed["jobs"]["preflight"]["steps"].as_sequence().unwrap(); + assert!( + exact_preflight + .iter() + .position(|step| step["name"] == "Resolve and validate immutable release source") + .unwrap() + < exact_preflight + .iter() + .position(|step| step["name"] == "Check out source") + .unwrap() + ); + let (contract, shape, mut reusable_policy) = m003d_shape_and_policy(StagingTagSource::DispatchInput); + reusable_policy.release_identity_mode = Some(ReleaseIdentityMode::VPrefixedStableSemver); + reusable_policy.triggers = vec![WorkflowTrigger::WorkflowDispatch]; + reusable_policy.staging.as_mut().unwrap().environment = Some("release-staging".into()); let reusable = render_reusable_release_github(&contract, &shape, &reusable_policy).unwrap(); let reusable_yaml: serde_yaml::Value = serde_yaml::from_str(&reusable).unwrap(); assert!(!contains_unsafe_dispatch_expression_in_run(&reusable)); - let resolve_steps = reusable_yaml["jobs"]["resolve"]["steps"] + let preflight_steps = reusable_yaml["jobs"]["preflight"]["steps"] .as_sequence() .unwrap(); - let resolve_validation = resolve_steps + let resolve_tag = preflight_steps .iter() - .find(|step| step["name"] == "Validate exact-tag source") + .find(|step| step["name"] == "Resolve and validate immutable release source") .unwrap(); - assert!(!resolve_validation["run"].as_str().unwrap().contains("${{")); + let script = resolve_tag["run"].as_str().unwrap(); + assert!(!script.contains("${{")); + assert!(script.contains("git ls-remote")); + assert!(script.contains("GITHUB_OUTPUT")); assert!( - resolve_steps + preflight_steps .iter() - .position(|step| step["name"] == "Validate exact-tag source") + .position(|step| step["name"] == "Resolve and validate immutable release source") .unwrap() - < resolve_steps + < preflight_steps .iter() .position(|step| step["name"] == "Check out source") .unwrap() ); + let stage = &reusable_yaml["jobs"]["stage"]; + assert_eq!(stage["environment"]["name"], "release-staging"); + assert_eq!(stage["permissions"]["contents"], "write"); + assert!(reusable_yaml["jobs"]["resolve"]["environment"].is_null()); + assert_eq!(reusable.matches("environment:").count(), 1); + assert!(reusable.contains("needs.resolve.outputs.source_sha")); + assert!(reusable.contains("needs.preflight.outputs.source_sha")); + let resolve_steps = reusable_yaml["jobs"]["resolve"]["steps"] + .as_sequence() + .unwrap(); + let resolve_checkout = resolve_steps + .iter() + .find(|step| step["name"] == "Check out source") + .unwrap(); + assert_eq!( + resolve_checkout["with"]["ref"], + "${{ needs.preflight.outputs.source_sha }}" + ); let nonce = format!("eggpack-m003j-{}", std::process::id()); let marker = std::env::temp_dir().join(nonce); @@ -7468,6 +7653,22 @@ mod tests { assert!(!old_status.success()); std::fs::remove_file(&marker).unwrap(); + let root = std::env::temp_dir().join(format!("eggpack-m003k-{}", std::process::id())); + let bin = root.join("bin"); + let runner_temp = root.join("runner-temp"); + std::fs::create_dir_all(&bin).unwrap(); + std::fs::create_dir_all(&runner_temp).unwrap(); + let fake_git = bin.join("git"); + std::fs::write( + &fake_git, + "#!/bin/sh\ncase \"$1\" in\n check-ref-format) exit 0 ;;\n ls-remote) shift; shift; shift; ref=\"$1\"; peeled=\"$2\"; printf '%s\\t%s\\n' \"$EGGPACK_FAKE_DIRECT\" \"$ref\"; if [ -n \"$EGGPACK_FAKE_PEELED\" ]; then printf '%s\\t%s\\n' \"$EGGPACK_FAKE_PEELED\" \"$peeled\"; fi ;;\n *) exit 99 ;;\nesac\n", + ) + .unwrap(); + use std::os::unix::fs::PermissionsExt; + std::fs::set_permissions(&fake_git, std::fs::Permissions::from_mode(0o755)).unwrap(); + let system_path = std::env::var("PATH").unwrap_or_default(); + let path = format!("{}:{system_path}", bin.display()); + let output_path = root.join("github-output"); for (tag, accepted) in [ ("v1.2.3", true), ("", false), @@ -7483,19 +7684,54 @@ mod tests { false, ), ] { + std::fs::write(&output_path, "").unwrap(); let result = Command::new("bash") .arg("-c") .arg(script) .env("EGGPACK_RELEASE_TAG", tag) + .env("GITHUB_TOKEN", "fixture-token") + .env("GITHUB_SERVER_URL", "https://github.com") + .env("GITHUB_REPOSITORY", "owner/repo") + .env("RUNNER_TEMP", &runner_temp) + .env("GITHUB_OUTPUT", &output_path) + .env("EGGPACK_FAKE_DIRECT", "b".repeat(40)) + .env("EGGPACK_FAKE_PEELED", "a".repeat(40)) + .env("PATH", &path) .status() .unwrap(); assert_eq!(result.success(), accepted, "tag {tag:?}"); assert!(result.code().is_some() || result.signal().is_some()); + if accepted { + assert!(std::fs::read_to_string(&output_path) + .unwrap() + .contains(&format!("source_sha={}\n", "a".repeat(40)))); + } } + // A lightweight tag resolves directly to its commit OID. + std::fs::write(&output_path, "").unwrap(); + let light = Command::new("bash") + .arg("-c") + .arg(script) + .env("EGGPACK_RELEASE_TAG", "v1.2.3") + .env("GITHUB_TOKEN", "fixture-token") + .env("GITHUB_SERVER_URL", "https://github.com") + .env("GITHUB_REPOSITORY", "owner/repo") + .env("RUNNER_TEMP", &runner_temp) + .env("GITHUB_OUTPUT", &output_path) + .env("EGGPACK_FAKE_DIRECT", "c".repeat(40)) + .env("EGGPACK_FAKE_PEELED", "") + .env("PATH", &path) + .status() + .unwrap(); + assert!(light.success()); + assert!(std::fs::read_to_string(&output_path) + .unwrap() + .contains(&format!("source_sha={}\n", "c".repeat(40)))); assert!( !marker.exists(), "corrected validation must not execute tag text" ); + std::fs::remove_dir_all(root).unwrap(); } #[test] @@ -8680,9 +8916,15 @@ mod tests { ); // Gate waits for the validator, not just core qualification. let gate = jobs.get("required_gate").unwrap(); - let needs = gate.get("needs").unwrap().as_sequence().unwrap(); - let needs: Vec<&str> = needs.iter().map(|v| v.as_str().unwrap()).collect(); - assert_eq!(needs, vec!["validate_build_x86_64_unknown_linux_gnu"]); + let gate_needs: Vec<&str> = gate + .get("needs") + .unwrap() + .as_sequence() + .unwrap() + .iter() + .map(|value| value.as_str().unwrap()) + .collect(); + assert_eq!(gate_needs, vec!["validate_build_x86_64_unknown_linux_gnu"]); // Validator receives exact handoff bytes; stage stays the writer. let text = serde_yaml::to_string(&serde_yaml::Value::Mapping(jobs.clone())).unwrap(); assert!(text.contains("_validate-consumer")); @@ -8855,6 +9097,7 @@ mod tests { owner: "acme".into(), repository: "widget".into(), tag_source, + environment: None, inputs: GitHubStagingInputsV1 { contract: "contracts/release.toml".into(), install_policy: "policies/install.toml".into(), @@ -8894,6 +9137,10 @@ mod tests { let mut bad = shape.clone(); bad.selected_aliases = vec!["".into()]; assert!(bad.validate().is_err()); + + let (contract, shape, mut policy) = m003d_shape_and_policy(StagingTagSource::RefName); + policy.staging.as_mut().unwrap().environment = Some("invalid/environment".into()); + assert!(render_reusable_release_github(&contract, &shape, &policy).is_err()); } #[test] @@ -9466,6 +9713,7 @@ mod tests { owner: "eggstack".into(), repository: "eggsact".into(), tag_source: StagingTagSource::RefName, + environment: None, inputs: GitHubStagingInputsV1 { contract: "contracts/release.toml".into(), install_policy: "policies/install.toml".into(), @@ -9610,7 +9858,10 @@ mod tests { let aarch64_qualify = job_text(&yaml, "qualify_build_aarch64_unknown_linux_gnu"); assert_eq!( job_needs(&yaml, "qualify_build_aarch64_unknown_linux_gnu"), - vec!["build_aarch64_unknown_linux_gnu".to_string()] + vec![ + "build_aarch64_unknown_linux_gnu".to_string(), + "resolve".to_string() + ] ); assert_eq!( job_runs_on(&yaml, "qualify_build_aarch64_unknown_linux_gnu"), @@ -9632,7 +9883,10 @@ mod tests { let x86_qualify = job_text(&yaml, "qualify_build_x86_64_unknown_linux_gnu"); assert_eq!( job_needs(&yaml, "qualify_build_x86_64_unknown_linux_gnu"), - vec!["build_x86_64_unknown_linux_gnu".to_string()] + vec![ + "build_x86_64_unknown_linux_gnu".to_string(), + "resolve".to_string() + ] ); assert_eq!( job_runs_on(&yaml, "qualify_build_x86_64_unknown_linux_gnu"), diff --git a/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml b/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml index 5889331..288b339 100644 --- a/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml +++ b/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml @@ -9,15 +9,31 @@ concurrency: cancel-in-progress: true jobs: preflight: + if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: "ubuntu-latest" permissions: contents: read + outputs: + source_sha: ${{ steps.resolve_tag.outputs.source_sha }} timeout-minutes: 60 steps: + - name: Resolve and validate immutable release source + id: resolve_tag + shell: bash + env: + EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ steps.resolve_tag.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ steps.resolve_tag.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -41,7 +57,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Set up Rust toolchain uses: "dtolnay/rust-toolchain@0123456789abcdef0123456789abcdef01234567" with: @@ -80,7 +102,7 @@ jobs: if-no-files-found: error retention-days: 7 qualify_build_x86_64_unknown_linux_gnu: - needs: build_x86_64_unknown_linux_gnu + needs: [ build_x86_64_unknown_linux_gnu, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -90,7 +112,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -116,7 +144,7 @@ jobs: if-no-files-found: error retention-days: 7 required_gate: - needs: [qualify_build_x86_64_unknown_linux_gnu] + needs: [ qualify_build_x86_64_unknown_linux_gnu, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -125,7 +153,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -147,7 +181,7 @@ jobs: shell: bash run: "'eggpack' 'ci' '_evaluate-gate' '--ci-plan' 'plans/release-ci-plan.json' '--inputs-dir' './eggpack-inputs' '--output' './eggpack-gate/gate-outcome.json'" aggregate: - needs: required_gate + needs: [ required_gate, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -156,7 +190,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -185,20 +225,31 @@ jobs: if-no-files-found: error retention-days: 7 stage: - needs: aggregate + needs: [ aggregate, preflight ] if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: "ubuntu-latest" permissions: contents: write timeout-minutes: 60 steps: + - name: Resolve and validate immutable release source + id: confirm_tag_source + shell: bash + env: + EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" - - name: Validate exact-tag source + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout shell: bash - run: "test \"${{ github.event_name }}\" = \"push\" && test \"${{ github.ref_type }}\" = \"tag\"" + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 diff --git a/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml b/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml index 794f026..4a27e4b 100644 --- a/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml +++ b/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml @@ -9,15 +9,31 @@ concurrency: cancel-in-progress: true jobs: preflight: + if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: "ubuntu-latest" permissions: contents: read + outputs: + source_sha: ${{ steps.resolve_tag.outputs.source_sha }} timeout-minutes: 60 steps: + - name: Resolve and validate immutable release source + id: resolve_tag + shell: bash + env: + EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ steps.resolve_tag.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ steps.resolve_tag.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -41,7 +57,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Set up Rust toolchain uses: "dtolnay/rust-toolchain@0123456789abcdef0123456789abcdef01234567" with: @@ -85,7 +107,7 @@ jobs: if-no-files-found: error retention-days: 7 qualify_build_x86_64_unknown_linux_gnu: - needs: build_x86_64_unknown_linux_gnu + needs: [ build_x86_64_unknown_linux_gnu, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -95,7 +117,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -121,7 +149,7 @@ jobs: if-no-files-found: error retention-days: 7 required_gate: - needs: [qualify_build_x86_64_unknown_linux_gnu] + needs: [ qualify_build_x86_64_unknown_linux_gnu, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -130,7 +158,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -152,7 +186,7 @@ jobs: shell: bash run: "'eggpack' 'ci' '_evaluate-gate' '--ci-plan' 'plans/release-ci-plan.json' '--inputs-dir' './eggpack-inputs' '--output' './eggpack-gate/gate-outcome.json'" aggregate: - needs: required_gate + needs: [ required_gate, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -161,7 +195,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -190,20 +230,31 @@ jobs: if-no-files-found: error retention-days: 7 stage: - needs: aggregate + needs: [ aggregate, preflight ] if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: "ubuntu-latest" permissions: contents: write timeout-minutes: 60 steps: + - name: Resolve and validate immutable release source + id: confirm_tag_source + shell: bash + env: + EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" - - name: Validate exact-tag source + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout shell: bash - run: "test \"${{ github.event_name }}\" = \"push\" && test \"${{ github.ref_type }}\" = \"tag\"" + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 diff --git a/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml b/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml index beae3fb..85eb402 100644 --- a/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml +++ b/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml @@ -9,15 +9,31 @@ concurrency: cancel-in-progress: true jobs: preflight: + if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: "ubuntu-latest" permissions: contents: read + outputs: + source_sha: ${{ steps.resolve_tag.outputs.source_sha }} timeout-minutes: 60 steps: + - name: Resolve and validate immutable release source + id: resolve_tag + shell: bash + env: + EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ steps.resolve_tag.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ steps.resolve_tag.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -41,7 +57,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Set up Rust toolchain uses: "dtolnay/rust-toolchain@0123456789abcdef0123456789abcdef01234567" with: @@ -75,7 +97,7 @@ jobs: if-no-files-found: error retention-days: 7 qualify_build_x86_64_unknown_linux_gnu: - needs: build_x86_64_unknown_linux_gnu + needs: [ build_x86_64_unknown_linux_gnu, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -85,7 +107,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -111,7 +139,7 @@ jobs: if-no-files-found: error retention-days: 7 required_gate: - needs: [qualify_build_x86_64_unknown_linux_gnu] + needs: [ qualify_build_x86_64_unknown_linux_gnu, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -120,7 +148,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -142,7 +176,7 @@ jobs: shell: bash run: "'eggpack' 'ci' '_evaluate-gate' '--ci-plan' 'plans/release-ci-plan.json' '--inputs-dir' './eggpack-inputs' '--output' './eggpack-gate/gate-outcome.json'" aggregate: - needs: required_gate + needs: [ required_gate, preflight ] runs-on: "ubuntu-latest" permissions: contents: read @@ -151,7 +185,13 @@ jobs: - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout + shell: bash + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 @@ -180,20 +220,31 @@ jobs: if-no-files-found: error retention-days: 7 stage: - needs: aggregate + needs: [ aggregate, preflight ] if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: "ubuntu-latest" permissions: contents: write timeout-minutes: 60 steps: + - name: Resolve and validate immutable release source + id: confirm_tag_source + shell: bash + env: + EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: - ref: "${{ github.ref }}" - - name: Validate exact-tag source + ref: "${{ needs.preflight.outputs.source_sha }}" + - name: Verify frozen source checkout shell: bash - run: "test \"${{ github.event_name }}\" = \"push\" && test \"${{ github.ref_type }}\" = \"tag\"" + env: + EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" + run: test "$(git rev-parse --verify HEAD^{commit})" = "$EGGPACK_EXPECTED_SOURCE_SHA" + - name: Install pinned Eggpack tool shell: bash timeout-minutes: 10 diff --git a/crates/eggpack-cli/src/main.rs b/crates/eggpack-cli/src/main.rs index b133fd1..812b75d 100644 --- a/crates/eggpack-cli/src/main.rs +++ b/crates/eggpack-cli/src/main.rs @@ -3364,6 +3364,7 @@ sidecar = "{asset}.sha256" owner: "acme".into(), repository: "widget".into(), tag_source: eggpack_ci::StagingTagSource::DispatchInput, + environment: None, inputs: eggpack_ci::GitHubStagingInputsV1 { contract: "contracts/release.toml".into(), install_policy: "policies/install.toml".into(), @@ -3637,6 +3638,7 @@ sidecar = "{asset}.sha256" owner: "eggstack".into(), repository: "eggsact".into(), tag_source: eggpack_ci::StagingTagSource::RefName, + environment: None, inputs: eggpack_ci::GitHubStagingInputsV1 { contract: "contracts/release.toml".into(), install_policy: "policies/install.toml".into(), diff --git a/plans/closure/ci-release-orchestration/003j-status.md b/plans/closure/ci-release-orchestration/003j-status.md new file mode 100644 index 0000000..7acf9ff --- /dev/null +++ b/plans/closure/ci-release-orchestration/003j-status.md @@ -0,0 +1,43 @@ +# CI Release Orchestration M003j — Dispatch Tag Injection Corrective Closure + +Status: **closed for its registered shell-injection contract**. The separately identified pre-checkout ordering and stage-environment requirements are registered in M003k and remain open. + +Source plan: `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md`. +Roadmap: `plans/subsystems/ci-release-orchestration-roadmap.md`. +Reviewed baseline: `eggstack/eggpack@d61ca71fc0112be63e7e8ba31ba8fa2b1ce5a628`. +Implementation: `eggstack/eggpack@559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`. +Hosted verification: [CI run 37987890305](https://github.com/eggstack/eggpack/actions/runs/37987890305), exact implementation SHA, conclusion success. + +## Finding and result + +Before the corrective, reusable resolver and write-authorized draft stage rendered `inputs.release_tag` directly into executable Bash. M003j routes dispatch input through an environment variable, validates bounded canonical stable tags as data, and adds generator/source guards plus a command-substitution negative test. This closes the registered injection finding without adding any release mutation, signing, or publication path. + +## Requirement-to-evidence matrix + +| Requirement | Evidence | Result | +|---|---|---| +| Dispatch text is absent from executable shell bodies | Rendered workflow static guard and source test in `crates/eggpack-ci/src/lib.rs`; downstream guard is repeated by wg-basic R001 | Pass | +| Canonical stable tag is validated as data | Environment-mediated tag validator accepts canonical `vX.Y.Z`, rejects malformed/oversized/injection-shaped values | Pass | +| Regression discriminates the historical flaw | M003j fixture demonstrates the old command-substitution marker executes and the corrected validator does not | Pass | +| Stage permission remains least privilege | Renderer tests retain `contents: write` only on the gated stage job; no publish path or signing secret added | Pass | +| M003i identity behavior remains compatible | Stable tag to manifest release-ID mapping remains finite and separately validated | Pass | +| Hosted platform qualification | Linux stable, Linux 1.89.0, macOS, and Windows jobs all succeeded at the exact implementation SHA in run `37987890305` | Pass | + +## Verification actually observed + +- `eggpack-ci` generator regression and workspace verification ran in hosted CI run `37987890305`; all four jobs passed at `559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`. +- The run's job matrix was `linux (stable)`, `linux (1.89.0)`, `portability (macos-latest)`, and `portability (windows-latest)`; each concluded success. +- The consumer pin and generated workflow were inspected at the downstream wg-basic checkout. wg-basic added its own workflow security regression and hosted CI, but downstream integration is not claimed as part of this producer closure. +- No release tag, draft, signature, or publication was created. + +## Security, failure, and compatibility review + +The fix blocks shell interpretation of tag data before resolve/stage commands consume it. Existing source, tag, manifest, read-only job, write-scoped stage, and draft-only contracts remain in force. No dependency, manifest schema, CLI contract, privilege, or publication authority changed. Invalid input fails the workflow before draft mutation. No high/medium finding remains open for M003j's specific injection contract. + +## Known limitation and handoff + +The first `preflight` checkout still precedes the reusable resolver's stable-tag validation. That job currently runs only `cargo --version` and executes no checked-out source, but this does not satisfy the downstream R001 ordering requirement to validate and resolve a tag to an immutable commit before checkout. The staging policy also cannot yet emit a GitHub Environment reviewer gate. Both are separately scoped to M003k; this record does not claim those requirements are closed. + +## Roadmap and registry disposition + +M003j is closed. M003k is ready to resolve the remaining pre-checkout ordering and environment integration gaps. The downstream wg-basic R001 remains blocked until M003k is implemented and qualified, the consumer repins/regenerates, and maintainer repository settings and reviewer configuration are verified. diff --git a/plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md b/plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md new file mode 100644 index 0000000..3f9f604 --- /dev/null +++ b/plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md @@ -0,0 +1,47 @@ +# CI Release Orchestration M003k — Pre-checkout Tag Resolution and Staging Approval Gate + +Status: in progress. Producer baseline: `eggstack/eggpack@559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce` (M003j implementation). Downstream trigger/evidence: `dbowm91/wg-basic@bd7c085d191ccf147e0f4dab72fde7cc8818f3fd`; R001 requires canonical tag validation and immutable commit resolution before any source checkout, plus reviewer-gated staging. + +Subsystem roadmap: `plans/subsystems/ci-release-orchestration-roadmap.md`. Canonical authority: ADR-0003; `plans/003-planning-process.md`; CI M003i/M003j closure records. + +Primary class: invariant / security corrective. + +## Objective + +For generated release workflows, validate the selected tag and resolve it to one immutable commit before any release-source checkout. Bind checkouts and source-verification steps to that commit, reject moved or malformed refs, and allow product policy to attach a named GitHub Environment only to the write-authorized draft-staging job. + +## Evidence and gap + +M003j safely handles dispatch input and its tag validator, but the generated `preflight` checks out the dispatch ref before that validator runs in `resolve`. That first job currently only runs `cargo --version`, but it violates R001's required ordering. `GitHubStagingPolicyV1` has no environment field, so consumers cannot make the generated `stage` job wait for a configured reviewer. The downstream wg-basic workflow cannot close R001 until these producer contracts are qualified and pinned. + +## Invariants and scope + +- Every tag is validated as bounded data in an environment binding, never interpolated into executable script text. +- Resolve exactly one existing tag to a full commit OID without checking out source. Resolve annotated tags to their peeled commit; reject missing, ambiguous, malformed, or non-commit results. +- All subsequent source checkouts use the resolved OID. Recheck checked-out HEAD against that OID before any Eggpack/product command; moved refs and stale handoffs fail closed. +- The write-authorized `stage` job alone may reference a configured named GitHub Environment. Eggpack renders the reference but does not create/configure the environment or select reviewers. +- Preserve draft-only staging, same-run artifacts, read-only candidate jobs, source/manifest identity, no tag mutation, and no publication path. +- Keep the optional environment field backward compatible; add no ReleaseManifest or runtime schema change. + +## Ordered work packages + +1. Update exact and reusable renderers so their first job validates the tag and resolves its OID without checkout, exposes the bounded OID as an output, then checks out that OID. Propagate the OID to all source-consuming jobs and reject any checked-out HEAD mismatch before Eggpack runs. +2. Add an optional, validated staging environment name to provider policy and emit `environment.name` only on `stage`. Update fixtures and provide a downstream wg-basic config example. +3. Add generator tests for malformed/injection input, lightweight/annotated ref-resolution handling, pre-checkout order, SHA checkout/recheck, environment scoping, and compatibility when no environment is configured. +4. Update CI renderer architecture, roadmap and registry. Prove output with a downstream fixture and `ci check`. + +## Failure and compatibility + +Invalid tags, missing refs, resolution ambiguity/failure, invalid OIDs, or checkout mismatch stop before release commands or draft mutation. Failed approval leaves the stage job pending/cancelled without staging. Absence of the environment preserves existing provider policy compatibility; rendered workflow changes are limited to safe resolution/checkouts and optional environment assignment. + +## Verification + +Run focused `eggpack-ci` tests; `cargo fmt --all -- --check`; `cargo test --workspace --all-targets --all-features --locked`; `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`; `scripts/check-local.sh`; and hosted Linux stable/MSRV/macOS/Windows CI. Regenerate wg-basic workflow at the new immutable producer revision and run its release-contract, native candidate, and systemd lifecycle lanes. Do not stage or publish any release. Local `scripts/check-local.sh` passed on 2026-10-10; hosted qualification and downstream evidence are pending. + +## Acceptance and closure + +No release job checks out a dispatch-selected ref before validating and resolving it; all source-consuming jobs use the frozen commit and reject a mismatch; adversarial input never reaches executable workflow text; only `stage` carries an environment; the no-environment form remains valid; and existing least-privilege/draft-only checks pass. Closure records exact SHAs, hosted runs and downstream drift evidence, with environment reviewer identity/configuration explicitly listed as consumer-owned operations. + +## Stop conditions + +Stop if the tag cannot be resolved without checking out source, safe output propagation requires interpolation, workflow write scope broadens, or environment assignment cannot be limited to `stage`. Do not hand-edit consumer YAML or claim downstream closure without exact-head hosted checks and settings review. diff --git a/plans/registry.md b/plans/registry.md index 271c2b9..412b5d9 100644 --- a/plans/registry.md +++ b/plans/registry.md @@ -96,7 +96,7 @@ Distribution predecessor evidence: | Release manifest | active | `plans/subsystems/release-manifest-roadmap.md` | M002/M003 closed; M003a closed | M003a closed as a docs-only post-publication downstream-closure reconciliation after Eggup M004 closed (`eggstack/eggup@ea1f1c5e29302e5feca4599db9342d3a5ac93915`; formal Eggup status cleanup `eggstack/eggup@3b82d5397e728649a666690868a1e2d0fe42460d`); closure `plans/closure/release-manifest/003a-status.md`; M003 remains closed and no runtime/package requalification was performed or implied | | Build and qualification | active | `plans/subsystems/build-qualification-roadmap.md` | M001-M006 closed | M006 closed on `398cd43` + run 36484758546 under accepted ADR-0005 Option A; the milestone chain is closed and later work needs new evidence | | Bootstrap installers | active; corrective closed | `plans/subsystems/bootstrap-installers-roadmap.md` | M002b closed; prior milestones closed | M002b implementation `88ddf2e`, hosted run `37806244313`; POSIX runtime remains on Unix and Windows PowerShell archive runtime passed. M003 completion definition remains satisfied | -| CI/release orchestration | active; M003i closed, M003j security corrective ready | `plans/subsystems/ci-release-orchestration-roadmap.md` | M003j dispatch-input shell hardening | M003i historical closure retained; two generated `run:` expressions embed `inputs.release_tag` in shell; wg-basic Release R001 blocked on qualified M003j output | +| CI/release orchestration | active; M003j closed, M003k in progress | `plans/subsystems/ci-release-orchestration-roadmap.md` | M003k pre-checkout tag resolution + stage environment | Local gates pass; hosted matrix, producer PR review, and downstream pin/qualification remain | | Eggup interoperability | active | `plans/subsystems/eggup-interoperability-roadmap.md` | Eggpack M001a + Eggup adapter M001/M001a + Eggup M003 real-consumer adoption + Eggup M004 registry promotion all closed | The whole producer/consumer package seam is closed end to end; Release Manifest M003a closed the remaining Eggpack-side planning drift, and no Eggpack work remains on this seam; Eggwork Operations M003 remains producer-only | | Ecosystem adoption | active | `plans/subsystems/ecosystem-adoption-roadmap.md` | M001/M002/M003a/M003b closed | Closure `plans/closure/ecosystem-adoption/003b-status.md`. Paired plans: Eggpack `plans/implementation/ecosystem-adoption/003b-eggsearch-seven-target-eggpack-producer-cutover.md` (`325d44e`); Eggsearch `plans/implementation/eggpack-release-adoption/001-seven-target-eggpack-producer-cutover.md` (`377f9e8`, registry `6767062`). Implementation landed at `eggstack/eggsearch@eabbf80`; hosted run `37531104901` staged eggsearch `v0.4.2` as draft `405157598` with the exact 19-asset inventory, glibc 2.17 re-proven on all three GNU targets, ARMv7 required consumer validator green, Windows ARM64 required and green, and zero OIDC permission in generated jobs. Provenance attested the staged bytes in run `37561960304`; the draft was published 2026-10-07, closing the named condition | | Planning hygiene | active | `plans/subsystems/planning-hygiene-roadmap.md` | M001/M002 closed | M002 closed at `plans/closure/planning-hygiene/002-status.md`: docs/evidence-only post-M003a handoff reconciliation with an empty production/package/workflow diff; stale/duplicated control-surface text removed and the handoff bound to exact paired-plan paths | @@ -105,7 +105,7 @@ Distribution predecessor evidence: ## Dependency-ready implementation work -Planning Hygiene M002, Ecosystem M003b, Bootstrap M002b, and CI M003i are closed. **New dependency-ready CI M003j security corrective:** `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md`. A wg-basic release-readiness source audit confirmed two `workflow_dispatch.inputs.release_tag` interpolations into generated executable Bash, including the write-scoped staging job, at Eggpack `crates/eggpack-ci/src/lib.rs` around the reusable resolver and stage render. Fix and qualify the producer generator before wg-basic R001 repins/regenerates; no public release or new signing is authorized. +Planning Hygiene M002, Ecosystem M003b, Bootstrap M002b, CI M003i, and CI M003j are closed. **Dependency-ready CI M003k:** `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md`. It resolves the downstream wg-basic R001 pre-checkout and stage-environment gates while preserving M003j's safe dispatch handling. The table below is the **milestone-to-closure index plus active ready work**, not an implication that every historical row is executable. @@ -113,7 +113,8 @@ The table below is the **milestone-to-closure index plus active ready work**, no |---|---|---|---|---| | Bootstrap installers | M002b Windows POSIX archive-test portability | **closed** | `plans/implementation/bootstrap-installers/002b-windows-posix-archive-test-portability-corrective.md` | Closure `plans/closure/bootstrap-installers/002b-status.md`; implementation `88ddf2e`; hosted run `37806244313` all lanes green | | CI orchestration | M003i exact tag versus manifest release ID policy | **closed** | `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` | Closure `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`; hosted run `37813044035` all four lanes green. wg-basic M003 may resume with this pin | -| CI orchestration | M003j dispatch-tag Bash interpolation corrective | **ready** | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | Hard: CI M003i closed; generated workflow root cause proven in source; wg-basic Release R001 needs immutable qualified fix | +| CI orchestration | M003j dispatch-tag Bash interpolation corrective | closed | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | Closure `plans/closure/ci-release-orchestration/003j-status.md`; implementation `559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`; hosted run `37987890305` all four lanes green | +| CI orchestration | M003k pre-checkout tag resolution and stage approval gate | **in progress** | `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` | Implementation is on branch `security/m003k-precheckout-resolution-environment`; local gate passed; hosted qualification and independent review pending | | Planning hygiene | M001 current evidence baseline + blocker reconciliation | closed | `plans/implementation/planning-hygiene/001-current-evidence-baseline-and-blocker-reconciliation.md` | Closure `plans/closure/planning-hygiene/001-status.md`; discharged CI M003b (eggsact `685fa373` + run `36886042696`) and closed Ecosystem M002 on stegoeggo `v0.5.0` (run `37181914252`); docs-only, zero production/package/workflow delta | | Planning hygiene | M002 post-M003a cross-repository handoff reconciliation | closed | `plans/implementation/planning-hygiene/002-post-m003a-cross-repository-handoff-reconciliation.md` | Closure `plans/closure/planning-hygiene/002-status.md`; docs/evidence-only; stale M003/M003a/M003b control-surface text reconciled against exact paired-plan paths; empty production/package/workflow diff | | Contract and conformance | M003 bounded direct-contract expansion CLI | closed | `plans/implementation/contract-conformance/003-bounded-direct-contract-expansion-cli.md` | Closure `plans/closure/contract-conformance/003-status.md`; implemented on `43fa2d7`; local-only scalar projection delegating to `DistributionContract`; `ci` family unchanged byte-for-byte; no new dependency, serialized schema, discovery, or framework | diff --git a/plans/subsystems/ci-release-orchestration-roadmap.md b/plans/subsystems/ci-release-orchestration-roadmap.md index 38bf53b..82de583 100644 --- a/plans/subsystems/ci-release-orchestration-roadmap.md +++ b/plans/subsystems/ci-release-orchestration-roadmap.md @@ -100,7 +100,9 @@ M003h status-reconciliation/main-integration corrective plan: `plans/implementat M003i identity-separation corrective: `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` (**closed** at `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`, hosted run `37813044035`, all four lanes green). The immutable producer pin unblocked the separate wg-basic Distribution M003 for its consumer-owned implementation and qualification. -M003j dispatch-tag shell-injection corrective: `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` (**ready**). A 2026-10-09 wg-basic first-public-release security review found `workflow_dispatch.inputs.release_tag` interpolated directly into executable Bash at two generator sites (resolve and write-scoped stage). Preserve M003i's source identity and fix unsafe render with env/data handling, deterministic negative tests, and a fresh immutable producer pin for wg-basic Release Readiness R001. +M003j dispatch-tag shell-injection corrective: `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` (**closed** at `plans/closure/ci-release-orchestration/003j-status.md`; implementation `559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`, hosted run `37987890305`, four platform lanes green). It removes executable interpolation and qualifies data-only tag validation. The separate pre-checkout ordering and stage-environment gaps are registered as M003k. + +M003k pre-checkout tag resolution and stage-environment support: `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` (**ready**; downstream wg-basic R001 at `bd7c085` requires source resolution before checkout and a reviewer-gated stage job). ## 8. Cross-cutting requirements @@ -142,7 +144,8 @@ Build/Qualification M001-M006 and CI M001/M002/M002a/M003c-M003g are closed on t | M003g live qualification failures corrective | closed | `plans/implementation/ci-release-orchestration/003g-live-qualification-corrective.md` | `plans/closure/ci-release-orchestration/003g-status.md`; implementations `5acda73`/`4b28820`/`5ac5b83`/`e5c81f2`; hosted runs 36638321253, 36642184204, 36646814734, 36652203168 all lanes | cross-tool PATH, invalid zigbuild check, artifact exec-bit stripping, consumer validation against failed evidence, stage arity, swallowed staging error, and boolean `make_latest` all corrected; live run 36652731202 staged a complete 15-asset draft for eggsact `v1.2.7`, which the maintainer then published | | M003h live qualification status reconciliation + main integration | closed | `plans/implementation/ci-release-orchestration/003h-live-qualification-status-reconciliation-and-main-integration.md` | `plans/closure/ci-release-orchestration/003h-status.md` | current `main@404f63ec` was merged by `609d5fb`; status reconciled, full verification passed, and `main` fast-forwarded without force | | M003i explicit tag and manifest release identity corrective | closed | `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` | `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`; hosted run `37813044035` passed all four lanes | Finite checked-in opt-in stable-tag mapping with explicitly versioned runtime envelope; legacy exact-tag workflow bytes and ReleaseManifest v1 remain unchanged; wg-basic M003 may resume against the immutable producer SHA | -| M003j dispatch tag shell-injection corrective | ready | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | none (new corrective plan) | Two unsafe `run:` expression interpolations in runtime resolve and write-scoped stage; fix generator and prove no shell execution from dispatch input; wg-basic Release R001 waits on qualified producer pin | +| M003j dispatch tag shell-injection corrective | closed | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | `plans/closure/ci-release-orchestration/003j-status.md`; implementation `559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`; hosted run `37987890305` all four lanes green | Injection is fixed; pre-checkout ordering and stage environment remain M003k requirements | +| M003k pre-checkout tag resolution + stage approval gate | ready | `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` | downstream baseline `dbowm91/wg-basic@bd7c085d191ccf147e0f4dab72fde7cc8818f3fd`; producer baseline `eggstack/eggpack@559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce` | ## 13. 2026-10-08 corrective addendum — M003i From 23d9f0347d89fd6ecd916692c145152e39de687f Mon Sep 17 00:00:00 2001 From: wr3n-ai Date: Sat, 10 Oct 2026 05:19:53 +0000 Subject: [PATCH 6/7] Reject tag refs that do not resolve to commits --- crates/eggpack-ci/src/lib.rs | 21 +++++++++++++++++-- .../tests/fixtures/m003b-archive-staging.yml | 4 ++-- .../tests/fixtures/m003b-bundle-staging.yml | 4 ++-- .../tests/fixtures/m003b-direct-staging.yml | 4 ++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/crates/eggpack-ci/src/lib.rs b/crates/eggpack-ci/src/lib.rs index f0bc53f..7361da0 100644 --- a/crates/eggpack-ci/src/lib.rs +++ b/crates/eggpack-ci/src/lib.rs @@ -3041,7 +3041,7 @@ fn release_tag_resolution_script(mapped_semver: bool, expected_sha: Option<&str> ); } script.push_str( - "ref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\n", + "ref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\nverify_repo=\"$RUNNER_TEMP/eggpack-tag-verify.git\"\ntrap 'rm -f -- \"$askpass\"' EXIT\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nremote=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$remote\" \"$ref\" \"$ref^{}\")\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled ref result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full object OID' >&2\n exit 1\nfi\ngit init --bare \"$verify_repo\" >/dev/null\nGIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git --git-dir=\"$verify_repo\" fetch --no-tags --depth=1 \"$remote\" \"$ref\" >/dev/null\nfetched_commit=\"$(git --git-dir=\"$verify_repo\" rev-parse --verify 'FETCH_HEAD^{commit}')\"\nif [ \"$fetched_commit\" != \"$source_sha\" ]; then\n echo 'tag did not resolve to the advertised commit object' >&2\n exit 1\nfi\n" ); if expected_sha.is_some() { script.push_str( @@ -7661,7 +7661,7 @@ mod tests { let fake_git = bin.join("git"); std::fs::write( &fake_git, - "#!/bin/sh\ncase \"$1\" in\n check-ref-format) exit 0 ;;\n ls-remote) shift; shift; shift; ref=\"$1\"; peeled=\"$2\"; printf '%s\\t%s\\n' \"$EGGPACK_FAKE_DIRECT\" \"$ref\"; if [ -n \"$EGGPACK_FAKE_PEELED\" ]; then printf '%s\\t%s\\n' \"$EGGPACK_FAKE_PEELED\" \"$peeled\"; fi ;;\n *) exit 99 ;;\nesac\n", + "#!/bin/sh\ncase \"$1\" in\n check-ref-format|init) exit 0 ;;\n ls-remote) shift; shift; shift; ref=\"$1\"; peeled=\"$2\"; printf '%s\\t%s\\n' \"$EGGPACK_FAKE_DIRECT\" \"$ref\"; if [ -n \"$EGGPACK_FAKE_PEELED\" ]; then printf '%s\\t%s\\n' \"$EGGPACK_FAKE_PEELED\" \"$peeled\"; fi ;;\n --git-dir=*) shift; case \"$1\" in fetch) exit 0 ;; rev-parse) printf '%s\\n' \"${EGGPACK_FAKE_COMMIT:-${EGGPACK_FAKE_PEELED:-$EGGPACK_FAKE_DIRECT}}\" ;; *) exit 99 ;; esac ;;\n *) exit 99 ;;\nesac\n", ) .unwrap(); use std::os::unix::fs::PermissionsExt; @@ -7727,6 +7727,23 @@ mod tests { assert!(std::fs::read_to_string(&output_path) .unwrap() .contains(&format!("source_sha={}\n", "c".repeat(40)))); + std::fs::write(&output_path, "").unwrap(); + let non_commit = Command::new("bash") + .arg("-c") + .arg(script) + .env("EGGPACK_RELEASE_TAG", "v1.2.3") + .env("GITHUB_TOKEN", "fixture-token") + .env("GITHUB_SERVER_URL", "https://github.com") + .env("GITHUB_REPOSITORY", "owner/repo") + .env("RUNNER_TEMP", &runner_temp) + .env("GITHUB_OUTPUT", &output_path) + .env("EGGPACK_FAKE_DIRECT", "c".repeat(40)) + .env("EGGPACK_FAKE_PEELED", "") + .env("EGGPACK_FAKE_COMMIT", "d".repeat(40)) + .env("PATH", &path) + .status() + .unwrap(); + assert!(!non_commit.success(), "non-commit tag objects fail closed"); assert!( !marker.exists(), "corrected validation must not execute tag text" diff --git a/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml b/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml index 288b339..7ad4723 100644 --- a/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml +++ b/crates/eggpack-ci/tests/fixtures/m003b-archive-staging.yml @@ -23,7 +23,7 @@ jobs: env: EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\nverify_repo=\"$RUNNER_TEMP/eggpack-tag-verify.git\"\ntrap 'rm -f -- \"$askpass\"' EXIT\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nremote=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$remote\" \"$ref\" \"$ref^{}\")\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled ref result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full object OID' >&2\n exit 1\nfi\ngit init --bare \"$verify_repo\" >/dev/null\nGIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git --git-dir=\"$verify_repo\" fetch --no-tags --depth=1 \"$remote\" \"$ref\" >/dev/null\nfetched_commit=\"$(git --git-dir=\"$verify_repo\" rev-parse --verify 'FETCH_HEAD^{commit}')\"\nif [ \"$fetched_commit\" != \"$source_sha\" ]; then\n echo 'tag did not resolve to the advertised commit object' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: @@ -239,7 +239,7 @@ jobs: EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" - run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\nverify_repo=\"$RUNNER_TEMP/eggpack-tag-verify.git\"\ntrap 'rm -f -- \"$askpass\"' EXIT\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nremote=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$remote\" \"$ref\" \"$ref^{}\")\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled ref result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full object OID' >&2\n exit 1\nfi\ngit init --bare \"$verify_repo\" >/dev/null\nGIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git --git-dir=\"$verify_repo\" fetch --no-tags --depth=1 \"$remote\" \"$ref\" >/dev/null\nfetched_commit=\"$(git --git-dir=\"$verify_repo\" rev-parse --verify 'FETCH_HEAD^{commit}')\"\nif [ \"$fetched_commit\" != \"$source_sha\" ]; then\n echo 'tag did not resolve to the advertised commit object' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: diff --git a/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml b/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml index 4a27e4b..0a87f4b 100644 --- a/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml +++ b/crates/eggpack-ci/tests/fixtures/m003b-bundle-staging.yml @@ -23,7 +23,7 @@ jobs: env: EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\nverify_repo=\"$RUNNER_TEMP/eggpack-tag-verify.git\"\ntrap 'rm -f -- \"$askpass\"' EXIT\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nremote=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$remote\" \"$ref\" \"$ref^{}\")\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled ref result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full object OID' >&2\n exit 1\nfi\ngit init --bare \"$verify_repo\" >/dev/null\nGIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git --git-dir=\"$verify_repo\" fetch --no-tags --depth=1 \"$remote\" \"$ref\" >/dev/null\nfetched_commit=\"$(git --git-dir=\"$verify_repo\" rev-parse --verify 'FETCH_HEAD^{commit}')\"\nif [ \"$fetched_commit\" != \"$source_sha\" ]; then\n echo 'tag did not resolve to the advertised commit object' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: @@ -244,7 +244,7 @@ jobs: EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" - run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\nverify_repo=\"$RUNNER_TEMP/eggpack-tag-verify.git\"\ntrap 'rm -f -- \"$askpass\"' EXIT\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nremote=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$remote\" \"$ref\" \"$ref^{}\")\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled ref result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full object OID' >&2\n exit 1\nfi\ngit init --bare \"$verify_repo\" >/dev/null\nGIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git --git-dir=\"$verify_repo\" fetch --no-tags --depth=1 \"$remote\" \"$ref\" >/dev/null\nfetched_commit=\"$(git --git-dir=\"$verify_repo\" rev-parse --verify 'FETCH_HEAD^{commit}')\"\nif [ \"$fetched_commit\" != \"$source_sha\" ]; then\n echo 'tag did not resolve to the advertised commit object' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: diff --git a/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml b/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml index 85eb402..a81ba65 100644 --- a/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml +++ b/crates/eggpack-ci/tests/fixtures/m003b-direct-staging.yml @@ -23,7 +23,7 @@ jobs: env: EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\nverify_repo=\"$RUNNER_TEMP/eggpack-tag-verify.git\"\ntrap 'rm -f -- \"$askpass\"' EXIT\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nremote=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$remote\" \"$ref\" \"$ref^{}\")\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled ref result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full object OID' >&2\n exit 1\nfi\ngit init --bare \"$verify_repo\" >/dev/null\nGIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git --git-dir=\"$verify_repo\" fetch --no-tags --depth=1 \"$remote\" \"$ref\" >/dev/null\nfetched_commit=\"$(git --git-dir=\"$verify_repo\" rev-parse --verify 'FETCH_HEAD^{commit}')\"\nif [ \"$fetched_commit\" != \"$source_sha\" ]; then\n echo 'tag did not resolve to the advertised commit object' >&2\n exit 1\nfi\nprintf 'source_sha=%s\\n' \"$source_sha\" >> \"$GITHUB_OUTPUT\"\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: @@ -234,7 +234,7 @@ jobs: EGGPACK_RELEASE_TAG: "${{ github.ref_name }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} EGGPACK_EXPECTED_SOURCE_SHA: "${{ needs.preflight.outputs.source_sha }}" - run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\" \"$ref\" \"$ref^{}\")\"\nrm -f -- \"$askpass\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled tag result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full commit OID' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" + run: "set -euo pipefail\ntag=\"$EGGPACK_RELEASE_TAG\"\nif [ \"${#tag}\" -gt 255 ] || [ -z \"$tag\" ]; then\n echo 'release tag is empty or oversized' >&2\n exit 1\nfi\nref=\"refs/tags/$tag\"\ngit check-ref-format \"$ref\"\naskpass=\"$RUNNER_TEMP/eggpack-tag-askpass\"\nverify_repo=\"$RUNNER_TEMP/eggpack-tag-verify.git\"\ntrap 'rm -f -- \"$askpass\"' EXIT\ncat >\"$askpass\" <<'ASKPASS'\n#!/bin/sh\ncase \"$1\" in\n *Username*) printf '%s\\n' x-access-token ;;\n *Password*) printf '%s\\n' \"$EGGPACK_GIT_TOKEN\" ;;\n *) exit 1 ;;\nesac\nASKPASS\nchmod 700 \"$askpass\"\nremote=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git\"\nrefs=\"$(GIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git ls-remote --exit-code \"$remote\" \"$ref\" \"$ref^{}\")\"\ndirect=\npeeled=\nwhile IFS=\"$(printf '\\t')\" read -r oid name; do\n case \"$name\" in\n \"$ref\") [ -z \"$direct\" ] || { echo 'duplicate tag ref result' >&2; exit 1; }; direct=\"$oid\" ;;\n \"$ref^{}\") [ -z \"$peeled\" ] || { echo 'duplicate peeled ref result' >&2; exit 1; }; peeled=\"$oid\" ;;\n *) echo 'unexpected tag resolution result' >&2; exit 1 ;;\n esac\ndone <<< \"$refs\"\nsource_sha=\"${peeled:-$direct}\"\nif [[ ! \"$source_sha\" =~ ^[0-9a-f]{40}$ ]]; then\n echo 'tag did not resolve to one full object OID' >&2\n exit 1\nfi\ngit init --bare \"$verify_repo\" >/dev/null\nGIT_ASKPASS=\"$askpass\" GIT_TERMINAL_PROMPT=0 EGGPACK_GIT_TOKEN=\"$GITHUB_TOKEN\" git --git-dir=\"$verify_repo\" fetch --no-tags --depth=1 \"$remote\" \"$ref\" >/dev/null\nfetched_commit=\"$(git --git-dir=\"$verify_repo\" rev-parse --verify 'FETCH_HEAD^{commit}')\"\nif [ \"$fetched_commit\" != \"$source_sha\" ]; then\n echo 'tag did not resolve to the advertised commit object' >&2\n exit 1\nfi\nif [ \"$source_sha\" != \"$EGGPACK_EXPECTED_SOURCE_SHA\" ]; then\n echo 'release tag moved after preflight resolution' >&2\n exit 1\nfi\n" - name: Check out source uses: "actions/checkout@0123456789abcdef0123456789abcdef01234567" with: From fb81aa1400e1f333f6500075f78d944a9242b673 Mon Sep 17 00:00:00 2001 From: wr3n-ai Date: Sat, 10 Oct 2026 05:25:41 +0000 Subject: [PATCH 7/7] Record M003k local and hosted qualification evidence --- .../003k-precheckout-tag-resolution-and-stage-environment.md | 2 +- plans/registry.md | 2 +- plans/subsystems/ci-release-orchestration-roadmap.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md b/plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md index 3f9f604..f974ca8 100644 --- a/plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md +++ b/plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md @@ -36,7 +36,7 @@ Invalid tags, missing refs, resolution ambiguity/failure, invalid OIDs, or check ## Verification -Run focused `eggpack-ci` tests; `cargo fmt --all -- --check`; `cargo test --workspace --all-targets --all-features --locked`; `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`; `scripts/check-local.sh`; and hosted Linux stable/MSRV/macOS/Windows CI. Regenerate wg-basic workflow at the new immutable producer revision and run its release-contract, native candidate, and systemd lifecycle lanes. Do not stage or publish any release. Local `scripts/check-local.sh` passed on 2026-10-10; hosted qualification and downstream evidence are pending. +Run focused `eggpack-ci` tests; `cargo fmt --all -- --check`; `cargo test --workspace --all-targets --all-features --locked`; `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`; `scripts/check-local.sh`; and hosted Linux stable/MSRV/macOS/Windows CI. Regenerate wg-basic workflow at the new immutable producer revision and run its release-contract, native candidate, and systemd lifecycle lanes. Do not stage or publish any release. Local `scripts/check-local.sh` passed on 2026-10-10; hosted run `38027143275` passed all four lanes on the current producer head. Independent PR review/merge and downstream evidence are pending. ## Acceptance and closure diff --git a/plans/registry.md b/plans/registry.md index 412b5d9..89a4111 100644 --- a/plans/registry.md +++ b/plans/registry.md @@ -114,7 +114,7 @@ The table below is the **milestone-to-closure index plus active ready work**, no | Bootstrap installers | M002b Windows POSIX archive-test portability | **closed** | `plans/implementation/bootstrap-installers/002b-windows-posix-archive-test-portability-corrective.md` | Closure `plans/closure/bootstrap-installers/002b-status.md`; implementation `88ddf2e`; hosted run `37806244313` all lanes green | | CI orchestration | M003i exact tag versus manifest release ID policy | **closed** | `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` | Closure `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`; hosted run `37813044035` all four lanes green. wg-basic M003 may resume with this pin | | CI orchestration | M003j dispatch-tag Bash interpolation corrective | closed | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | Closure `plans/closure/ci-release-orchestration/003j-status.md`; implementation `559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`; hosted run `37987890305` all four lanes green | -| CI orchestration | M003k pre-checkout tag resolution and stage approval gate | **in progress** | `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` | Implementation is on branch `security/m003k-precheckout-resolution-environment`; local gate passed; hosted qualification and independent review pending | +| CI orchestration | M003k pre-checkout tag resolution and stage approval gate | **in progress** | `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` | PR `eggstack/eggpack#1` at `23d9f0347d89fd6ecd916692c145152e39de687f`; local gate and hosted run `38027143275` passed; independent review/merge and downstream qualification pending | | Planning hygiene | M001 current evidence baseline + blocker reconciliation | closed | `plans/implementation/planning-hygiene/001-current-evidence-baseline-and-blocker-reconciliation.md` | Closure `plans/closure/planning-hygiene/001-status.md`; discharged CI M003b (eggsact `685fa373` + run `36886042696`) and closed Ecosystem M002 on stegoeggo `v0.5.0` (run `37181914252`); docs-only, zero production/package/workflow delta | | Planning hygiene | M002 post-M003a cross-repository handoff reconciliation | closed | `plans/implementation/planning-hygiene/002-post-m003a-cross-repository-handoff-reconciliation.md` | Closure `plans/closure/planning-hygiene/002-status.md`; docs/evidence-only; stale M003/M003a/M003b control-surface text reconciled against exact paired-plan paths; empty production/package/workflow diff | | Contract and conformance | M003 bounded direct-contract expansion CLI | closed | `plans/implementation/contract-conformance/003-bounded-direct-contract-expansion-cli.md` | Closure `plans/closure/contract-conformance/003-status.md`; implemented on `43fa2d7`; local-only scalar projection delegating to `DistributionContract`; `ci` family unchanged byte-for-byte; no new dependency, serialized schema, discovery, or framework | diff --git a/plans/subsystems/ci-release-orchestration-roadmap.md b/plans/subsystems/ci-release-orchestration-roadmap.md index 82de583..f92aa62 100644 --- a/plans/subsystems/ci-release-orchestration-roadmap.md +++ b/plans/subsystems/ci-release-orchestration-roadmap.md @@ -102,7 +102,7 @@ M003i identity-separation corrective: `plans/implementation/ci-release-orchestra M003j dispatch-tag shell-injection corrective: `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` (**closed** at `plans/closure/ci-release-orchestration/003j-status.md`; implementation `559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`, hosted run `37987890305`, four platform lanes green). It removes executable interpolation and qualifies data-only tag validation. The separate pre-checkout ordering and stage-environment gaps are registered as M003k. -M003k pre-checkout tag resolution and stage-environment support: `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` (**ready**; downstream wg-basic R001 at `bd7c085` requires source resolution before checkout and a reviewer-gated stage job). +M003k pre-checkout tag resolution and stage-environment support: `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` (**in progress**; PR `eggstack/eggpack#1`, producer head `23d9f0347d89fd6ecd916692c145152e39de687f`, local gate and hosted run `38027143275` passed; independent review/merge and downstream qualification remain). ## 8. Cross-cutting requirements @@ -145,7 +145,7 @@ Build/Qualification M001-M006 and CI M001/M002/M002a/M003c-M003g are closed on t | M003h live qualification status reconciliation + main integration | closed | `plans/implementation/ci-release-orchestration/003h-live-qualification-status-reconciliation-and-main-integration.md` | `plans/closure/ci-release-orchestration/003h-status.md` | current `main@404f63ec` was merged by `609d5fb`; status reconciled, full verification passed, and `main` fast-forwarded without force | | M003i explicit tag and manifest release identity corrective | closed | `plans/implementation/ci-release-orchestration/003i-explicit-tag-and-manifest-release-identity-corrective.md` | `plans/closure/ci-release-orchestration/003i-status.md`; implementation `3ddac9d84fc2e10b8451d38672f66b02e06724df`; hosted run `37813044035` passed all four lanes | Finite checked-in opt-in stable-tag mapping with explicitly versioned runtime envelope; legacy exact-tag workflow bytes and ReleaseManifest v1 remain unchanged; wg-basic M003 may resume against the immutable producer SHA | | M003j dispatch tag shell-injection corrective | closed | `plans/implementation/ci-release-orchestration/003j-dispatch-tag-shell-injection-corrective.md` | `plans/closure/ci-release-orchestration/003j-status.md`; implementation `559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce`; hosted run `37987890305` all four lanes green | Injection is fixed; pre-checkout ordering and stage environment remain M003k requirements | -| M003k pre-checkout tag resolution + stage approval gate | ready | `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` | downstream baseline `dbowm91/wg-basic@bd7c085d191ccf147e0f4dab72fde7cc8818f3fd`; producer baseline `eggstack/eggpack@559d940af0fe6a2951eb17de1fcbecbf9e0bb6ce` | +| M003k pre-checkout tag resolution + stage approval gate | in progress | `plans/implementation/ci-release-orchestration/003k-precheckout-tag-resolution-and-stage-environment.md` | PR `eggstack/eggpack#1` at `23d9f0347d89fd6ecd916692c145152e39de687f`; run `38027143275` all four lanes green; independent review/merge and downstream `dbowm91/wg-basic` qualification pending | ## 13. 2026-10-08 corrective addendum — M003i