@intentius/chant 0.124.86 → 0.124.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-pins.d.ts +1 -0
- package/dist/action-pins.d.ts.map +1 -1
- package/dist/action-pins.js +2 -0
- package/dist/actor.d.ts +12 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +18 -0
- package/dist/bundle-check.d.ts +20 -5
- package/dist/bundle-check.d.ts.map +1 -1
- package/dist/bundle-check.js +20 -5
- package/dist/chant-install.d.ts +98 -0
- package/dist/chant-install.d.ts.map +1 -1
- package/dist/chant-install.js +204 -2
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +1 -2
- package/dist/ci-control.d.ts +1 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +1 -1
- package/dist/ci-evidence-claims.d.ts +59 -0
- package/dist/ci-evidence-claims.d.ts.map +1 -0
- package/dist/ci-evidence-claims.js +87 -0
- package/dist/ci-evidence-from-job.d.ts +103 -0
- package/dist/ci-evidence-from-job.d.ts.map +1 -0
- package/dist/ci-evidence-from-job.js +162 -0
- package/dist/ci-evidence-jobs.d.ts +69 -10
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +72 -8
- package/dist/ci-handover.d.ts +12 -0
- package/dist/ci-handover.d.ts.map +1 -1
- package/dist/ci-handover.js +15 -3
- package/dist/ci-identity.d.ts +32 -6
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +40 -8
- package/dist/ci-image.d.ts +47 -9
- package/dist/ci-image.d.ts.map +1 -1
- package/dist/ci-image.js +45 -18
- package/dist/ci-jobs.d.ts +1 -1
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +7 -2
- package/dist/ci-login.d.ts +75 -13
- package/dist/ci-login.d.ts.map +1 -1
- package/dist/ci-login.js +89 -37
- package/dist/ci-product-words.d.ts +20 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +27 -1
- package/dist/ci-product.d.ts +20 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +21 -2
- package/dist/cli/handlers/approve-confirm.d.ts +14 -0
- package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
- package/dist/cli/handlers/approve-confirm.js +46 -0
- package/dist/cli/handlers/build.d.ts +1 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -1
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +38 -14
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +238 -26
- package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-forge-check.js +34 -17
- package/dist/cli/handlers/generated-check.d.ts +3 -0
- package/dist/cli/handlers/generated-check.d.ts.map +1 -0
- package/dist/cli/handlers/generated-check.js +41 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +3 -0
- package/dist/cli/handlers/local-chant.d.ts +13 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -1
- package/dist/cli/handlers/local-chant.js +42 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +42 -5
- package/dist/cli/handlers/run-wave.js +8 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -4
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +66 -0
- package/dist/cli/registry.d.ts +24 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +10 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +21 -3
- package/dist/components/check-steps.js +1 -1
- package/dist/components/pr-checks.d.ts +105 -0
- package/dist/components/pr-checks.d.ts.map +1 -0
- package/dist/components/pr-checks.js +119 -0
- package/dist/components/pr-pipeline.d.ts +34 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +14 -1
- package/dist/components/product-pipeline.d.ts +16 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +17 -2
- package/dist/components/product-plan.d.ts +262 -3
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +243 -11
- package/dist/config.d.ts +10 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -6
- package/dist/control/consumers.d.ts +6 -0
- package/dist/control/consumers.d.ts.map +1 -1
- package/dist/control/consumers.js +6 -0
- package/dist/dead-guards.d.ts.map +1 -1
- package/dist/dead-guards.js +9 -6
- package/dist/discovery/files.d.ts +1 -1
- package/dist/discovery/files.js +1 -1
- package/dist/drift-issue.d.ts +20 -3
- package/dist/drift-issue.d.ts.map +1 -1
- package/dist/drift-issue.js +16 -0
- package/dist/drift-record.d.ts +45 -5
- package/dist/drift-record.d.ts.map +1 -1
- package/dist/drift-record.js +27 -6
- package/dist/floor-table.d.ts +6 -6
- package/dist/floor-table.d.ts.map +1 -1
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +58 -20
- package/dist/floor-table.js +10 -7
- package/dist/forge-check/contract.d.ts +8 -0
- package/dist/forge-check/contract.d.ts.map +1 -1
- package/dist/forge-check/contract.js +4 -1
- package/dist/forge-check/index.d.ts +2 -0
- package/dist/forge-check/index.d.ts.map +1 -1
- package/dist/forge-check/index.js +2 -0
- package/dist/forge-flags.d.ts +10 -0
- package/dist/forge-flags.d.ts.map +1 -1
- package/dist/forge-flags.js +31 -0
- package/dist/forge-remote.d.ts +47 -0
- package/dist/forge-remote.d.ts.map +1 -0
- package/dist/forge-remote.js +69 -0
- package/dist/generated-check.d.ts +74 -0
- package/dist/generated-check.d.ts.map +1 -0
- package/dist/generated-check.js +216 -0
- package/dist/lexicon.d.ts +16 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.d.ts +15 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +49 -3
- package/dist/lifecycle/release-images.d.ts +22 -1
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +27 -3
- package/dist/lifecycle/release-ledger.d.ts +4 -3
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +3 -2
- package/dist/local-chant.d.ts +57 -3
- package/dist/local-chant.d.ts.map +1 -1
- package/dist/local-chant.js +122 -13
- package/dist/op/op-waves-evidence-jobs.d.ts +92 -0
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-jobs.js +112 -0
- package/dist/op/op-waves-evidence.d.ts +17 -4
- package/dist/op/op-waves-evidence.d.ts.map +1 -1
- package/dist/op/op-waves-evidence.js +32 -10
- package/dist/op/op-waves-run.d.ts +12 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +54 -3
- package/dist/op/op-waves.d.ts +8 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +10 -0
- package/dist/op/schedule-overdue.d.ts +39 -2
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +89 -7
- package/dist/pr-forge-reads.d.ts +21 -1
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +19 -1
- package/dist/pr-forge.d.ts +7 -1
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +7 -2
- package/dist/pr-plan-note.d.ts +24 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +11 -1
- package/dist/pr-plan-record.d.ts +47 -0
- package/dist/pr-plan-record.d.ts.map +1 -0
- package/dist/pr-plan-record.js +89 -0
- package/dist/pr-post.d.ts +40 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +79 -6
- package/dist/pr-requires.d.ts +8 -0
- package/dist/pr-requires.d.ts.map +1 -1
- package/dist/pr-requires.js +3 -1
- package/dist/ref-gate-init.d.ts +76 -0
- package/dist/ref-gate-init.d.ts.map +1 -0
- package/dist/ref-gate-init.js +144 -0
- package/dist/ref-gate-rules.d.ts +19 -0
- package/dist/ref-gate-rules.d.ts.map +1 -0
- package/dist/ref-gate-rules.js +17 -0
- package/dist/release-floors.d.ts +51 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +66 -16
- package/dist/state-migration.d.ts +23 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +39 -3
- package/dist/state-unlock.d.ts +32 -1
- package/dist/state-unlock.d.ts.map +1 -1
- package/dist/state-unlock.js +31 -0
- package/dist/wave-runtime.mjs +310 -303
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +13 -7
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +4 -3
- package/dist/workspace/drift-cli.d.ts +1 -1
- package/dist/workspace/drift-cli.d.ts.map +1 -1
- package/dist/workspace/drift-cli.js +5 -12
- package/dist/workspace/forge-work.d.ts +3 -2
- package/dist/workspace/forge-work.d.ts.map +1 -1
- package/dist/workspace/forge-work.js +7 -17
- package/dist/workspace/lexicon-outputs.js +2 -2
- package/dist/workspace/release-workflow.d.ts +26 -3
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +48 -6
- package/dist/workspace/trust/check-evidence-report.d.ts +25 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +20 -0
- package/dist/workspace/trust/check-evidence.d.ts +59 -13
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence.js +101 -24
- package/dist/workspace/trust/ci-tag-statement.d.ts +2 -2
- package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
- package/dist/workspace/trust/dsse.d.ts +40 -2
- package/dist/workspace/trust/dsse.d.ts.map +1 -1
- package/dist/workspace/trust/dsse.js +34 -2
- package/dist/workspace/trust/evidence.d.ts +7 -2
- package/dist/workspace/trust/evidence.d.ts.map +1 -1
- package/dist/workspace/trust/evidence.js +5 -0
- package/dist/workspace/trust/keyless-fixture.d.ts +41 -0
- package/dist/workspace/trust/keyless-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/keyless-fixture.js +161 -0
- package/dist/workspace/trust/keyless.d.ts +202 -0
- package/dist/workspace/trust/keyless.d.ts.map +1 -0
- package/dist/workspace/trust/keyless.js +488 -0
- package/dist/workspace/trust/local-evidence.d.ts +3 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -1
- package/dist/workspace/trust/op-run-statement.d.ts +2 -2
- package/dist/workspace/trust/op-run-statement.d.ts.map +1 -1
- package/dist/workspace/trust/open-evidence.d.ts +67 -0
- package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/open-evidence.js +92 -0
- package/dist/workspace/trust/policy.d.ts +56 -1
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +103 -2
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate-cli.js +65 -3
- package/dist/workspace/trust/ref-gate.d.ts +62 -3
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate.js +75 -8
- package/dist/workspace/trust/run-statement.d.ts +3 -3
- package/dist/workspace/trust/run-statement.d.ts.map +1 -1
- package/dist/workspace/trust/runner-identity.d.ts +56 -0
- package/dist/workspace/trust/runner-identity.d.ts.map +1 -0
- package/dist/workspace/trust/runner-identity.js +65 -0
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +8 -1
- package/package.json +1 -1
- package/src/action-pins.ts +2 -0
- package/src/actor.test.ts +12 -0
- package/src/actor.ts +19 -0
- package/src/bundle-check.test.ts +22 -0
- package/src/bundle-check.ts +33 -5
- package/src/chant-install.test.ts +109 -1
- package/src/chant-install.ts +243 -2
- package/src/ci-commit.test.ts +51 -5
- package/src/ci-commit.ts +1 -2
- package/src/ci-control.ts +1 -0
- package/src/ci-evidence-claims.ts +102 -0
- package/src/ci-evidence-from-job.test.ts +147 -0
- package/src/ci-evidence-from-job.ts +195 -0
- package/src/ci-evidence-jobs.ts +85 -10
- package/src/ci-handover.ts +16 -3
- package/src/ci-identity.test.ts +3 -3
- package/src/ci-identity.ts +51 -11
- package/src/ci-image.test.ts +60 -10
- package/src/ci-image.ts +78 -19
- package/src/ci-jobs.ts +7 -2
- package/src/ci-login.test.ts +131 -3
- package/src/ci-login.token-drop.test.ts +204 -0
- package/src/ci-login.ts +137 -39
- package/src/ci-product-words.ts +30 -0
- package/src/ci-product.ts +26 -1
- package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
- package/src/cli/handlers/approve-confirm.test.ts +35 -0
- package/src/cli/handlers/approve-confirm.ts +44 -0
- package/src/cli/handlers/build-source-dir.test.ts +4 -0
- package/src/cli/handlers/build.ts +20 -2
- package/src/cli/handlers/ci-check.ts +35 -13
- package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
- package/src/cli/handlers/ci-evidence.ts +223 -24
- package/src/cli/handlers/ci-forge-check.ts +22 -9
- package/src/cli/handlers/generated-check.ts +39 -0
- package/src/cli/handlers/lifecycle.test.ts +20 -0
- package/src/cli/handlers/lifecycle.ts +4 -0
- package/src/cli/handlers/local-chant.ts +39 -1
- package/src/cli/handlers/pr.ts +43 -5
- package/src/cli/handlers/run-wave.ts +7 -0
- package/src/cli/main.ts +38 -4
- package/src/cli/parse-args.ts +46 -0
- package/src/cli/registry.ts +24 -0
- package/src/components/check-hooks.ts +25 -3
- package/src/components/check-report-summary.test.ts +78 -0
- package/src/components/check-steps.ts +1 -1
- package/src/components/pr-checks.ts +159 -0
- package/src/components/pr-pipeline.ts +41 -1
- package/src/components/product-pipeline.ts +25 -3
- package/src/components/product-plan.test.ts +102 -1
- package/src/components/product-plan.ts +419 -14
- package/src/config.ts +13 -8
- package/src/control/consumers.ts +7 -0
- package/src/dead-guards.test.ts +27 -5
- package/src/dead-guards.ts +9 -6
- package/src/discovery/files.ts +1 -1
- package/src/drift-issue.test.ts +29 -1
- package/src/drift-issue.ts +28 -3
- package/src/drift-record.test.ts +25 -0
- package/src/drift-record.ts +55 -6
- package/src/floor-table.data.ts +58 -20
- package/src/floor-table.ts +12 -9
- package/src/forge-check/contract.ts +11 -1
- package/src/forge-check/forge-check.test.ts +8 -0
- package/src/forge-check/index.ts +2 -0
- package/src/forge-flags.test.ts +25 -1
- package/src/forge-flags.ts +34 -0
- package/src/forge-remote.test.ts +37 -0
- package/src/forge-remote.ts +79 -0
- package/src/generated-check.e2e.test.ts +98 -0
- package/src/generated-check.test.ts +104 -0
- package/src/generated-check.ts +269 -0
- package/src/lexicon.ts +17 -0
- package/src/lifecycle/publish-npm.ts +56 -3
- package/src/lifecycle/release-catalog.test.ts +2 -2
- package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
- package/src/lifecycle/release-images.test.ts +44 -0
- package/src/lifecycle/release-images.ts +39 -3
- package/src/lifecycle/release-ledger.ts +4 -3
- package/src/local-chant.e2e.test.ts +81 -6
- package/src/local-chant.test.ts +22 -3
- package/src/local-chant.ts +130 -13
- package/src/op/op-waves-evidence-jobs.ts +134 -0
- package/src/op/op-waves-evidence.test.ts +37 -4
- package/src/op/op-waves-evidence.ts +32 -11
- package/src/op/op-waves-run.ts +57 -2
- package/src/op/op-waves.ts +11 -0
- package/src/op/schedule-overdue.test.ts +83 -1
- package/src/op/schedule-overdue.ts +107 -9
- package/src/pr-forge-reads-compare.test.ts +2 -1
- package/src/pr-forge-reads.ts +37 -1
- package/src/pr-forge.ts +14 -3
- package/src/pr-plan-note.ts +32 -3
- package/src/pr-plan-record.test.ts +75 -0
- package/src/pr-plan-record.ts +101 -0
- package/src/pr-post-plan-note.test.ts +60 -0
- package/src/pr-post.test.ts +30 -0
- package/src/pr-post.ts +110 -6
- package/src/pr-requires.test.ts +20 -0
- package/src/pr-requires.ts +10 -1
- package/src/ref-gate-init.ts +189 -0
- package/src/ref-gate-rules.ts +26 -0
- package/src/release-floors.ts +88 -16
- package/src/state-migration-record.test.ts +90 -0
- package/src/state-migration.test.ts +1 -1
- package/src/state-migration.ts +52 -3
- package/src/state-unlock.test.ts +33 -1
- package/src/state-unlock.ts +49 -1
- package/src/workspace/ci-green-cli.ts +12 -6
- package/src/workspace/ci-green.ts +4 -3
- package/src/workspace/drift-cli.ts +6 -18
- package/src/workspace/forge-work.ts +7 -14
- package/src/workspace/lexicon-outputs.ts +2 -2
- package/src/workspace/release-workflow.test.ts +70 -0
- package/src/workspace/release-workflow.ts +56 -8
- package/src/workspace/trust/check-evidence-report.ts +33 -0
- package/src/workspace/trust/check-evidence.test.ts +3 -3
- package/src/workspace/trust/check-evidence.ts +110 -28
- package/src/workspace/trust/ci-tag-statement.ts +2 -2
- package/src/workspace/trust/dsse.ts +48 -4
- package/src/workspace/trust/evidence.ts +7 -2
- package/src/workspace/trust/keyless-fixture.ts +214 -0
- package/src/workspace/trust/keyless.test.ts +220 -0
- package/src/workspace/trust/keyless.ts +557 -0
- package/src/workspace/trust/local-evidence.ts +3 -1
- package/src/workspace/trust/op-run-statement.ts +2 -2
- package/src/workspace/trust/open-evidence.ts +129 -0
- package/src/workspace/trust/policy.ts +129 -2
- package/src/workspace/trust/ref-gate-cli.ts +59 -3
- package/src/workspace/trust/ref-gate-pieces.test.ts +175 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
- package/src/workspace/trust/ref-gate.ts +90 -8
- package/src/workspace/trust/run-statement.ts +3 -3
- package/src/workspace/trust/runner-identity.ts +92 -0
- package/src/workspace/trust/trust-files.test.ts +6 -0
- package/src/workspace/trust/trust-files.ts +14 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which checks a job outside the check's own may sign (#4926): `chant ci
|
|
3
|
+
* evidence sign --from-job <job>`, the evidence job after a wave job.
|
|
4
|
+
*
|
|
5
|
+
* The wave job runs the change's code, so whatever could sign in it could
|
|
6
|
+
* sign a check that never passed, and a wave that trades cloud credentials
|
|
7
|
+
* can request no signing token after the trade anyway. The evidence job runs
|
|
8
|
+
* none of that code. It reads the wave job's own record from the forge
|
|
9
|
+
* (./pr-forge-reads.ts `runJobs`) with the job token and signs a check only
|
|
10
|
+
* when:
|
|
11
|
+
*
|
|
12
|
+
* - the job it names ran in this run, for this commit: a job of another run
|
|
13
|
+
* or commit refuses the whole command;
|
|
14
|
+
* - the forge reports the check's step (GitHub, Forgejo) or job (GitLab,
|
|
15
|
+
* which reports no steps) finished with `success`. Change code can fail or
|
|
16
|
+
* pass its own steps, but it cannot make the forge report a passing policy
|
|
17
|
+
* step whose command failed;
|
|
18
|
+
* - with `claims`, the step's claim file (./ci-evidence-claims.ts) says the
|
|
19
|
+
* check passed. Its claim, such as the policy rows, is what the statement
|
|
20
|
+
* digests.
|
|
21
|
+
*
|
|
22
|
+
* Each check signed carries `source: { run, job, step }`, the ids it relied
|
|
23
|
+
* on, so a verifier can look them up.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { ForgeReads, RunJob } from "./pr-forge-reads";
|
|
27
|
+
import { commitAndTree, noRunnerIdentity, recordChecks, runnerEvidenceSigner, signChecks, type CheckSource } from "./workspace/trust/check-evidence";
|
|
28
|
+
import { EVIDENCE_SOURCES_ENV, parseEvidenceSources, readCheckClaimFile, type EvidenceSourceSpec } from "./ci-evidence-claims";
|
|
29
|
+
|
|
30
|
+
/** What {@link checksFromJob} reads. */
|
|
31
|
+
export interface ChecksFromJobInput {
|
|
32
|
+
reads: Pick<ForgeReads, "runJobs">;
|
|
33
|
+
/** This run's id: `GITHUB_RUN_ID`, `CI_PIPELINE_ID`. */
|
|
34
|
+
run: number;
|
|
35
|
+
/** This run's commit: `GITHUB_SHA`, `CI_COMMIT_SHA`. */
|
|
36
|
+
sha: string;
|
|
37
|
+
/** The job the checks ran in, by name. */
|
|
38
|
+
fromJob: string;
|
|
39
|
+
checks: readonly string[];
|
|
40
|
+
/** Each check's job and step; a check with none is read from `fromJob`'s own result. */
|
|
41
|
+
sources?: Readonly<Record<string, EvidenceSourceSpec>>;
|
|
42
|
+
/** The directory of the jobs' claim files. Without it, a check needs only its step's success and signs no claim. */
|
|
43
|
+
claims?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** What may be signed, and what not and why. */
|
|
47
|
+
export type ChecksFromJob =
|
|
48
|
+
| { sign: Array<{ check: string; claim?: string; source: CheckSource }>; skipped: Array<{ check: string; reason: string }> }
|
|
49
|
+
| { refused: string };
|
|
50
|
+
|
|
51
|
+
const SUCCESS = "success";
|
|
52
|
+
|
|
53
|
+
/** Whether the forge reports `job` passed: GitHub's and Forgejo's conclusion, GitLab's status. */
|
|
54
|
+
function jobPassed(job: RunJob): boolean {
|
|
55
|
+
return job.conclusion !== undefined ? job.conclusion === SUCCESS : job.status === SUCCESS;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The checks the run's record lets this job sign (#4926), or why the job it names does not count at all. */
|
|
59
|
+
export async function checksFromJob(input: ChecksFromJobInput): Promise<ChecksFromJob> {
|
|
60
|
+
const jobs = await input.reads.runJobs(input.run);
|
|
61
|
+
const found = new Map<string, RunJob | string>();
|
|
62
|
+
const jobNamed = (name: string): RunJob | string => {
|
|
63
|
+
const had = found.get(name);
|
|
64
|
+
if (had !== undefined) return had;
|
|
65
|
+
const named = jobs.filter((j) => j.name === name);
|
|
66
|
+
let got: RunJob | string;
|
|
67
|
+
if (named.length === 0) got = `run ${input.run} has no job named ${name}`;
|
|
68
|
+
else if (named.length > 1) got = `run ${input.run} has ${named.length} jobs named ${name}, so which one ran the check is not known`;
|
|
69
|
+
else {
|
|
70
|
+
const j = named[0]!;
|
|
71
|
+
if (j.run !== undefined && j.run !== input.run) got = `job ${name} (${j.id}) belongs to run ${j.run}, not this run ${input.run}`;
|
|
72
|
+
else if (j.headSha === undefined) got = `the forge names no commit for job ${name} (${j.id}), so it cannot be bound to ${input.sha.slice(0, 12)}`;
|
|
73
|
+
else if (j.headSha !== input.sha) got = `job ${name} (${j.id}) ran for commit ${j.headSha.slice(0, 12)}, not this run's ${input.sha.slice(0, 12)}`;
|
|
74
|
+
else got = j;
|
|
75
|
+
}
|
|
76
|
+
found.set(name, got);
|
|
77
|
+
return got;
|
|
78
|
+
};
|
|
79
|
+
const sign: Array<{ check: string; claim?: string; source: CheckSource }> = [];
|
|
80
|
+
const skipped: Array<{ check: string; reason: string }> = [];
|
|
81
|
+
for (const check of input.checks) {
|
|
82
|
+
const spec = input.sources?.[check] ?? {};
|
|
83
|
+
const name = spec.job ?? input.fromJob;
|
|
84
|
+
const job = jobNamed(name);
|
|
85
|
+
if (typeof job === "string") return { refused: job };
|
|
86
|
+
if (!job.done) {
|
|
87
|
+
skipped.push({ check, reason: `job ${name} has not finished (${job.status})` });
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
let step: string | undefined;
|
|
91
|
+
if (spec.step !== undefined) {
|
|
92
|
+
if (!job.steps) {
|
|
93
|
+
skipped.push({ check, reason: `the forge lists no steps for job ${name}` });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const s = job.steps.filter((x) => x.name === spec.step);
|
|
97
|
+
if (s.length !== 1) {
|
|
98
|
+
skipped.push({ check, reason: s.length === 0 ? `job ${name} has no step named ${JSON.stringify(spec.step)}` : `job ${name} has ${s.length} steps named ${JSON.stringify(spec.step)}` });
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (s[0]!.conclusion !== SUCCESS) {
|
|
102
|
+
skipped.push({ check, reason: `step ${JSON.stringify(spec.step)} of job ${name} concluded ${s[0]!.conclusion ?? s[0]!.status}` });
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
step = spec.step;
|
|
106
|
+
} else if (!jobPassed(job)) {
|
|
107
|
+
skipped.push({ check, reason: `job ${name} ended ${job.conclusion ?? job.status}` });
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
let claim: string | undefined;
|
|
111
|
+
if (input.claims !== undefined) {
|
|
112
|
+
const file = readCheckClaimFile(input.claims, check);
|
|
113
|
+
if ("problem" in file) {
|
|
114
|
+
skipped.push({ check, reason: file.problem });
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!file.passed) {
|
|
118
|
+
skipped.push({ check, reason: `job ${name}'s claim file says ${check} did not pass` });
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
claim = file.claim;
|
|
122
|
+
}
|
|
123
|
+
sign.push({ check, ...(claim !== undefined ? { claim } : {}), source: { run: input.run, job: job.id, ...(step ? { step } : {}) } });
|
|
124
|
+
}
|
|
125
|
+
return { sign, skipped };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** What {@link signFromJob} does in a job. */
|
|
129
|
+
export interface SignFromJobInput {
|
|
130
|
+
repo: string;
|
|
131
|
+
/** The commit whose `.chant/trust.json` lists the runner identities. */
|
|
132
|
+
base: string;
|
|
133
|
+
fromJob: string;
|
|
134
|
+
checks: readonly string[];
|
|
135
|
+
claims?: string;
|
|
136
|
+
/** The commit to sign. Default: the run's commit. It must be the run's commit. */
|
|
137
|
+
at?: string;
|
|
138
|
+
reads: Pick<ForgeReads, "runJobs">;
|
|
139
|
+
env?: NodeJS.ProcessEnv;
|
|
140
|
+
/** The runner key in place of `CHANT_RUNNER_KEY`. */
|
|
141
|
+
key?: string;
|
|
142
|
+
push?: boolean;
|
|
143
|
+
fetch?: typeof fetch;
|
|
144
|
+
log?: (line: string) => void;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** What {@link signFromJob} signed and skipped, or why it refused. */
|
|
148
|
+
export type SignFromJobResult =
|
|
149
|
+
| { signed: Array<{ check: string; runner: string; commit: string; tree: string; source: CheckSource }>; skipped: Array<{ check: string; reason: string }>; pushWarning?: string }
|
|
150
|
+
| { refused: string };
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* `chant ci evidence sign --from-job` (#4926): this run's id and commit from
|
|
154
|
+
* the job's environment (`GITHUB_RUN_ID` and `GITHUB_SHA` on GitHub and
|
|
155
|
+
* Forgejo, `CI_PIPELINE_ID` and `CI_COMMIT_SHA` on GitLab), the sources from
|
|
156
|
+
* `CHANT_EVIDENCE_SOURCES`, the checks {@link checksFromJob} allows, signed
|
|
157
|
+
* with the job's runner identity and pushed. Without a runner identity it
|
|
158
|
+
* signs nothing and says so, as `sign` does.
|
|
159
|
+
*/
|
|
160
|
+
export async function signFromJob(input: SignFromJobInput): Promise<SignFromJobResult> {
|
|
161
|
+
const env = input.env ?? process.env;
|
|
162
|
+
const log = input.log ?? ((line: string) => console.error(line));
|
|
163
|
+
const rawRun = env.GITHUB_RUN_ID ?? env.CI_PIPELINE_ID;
|
|
164
|
+
const sha = env.GITHUB_SHA ?? env.CI_COMMIT_SHA;
|
|
165
|
+
if (!rawRun || !/^\d+$/.test(rawRun) || !sha) return { refused: "--from-job reads this run from the job's environment: GITHUB_RUN_ID and GITHUB_SHA, or CI_PIPELINE_ID and CI_COMMIT_SHA" };
|
|
166
|
+
let commit: string;
|
|
167
|
+
try {
|
|
168
|
+
commit = commitAndTree(input.repo, input.at ?? sha).commit;
|
|
169
|
+
} catch {
|
|
170
|
+
return { refused: `${input.at ?? sha} is not a commit in this checkout; fetch the run's commit first` };
|
|
171
|
+
}
|
|
172
|
+
if (commit !== sha) return { refused: `--at names ${commit.slice(0, 12)}, and this run is for ${sha.slice(0, 12)}; --from-job signs only the run's own commit` };
|
|
173
|
+
const parsed = parseEvidenceSources(env[EVIDENCE_SOURCES_ENV]);
|
|
174
|
+
if ("problem" in parsed) return { refused: parsed.problem };
|
|
175
|
+
const decided = await checksFromJob({ reads: input.reads, run: Number(rawRun), sha, fromJob: input.fromJob, checks: input.checks, sources: parsed.sources, ...(input.claims !== undefined ? { claims: input.claims } : {}) });
|
|
176
|
+
if ("refused" in decided) return decided;
|
|
177
|
+
for (const s of decided.skipped) log(`ci evidence: ${s.check} not signed: ${s.reason}`);
|
|
178
|
+
if (decided.sign.length === 0) return { signed: [], skipped: decided.skipped };
|
|
179
|
+
const signer = await runnerEvidenceSigner(input.repo, input.base, { env, ...(input.key ? { key: input.key } : {}), ...(input.fetch ? { fetch: input.fetch } : {}) });
|
|
180
|
+
if (!signer) {
|
|
181
|
+
log(`ci evidence: ${noRunnerIdentity()}, so no check was signed`);
|
|
182
|
+
return { signed: [], skipped: [...decided.skipped, ...decided.sign.map((s) => ({ check: s.check, reason: noRunnerIdentity() }))] };
|
|
183
|
+
}
|
|
184
|
+
const signed = await signChecks(input.repo, commit, decided.sign, signer);
|
|
185
|
+
const pushed = await recordChecks(input.repo, signed, { push: input.push !== false });
|
|
186
|
+
const bySource = new Map(decided.sign.map((s) => [s.check, s.source]));
|
|
187
|
+
for (const s of signed) log(`ci evidence: signed ${s.check} at ${s.commit.slice(0, 12)} as ${s.runner}, from job ${bySource.get(s.check)!.job}${bySource.get(s.check)!.step ? ` step ${JSON.stringify(bySource.get(s.check)!.step)}` : ""} of run ${rawRun}`);
|
|
188
|
+
const warning = input.push !== false && !pushed.pushed ? pushed.pushWarning : undefined;
|
|
189
|
+
if (warning) log(`ci evidence: the evidence is attached here, and the push did not land: ${warning}`);
|
|
190
|
+
return {
|
|
191
|
+
signed: signed.map((s) => ({ check: s.check, runner: s.runner, commit: s.commit, tree: s.tree, source: bySource.get(s.check)! })),
|
|
192
|
+
skipped: decided.skipped,
|
|
193
|
+
...(warning ? { pushWarning: warning } : {}),
|
|
194
|
+
};
|
|
195
|
+
}
|
package/src/ci-evidence-jobs.ts
CHANGED
|
@@ -14,16 +14,30 @@
|
|
|
14
14
|
* before posting the note, which then says which checks were signed. The
|
|
15
15
|
* key is in that one step, in a job that runs none of the change's code.
|
|
16
16
|
* GitLab posts its notes from a target-branch pipeline that reads every
|
|
17
|
-
* open merge request, so there a job of its own
|
|
18
|
-
* (`<plan job>-evidence`) signs from
|
|
17
|
+
* open merge request, so there a job of its own in that pipeline, before
|
|
18
|
+
* the note job (`<plan job>-evidence`), signs from each merge request's
|
|
19
|
+
* plan job artifact (#4914): a merge request pipeline is built from the
|
|
20
|
+
* change's own files, so no job in it may hold the key. The signing job
|
|
21
|
+
* names the environment {@link GITLAB_EVIDENCE_ENVIRONMENT}, which the
|
|
22
|
+
* key's variable is scoped to, protected; the jobs that run the change
|
|
23
|
+
* name none, so GitLab never hands them the key.
|
|
19
24
|
* - A wave job (the waves pipeline) gets the key on its `chant run wave`
|
|
20
25
|
* step, and signs `plan:<wave>` and `policy:<wave>` once the wave is
|
|
21
|
-
* planned (../op/op-waves-evidence.ts).
|
|
26
|
+
* planned (../op/op-waves-evidence.ts). A wave with a policy runs it as a
|
|
27
|
+
* step of its own and a `<wave job>-evidence` job signs `policy:<wave>`
|
|
28
|
+
* from that step's result; a wave that trades cloud credentials and signs
|
|
29
|
+
* keyless signs `plan:<wave>` there too (#4926,
|
|
30
|
+
* ./op/op-waves-evidence-jobs.ts).
|
|
22
31
|
* - A product's check job runs `chant ci check` with the key in
|
|
23
32
|
* `CHANT_RUNNER_KEY`; the check runner signs each hook (./components/check-steps.ts).
|
|
24
33
|
*
|
|
25
|
-
*
|
|
26
|
-
* identity:
|
|
34
|
+
* With `identity: "oidc"` (#4869) the same steps sign keyless from the
|
|
35
|
+
* job's OIDC identity: no secret, `CHANT_RUNNER_IDENTITY=oidc` on the
|
|
36
|
+
* signing step, and the job asks the forge for a token, so no product adds
|
|
37
|
+
* that itself: `id-token: write` on GitHub (Forgejo's dialect turns it into
|
|
38
|
+
* `enable-openid-connect: true`), and on GitLab `id_tokens:` with
|
|
39
|
+
* `CHANT_ID_TOKEN_SIGSTORE` for the signing audience. `.chant/trust.json`
|
|
40
|
+
* at base lists the workflow's identity under `keyless`.
|
|
27
41
|
*/
|
|
28
42
|
|
|
29
43
|
import type { ForgeKind } from "./pr-forge";
|
|
@@ -31,24 +45,85 @@ import type { ForgeKind } from "./pr-forge";
|
|
|
31
45
|
/** The variable the signing steps read the key from. */
|
|
32
46
|
export const EVIDENCE_KEY_ENV = "CHANT_RUNNER_KEY";
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
/** The variable that makes a signing step sign keyless (#4869). */
|
|
49
|
+
export const EVIDENCE_IDENTITY_ENV = "CHANT_RUNNER_IDENTITY";
|
|
35
50
|
|
|
36
|
-
/**
|
|
51
|
+
/** The GitLab `id_tokens` variable a keyless signing job's token comes in (#4869). */
|
|
52
|
+
export const EVIDENCE_ID_TOKEN_VAR = "CHANT_ID_TOKEN_SIGSTORE";
|
|
53
|
+
|
|
54
|
+
/** The audience a keyless signing job's token is requested for unless told: sigstore's. */
|
|
55
|
+
export const EVIDENCE_DEFAULT_AUDIENCE = "sigstore";
|
|
56
|
+
|
|
57
|
+
export { CHECK_EVIDENCE_FLOOR, CHECK_JOB_FLOOR, GITLAB_OPEN_EVIDENCE_FLOOR, KEYLESS_EVIDENCE_FLOOR, LOCAL_EVIDENCE_FLOOR, PR_LOOP_EVIDENCE_FLOOR, REF_GATE_STATUS_JOB_FLOOR, WAVE_EVIDENCE_JOB_FLOOR } from "./release-floors";
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The GitLab environment every signing job names (#4914), with `action:
|
|
61
|
+
* access`, so it creates no deployment. Scope the runner key's CI/CD
|
|
62
|
+
* variable to it and protect it: GitLab then hands the key only to the
|
|
63
|
+
* signing jobs of a protected branch's pipeline, and to none of the jobs
|
|
64
|
+
* that run a merge request's code.
|
|
65
|
+
*/
|
|
66
|
+
export const GITLAB_EVIDENCE_ENVIRONMENT = "chant-evidence";
|
|
67
|
+
|
|
68
|
+
/** Where a GitLab signing job keeps what it signed for each merge request (#4914): `.chant/evidence/<job>/<iid>/evidence.json`. */
|
|
69
|
+
export function gitlabOpenEvidenceDir(job: string): string {
|
|
70
|
+
return `.chant/evidence/${job}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The lines of a GitLab signing job in the target branch's plan notes
|
|
75
|
+
* pipeline (#4914): `chant ci evidence sign --open` finds every open merge
|
|
76
|
+
* request's newest `job`, reads its report from the job's artifact at
|
|
77
|
+
* `dir`, fetches the head and signs it against the policy at the branch's
|
|
78
|
+
* commit, and keeps each merge request's `evidence.json` under `out`.
|
|
79
|
+
* With `noForks`, a merge request from a fork is not signed for, as a
|
|
80
|
+
* product plan with `forks: "skip"` plans none.
|
|
81
|
+
*/
|
|
82
|
+
export function openEvidenceLines(opts: { job: string; dir: string; out: string; bin?: string; noForks?: boolean }): string[] {
|
|
83
|
+
const chant = opts.bin ?? "chant";
|
|
84
|
+
return [`${chant} ci evidence sign --open --job ${opts.job} --from-report ${opts.dir} --base "$CI_COMMIT_SHA" --output ${opts.out}${opts.noForks ? " --no-forks" : ""}`];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A pipeline's runner identity (#4870): a runner key's secret, or (#4869)
|
|
89
|
+
* the job's own OIDC identity. Exactly one.
|
|
90
|
+
*/
|
|
37
91
|
export interface PipelineEvidence {
|
|
38
92
|
/** The secret (GitHub, Forgejo) or CI/CD variable (GitLab) holding the runner key as PEM. */
|
|
39
|
-
runnerKeySecret
|
|
93
|
+
runnerKeySecret?: string;
|
|
94
|
+
/** `oidc` (#4869): sign keyless from the job's OIDC identity, which `.chant/trust.json` at base lists under `keyless.identities`. */
|
|
95
|
+
identity?: "oidc";
|
|
96
|
+
/** With `identity`: the token's audience, as `keyless.audience` in `.chant/trust.json` says. Default `sigstore`. */
|
|
97
|
+
audience?: string;
|
|
40
98
|
}
|
|
41
99
|
|
|
42
100
|
const SECRET_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
43
101
|
|
|
44
|
-
/** Refuse a secret name the forge could not hold. */
|
|
102
|
+
/** Refuse a secret name the forge could not hold, and an evidence block that names both identities or neither. */
|
|
45
103
|
export function assertPipelineEvidence(evidence: PipelineEvidence | undefined): void {
|
|
46
104
|
if (evidence === undefined) return;
|
|
105
|
+
if (evidence.identity !== undefined) {
|
|
106
|
+
if (evidence.runnerKeySecret !== undefined) throw new Error("evidence names a runnerKeySecret and an identity; a pipeline signs with one of them (#4869)");
|
|
107
|
+
if (evidence.identity !== "oidc") throw new Error(`evidence.identity ${JSON.stringify(evidence.identity)} is not oidc, the one identity chant signs with keyless`);
|
|
108
|
+
if (evidence.audience !== undefined && !/^[\x21-\x7e]+$/.test(evidence.audience)) throw new Error(`evidence.audience ${JSON.stringify(evidence.audience)} is not printable ASCII with no space`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
47
111
|
if (!SECRET_NAME.test(evidence.runnerKeySecret ?? "")) throw new Error(`evidence.runnerKeySecret ${JSON.stringify(evidence.runnerKeySecret)} is not a secret name: letters, digits and _, not starting with a digit`);
|
|
48
112
|
}
|
|
49
113
|
|
|
50
|
-
/**
|
|
114
|
+
/** Whether the pipeline signs keyless (#4869), so its signing jobs ask the forge for an OIDC token. */
|
|
115
|
+
export function evidenceKeyless(evidence: PipelineEvidence | undefined): boolean {
|
|
116
|
+
return evidence?.identity === "oidc";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The GitLab `id_tokens:` a keyless signing job requests (#4869); empty with a runner key. */
|
|
120
|
+
export function evidenceIdTokens(evidence: PipelineEvidence | undefined): Record<string, { aud: string }> {
|
|
121
|
+
return evidenceKeyless(evidence) ? { [EVIDENCE_ID_TOKEN_VAR]: { aud: evidence!.audience ?? EVIDENCE_DEFAULT_AUDIENCE } } : {};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The signing step's variables: the key from the forge's secret, or (#4869) `CHANT_RUNNER_IDENTITY=oidc`. */
|
|
51
125
|
export function evidenceKeyEnv(forge: ForgeKind, evidence: PipelineEvidence): Record<string, string> {
|
|
126
|
+
if (evidenceKeyless(evidence)) return { [EVIDENCE_IDENTITY_ENV]: "oidc" };
|
|
52
127
|
return { [EVIDENCE_KEY_ENV]: forge === "gitlab" ? `$${evidence.runnerKeySecret}` : `\${{ secrets.${evidence.runnerKeySecret} }}` };
|
|
53
128
|
}
|
|
54
129
|
|
package/src/ci-handover.ts
CHANGED
|
@@ -77,10 +77,23 @@ export const NO_FORGE_TOKEN_MARKER = "CHANT_NO_FORGE_TOKEN";
|
|
|
77
77
|
* `$0` is that file. terragucci's `restartWithout` (render.ts:1826).
|
|
78
78
|
*/
|
|
79
79
|
export function dropForgeTokens(shell: "sh" | "bash" = "sh", extra: readonly string[] = []): string {
|
|
80
|
-
const again = shell === "bash" ? 'bash --noprofile --norc -e -o pipefail "$0"' : 'sh -e "$0"';
|
|
81
|
-
const marker = NO_FORGE_TOKEN_MARKER;
|
|
82
80
|
// #4296: a plan job that traded its OIDC token drops the variables a token is requested with too.
|
|
83
|
-
|
|
81
|
+
return restartWithout(shell, [...FORGE_TOKEN_VARS, ...extra], NO_FORGE_TOKEN_MARKER);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The line that restarts the step's shell once without `vars` in its
|
|
86
|
+
* process environment, setting `marker` so the restarted shell does not
|
|
87
|
+
* restart again, or, when it cannot restart, unsets them (#4912). The
|
|
88
|
+
* restart runs the step's script file (`$0`) again from its first line,
|
|
89
|
+
* with every exported variable but `vars`, so the line goes at the top of
|
|
90
|
+
* the step. It needs that file, `env` and the shell on the PATH; without
|
|
91
|
+
* them (a script given to `sh -c`, GitLab's piped script) the shell unsets
|
|
92
|
+
* `vars` and runs on. {@link dropForgeTokens} and ci-login's `restart` use
|
|
93
|
+
* it. terragucci's `restartWithout` (render.ts:2101).
|
|
94
|
+
*/
|
|
95
|
+
export function restartWithout(shell: "sh" | "bash", vars: readonly string[], marker: string): string {
|
|
96
|
+
const again = shell === "bash" ? 'bash --noprofile --norc -e -o pipefail "$0"' : 'sh -e "$0"';
|
|
84
97
|
const can = `[ -z "\${${marker}:-}" ] && [ "\${0#*/}" != "$0" ] && [ -f "$0" ] && ! { [ "\${0##*/}" = sh ] || [ "\${0##*/}" = bash ] || [ "\${0##*/}" = dash ]; } && command -v env >/dev/null 2>&1 && command -v ${shell} >/dev/null 2>&1`;
|
|
85
98
|
return `if ${can}; then exec env ${vars.map((v) => `-u ${v}`).join(" ")} ${marker}=1 ${again}; fi; unset ${vars.join(" ")}`;
|
|
86
99
|
}
|
package/src/ci-identity.test.ts
CHANGED
|
@@ -84,11 +84,11 @@ describe("the trade script stays inside one shell word", () => {
|
|
|
84
84
|
test("it holds no single quote, so tradeLine can quote it", () => {
|
|
85
85
|
expect(TRADE_JS).not.toContain("'");
|
|
86
86
|
});
|
|
87
|
-
test("GitLab's lines trade, unset the token variables and the extra ones, then
|
|
87
|
+
test("GitLab's lines trade into a shell variable, unset the token variables and the extra ones, then evaluate the credentials (#4912)", () => {
|
|
88
88
|
const [trade, unset, source] = gitlabTradeLines(["CHANT_FORGE_TOKEN"]);
|
|
89
|
-
expect(trade).
|
|
89
|
+
expect(trade).toMatch(/^CHANT_CLOUD_TRADE_VARS="\$\(cd \/ && node -e '.*' "-" sh\)"$/);
|
|
90
90
|
expect(unset).toBe(`unset CHANT_FORGE_TOKEN ${OIDC_REQUEST_VARS.join(" ")}`);
|
|
91
|
-
expect(source).
|
|
91
|
+
expect(source).toBe('eval "$CHANT_CLOUD_TRADE_VARS"; unset CHANT_CLOUD_TRADE_VARS');
|
|
92
92
|
expect(gitlabTradeIdTokens(resolveCloudIdentity(DECL, "prod", "app")!.plan)).toEqual({
|
|
93
93
|
CHANT_ID_TOKEN_AWS: { aud: "sts.amazonaws.com" },
|
|
94
94
|
CHANT_ID_TOKEN_GCP: { aud: "https://iam.googleapis.com/projects/123/locations/global/workloadIdentityPools/ci/providers/forge" },
|
package/src/ci-identity.ts
CHANGED
|
@@ -124,7 +124,12 @@ export interface GcpCloudIdentity {
|
|
|
124
124
|
provider: string;
|
|
125
125
|
/** The OIDC token's audience. Default `https://iam.googleapis.com/<provider>`. */
|
|
126
126
|
audience?: string;
|
|
127
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Google's STS, for a regional endpoint or an emulator: its base URL, to
|
|
129
|
+
* which `/v1/token` is added, or its full token URL, one that ends in
|
|
130
|
+
* `/token` (#4912, terragucci's `token_url`). Default
|
|
131
|
+
* `https://sts.googleapis.com`.
|
|
132
|
+
*/
|
|
128
133
|
stsEndpoint?: string;
|
|
129
134
|
/** IAM credentials, for an emulator. Default `https://iamcredentials.googleapis.com`. */
|
|
130
135
|
iamEndpoint?: string;
|
|
@@ -569,8 +574,9 @@ export const TRADED_VARS: Record<IdentityCloud, readonly string[]> = {
|
|
|
569
574
|
/**
|
|
570
575
|
* How the trade leaves what it got. `github-env`: `NAME=value` lines
|
|
571
576
|
* appended to the file argv 1 names (`$GITHUB_ENV`), and an `::add-mask::`
|
|
572
|
-
* line for each secret, so every later step of the job has them. `sh`:
|
|
573
|
-
*
|
|
577
|
+
* line for each secret, so every later step of the job has them. `sh`:
|
|
578
|
+
* `export` lines, printed when argv 1 is `-` (GitLab's script captures and
|
|
579
|
+
* evaluates them, #4912), else written to that file, mode 0600.
|
|
574
580
|
*/
|
|
575
581
|
export type TradeFormat = "github-env" | "sh";
|
|
576
582
|
|
|
@@ -582,6 +588,22 @@ export type TradeFormat = "github-env" | "sh";
|
|
|
582
588
|
*/
|
|
583
589
|
export const CLOUD_TARGETS_ENV = "CHANT_CLOUD_TARGETS";
|
|
584
590
|
|
|
591
|
+
/**
|
|
592
|
+
* The variable the trade sets (#4930): the clouds it traded the job's
|
|
593
|
+
* token for, comma-separated (`aws,gcp`). The trade and ci-login's login
|
|
594
|
+
* both write a {@link CLOUD_TARGETS_ENV} file, so a product that hands a
|
|
595
|
+
* target traded credentials (terragucci's re-plan) reads this, not the
|
|
596
|
+
* file, to know the job traded. The login never sets it.
|
|
597
|
+
*/
|
|
598
|
+
export const CLOUD_TRADED_ENV = "CHANT_CLOUD_TRADED";
|
|
599
|
+
|
|
600
|
+
/** The clouds the job's trade traded for, from {@link CLOUD_TRADED_ENV}: none when the job did not trade, such as after ci-login's login (#4930). */
|
|
601
|
+
export function cloudsTraded(env: Readonly<Record<string, string | undefined>>): IdentityCloud[] {
|
|
602
|
+
const v = env[CLOUD_TRADED_ENV];
|
|
603
|
+
if (!v) return [];
|
|
604
|
+
return v.split(",").filter((c): c is IdentityCloud => (IDENTITY_CLOUDS as readonly string[]).includes(c));
|
|
605
|
+
}
|
|
606
|
+
|
|
585
607
|
/** The file {@link CLOUD_TARGETS_ENV} names: per cloud, the job's own identity, the targets that take another, and each identity's variables. */
|
|
586
608
|
export interface CloudTargetsFile {
|
|
587
609
|
version: 1;
|
|
@@ -633,7 +655,8 @@ export const TRADE_JS = [
|
|
|
633
655
|
"if(a.role)Object.assign(vars,by.aws[a.role])}",
|
|
634
656
|
'if(spec.gcp){const c=spec.gcp;const tok=await idToken("gcp",c.audience);by.gcp={};',
|
|
635
657
|
'const sts=trim(c.stsEndpoint||"https://sts.googleapis.com"),iam=trim(c.iamEndpoint||"https://iamcredentials.googleapis.com");',
|
|
636
|
-
'
|
|
658
|
+
// #4912: stsEndpoint is Google's STS, or its full token URL (terragucci's `token_url`).
|
|
659
|
+
'const fed=json(await post(/\\/token$/.test(sts)?sts:sts+"/v1/token",{"content-type":"application/json"},JSON.stringify({grantType:"urn:ietf:params:oauth:grant-type:token-exchange",audience:"//iam.googleapis.com/"+c.provider,scope:"https://www.googleapis.com/auth/cloud-platform",requestedTokenType:"urn:ietf:params:oauth:token-type:access_token",subjectToken:tok,subjectTokenType:"urn:ietf:params:oauth:token-type:jwt"})),"Google STS").access_token;',
|
|
637
660
|
'if(!clean(fed))throw new Error("Google STS gave no token");',
|
|
638
661
|
'for(const sa of ids("gcp")){',
|
|
639
662
|
'const at=json(await post(iam+"/v1/projects/-/serviceAccounts/"+encodeURIComponent(sa)+":generateAccessToken",{"content-type":"application/json",authorization:"Bearer "+fed},JSON.stringify({scope:["https://www.googleapis.com/auth/cloud-platform"]})),"IAM credentials").accessToken;',
|
|
@@ -665,9 +688,11 @@ export const TRADE_JS = [
|
|
|
665
688
|
'const doc={version:1,clouds:{}};for(const c of clouds){const s=spec[c];doc.clouds[c]={...(s[KEY[c]]?{default:s[KEY[c]]}:{}),targets:(s.targets||[]).map((t)=>({targets:t.targets,identity:t[KEY[c]]})),vars:by[c]}}',
|
|
666
689
|
'const tf=trim(process.env.RUNNER_TEMP||process.env.TMPDIR||"/tmp")+"/chant-cloud-targets-"+require("crypto").randomBytes(8).toString("hex")+".json";',
|
|
667
690
|
`fs.writeFileSync(tf,JSON.stringify(doc),{mode:0o600,flag:"wx"});vars.${CLOUD_TARGETS_ENV}=tf}`,
|
|
691
|
+
// #4930: which clouds this job traded, so a product tells the trade's targets file from a login's.
|
|
692
|
+
`if(clouds.length)vars.${CLOUD_TRADED_ENV}=clouds.join(",");`,
|
|
668
693
|
'for(const [k,v] of Object.entries(vars))if(!clean(v))throw new Error(k+" is not a value the job can hold");',
|
|
669
694
|
'if(format==="github-env"){for(const s of secrets)console.log("::add-mask::"+s);fs.appendFileSync(out,Object.entries(vars).map(([k,v])=>k+"="+v+"\\n").join(""))}',
|
|
670
|
-
'else
|
|
695
|
+
'else{const sh=Object.entries(vars).map(([k,v])=>"export "+k+"="+Q+v.split(Q).join(Q+"\\\\"+Q+Q)+Q+"\\n").join("");if(out==="-")process.stdout.write(sh);else fs.writeFileSync(out,sh,{mode:0o600})}',
|
|
671
696
|
'for(const s of said)console.error("chant: traded the job\\u0027s OIDC token for "+s)};',
|
|
672
697
|
"run().catch((e)=>fail(e&&e.message?e.message:String(e)));",
|
|
673
698
|
].join("");
|
|
@@ -681,19 +706,30 @@ export function tradeLine(out: string, format: TradeFormat): string {
|
|
|
681
706
|
return `(cd / && node -e '${TRADE_JS}' "${out}" ${format})`;
|
|
682
707
|
}
|
|
683
708
|
|
|
684
|
-
/**
|
|
709
|
+
/**
|
|
710
|
+
* The file GitLab's trade wrote and sourced before #4912. `gitlabTradeLines`
|
|
711
|
+
* writes none now; kept for a product that names it.
|
|
712
|
+
* @deprecated `gitlabTradeLines` captures the trade's `export` lines in {@link GITLAB_TRADE_VARS}.
|
|
713
|
+
*/
|
|
685
714
|
export const GITLAB_TRADE_FILE = "${TMPDIR:-/tmp}/chant-cloud-$CI_JOB_ID.sh";
|
|
686
715
|
|
|
716
|
+
/** The shell variable GitLab's script holds the trade's `export` lines in until it evaluates them (#4912), as ci-login's `CHANT_CLOUD_LOGIN_VARS`. Not exported, so no child sees it. */
|
|
717
|
+
export const GITLAB_TRADE_VARS = "CHANT_CLOUD_TRADE_VARS";
|
|
718
|
+
|
|
687
719
|
/**
|
|
688
720
|
* The lines a GitLab job's script starts with when it trades: the trade,
|
|
689
|
-
*
|
|
690
|
-
*
|
|
721
|
+
* its `export` lines captured in {@link GITLAB_TRADE_VARS}, the unset of
|
|
722
|
+
* the token variables (and, with `extraUnset`, the forge tokens'), and the
|
|
723
|
+
* evaluation of what the trade printed, then the unset of the variable
|
|
724
|
+
* that held it. No file of credentials is written (#4912), as ci-login's
|
|
725
|
+
* `gitlabCloudLogin`. An assignment's status is its command substitution's,
|
|
726
|
+
* so a failed trade stops the script.
|
|
691
727
|
*/
|
|
692
728
|
export function gitlabTradeLines(extraUnset: readonly string[] = []): string[] {
|
|
693
729
|
return [
|
|
694
|
-
tradeLine(
|
|
730
|
+
`${GITLAB_TRADE_VARS}="$${tradeLine("-", "sh")}"`,
|
|
695
731
|
`unset ${[...extraUnset, ...OIDC_REQUEST_VARS].join(" ")}`,
|
|
696
|
-
|
|
732
|
+
`eval "$${GITLAB_TRADE_VARS}"; unset ${GITLAB_TRADE_VARS}`,
|
|
697
733
|
];
|
|
698
734
|
}
|
|
699
735
|
|
|
@@ -702,6 +738,9 @@ export function gitlabTradeIdTokens(spec: CloudTradeSpec): Record<string, { aud:
|
|
|
702
738
|
return Object.fromEntries(tradedClouds(spec).map((c) => [idTokenVar(c), { aud: spec[c]!.audience }]));
|
|
703
739
|
}
|
|
704
740
|
|
|
741
|
+
/** The AWS region variables, which {@link targetCloudEnv} replaces only when the target's identity sets them. */
|
|
742
|
+
const JOB_REGION_VARS: ReadonlySet<string> = new Set(["AWS_REGION", "AWS_DEFAULT_REGION"]);
|
|
743
|
+
|
|
705
744
|
/**
|
|
706
745
|
* `env` for one target's tool (#4332): the job's environment with each
|
|
707
746
|
* cloud's credentials replaced by those of the identity `target` takes, as
|
|
@@ -722,7 +761,8 @@ export function targetCloudEnv(env: Readonly<Record<string, string | undefined>>
|
|
|
722
761
|
if (id === undefined || id === c.default) continue;
|
|
723
762
|
const vars = c.vars[id];
|
|
724
763
|
if (!vars) throw new Error(`${CLOUD_TARGETS_ENV} (${path}) holds no ${cloud} credentials for ${id}`);
|
|
725
|
-
|
|
764
|
+
// The region is the job's, not the identity's: a login that names none (#4930) leaves the job's in place, and a trade's identity sets its own.
|
|
765
|
+
for (const k of TRADED_VARS[cloud]) if (!JOB_REGION_VARS.has(k)) delete out[k];
|
|
726
766
|
Object.assign(out, vars);
|
|
727
767
|
}
|
|
728
768
|
return out;
|
package/src/ci-image.test.ts
CHANGED
|
@@ -7,7 +7,9 @@ import { crc32, deflateRawSync, gzipSync } from "node:zlib";
|
|
|
7
7
|
import { describe, expect, test } from "vitest";
|
|
8
8
|
import {
|
|
9
9
|
CI_BASE_IMAGES,
|
|
10
|
+
CI_IMAGE_DOCKER_STAGES_FLOOR,
|
|
10
11
|
CI_IMAGE_FLOOR,
|
|
12
|
+
CI_IMAGE_NON_ROOT_FLOOR,
|
|
11
13
|
CI_TOOL_DOCKER_ARCH,
|
|
12
14
|
CI_TOOL_SHA256,
|
|
13
15
|
CI_TOOLS,
|
|
@@ -163,8 +165,10 @@ describe("ciToolRelease", () => {
|
|
|
163
165
|
expect(() => ciToolSha256("tofu", "1.13.1", { amd64: "nothex" })).toThrow(/64 lower-case hex/);
|
|
164
166
|
});
|
|
165
167
|
|
|
166
|
-
test("CI_IMAGE_FLOOR is the next
|
|
167
|
-
expect(CI_IMAGE_FLOOR).toBe(
|
|
168
|
+
test("CI_IMAGE_FLOOR is the release that shipped it, and #4908's and #4932's floors the next", () => {
|
|
169
|
+
expect(CI_IMAGE_FLOOR).toBe("0.124.86");
|
|
170
|
+
expect(CI_IMAGE_NON_ROOT_FLOOR).toBe(NEXT_RELEASE);
|
|
171
|
+
expect(CI_IMAGE_DOCKER_STAGES_FLOOR).toBe(NEXT_RELEASE);
|
|
168
172
|
});
|
|
169
173
|
});
|
|
170
174
|
|
|
@@ -238,13 +242,13 @@ describe("ciToolFetchScript against local fixtures", () => {
|
|
|
238
242
|
test("a bare binary, and a zip's member, install as the command", () => {
|
|
239
243
|
const tg = Buffer.from("#!/bin/sh\necho terragrunt\n");
|
|
240
244
|
const out = tmp();
|
|
241
|
-
const s1 = ciToolFetchScript("terragrunt", "1.
|
|
245
|
+
const s1 = ciToolFetchScript("terragrunt", "1.1.0", { dir: `${out}/tg`, arch: CI_TOOL_DOCKER_ARCH });
|
|
242
246
|
expect(runShell(s1, { terragrunt_linux_arm64: tg, SHA256SUMS: `${sha(tg)} *terragrunt_linux_arm64\n` }, { TARGETARCH: "arm64" }).status).toBe(0);
|
|
243
247
|
expect(readFileSync(`${out}/tg/terragrunt`, "utf-8")).toContain("echo terragrunt");
|
|
244
248
|
|
|
245
249
|
const z = zip({ terraform: "#!/bin/sh\necho terraform\n", "LICENSE.txt": "x" });
|
|
246
|
-
const s2 = ciToolFetchScript("terraform", "1.14.
|
|
247
|
-
const r = runShell(s2, { "terraform_1.14.
|
|
250
|
+
const s2 = ciToolFetchScript("terraform", "1.14.8", { dir: `${out}/tf`, arch: CI_TOOL_DOCKER_ARCH });
|
|
251
|
+
const r = runShell(s2, { "terraform_1.14.8_linux_amd64.zip": z, "terraform_1.14.8_SHA256SUMS": `${sha(z)} terraform_1.14.8_linux_amd64.zip\n` }, { TARGETARCH: "amd64" });
|
|
248
252
|
expect(r.stderr).toBe("");
|
|
249
253
|
expect(readFileSync(`${out}/tf/terraform`, "utf-8")).toContain("echo terraform");
|
|
250
254
|
});
|
|
@@ -258,7 +262,7 @@ describe("ciToolFetchScript against local fixtures", () => {
|
|
|
258
262
|
|
|
259
263
|
test("refuses, before any shell, a release that needs a recorded sha256 it lacks", () => {
|
|
260
264
|
expect(() => ciToolFetchScript("act", "0.2.89", { dir: "/out/act" })).toThrow(/no recorded sha256 for act 0.2.89 on amd64 and arm64; act's release publishes no checksums file/);
|
|
261
|
-
expect(() => ciToolFetchScript("terragrunt", "1.
|
|
265
|
+
expect(() => ciToolFetchScript("terragrunt", "1.1.0", { dir: "/out/tg", requirePin: true })).toThrow(/no recorded sha256 for terragrunt 1.1.0/);
|
|
262
266
|
expect(() => ciToolFetchScript("tofu", "1.13.1", { dir: "/out/x y" })).toThrow(/absolute path/);
|
|
263
267
|
});
|
|
264
268
|
});
|
|
@@ -285,6 +289,52 @@ describe("ciToolInstallLine", () => {
|
|
|
285
289
|
});
|
|
286
290
|
});
|
|
287
291
|
|
|
292
|
+
describe("non-root job lines (#4908)", () => {
|
|
293
|
+
test("sudo writes the tool root and the link, and leaves the download and the check to the job's user", () => {
|
|
294
|
+
const line = ciToolInstallLine("tofu", "1.13.1", { sudo: true });
|
|
295
|
+
expect(line).toContain('sudo mkdir -p "/opt/chant/tofu-1.13.1"');
|
|
296
|
+
expect(line).toContain('sudo install -m 0755 "$t/tofu" "/opt/chant/tofu-1.13.1/tofu"');
|
|
297
|
+
expect(line.endsWith('sudo ln -sf "/opt/chant/tofu-1.13.1/tofu" /usr/local/bin/tofu')).toBe(true);
|
|
298
|
+
expect(line).not.toContain("sudo curl");
|
|
299
|
+
expect(line).not.toContain("sudo sha256sum");
|
|
300
|
+
expect(ciToolFetchScript("pulumi", "3.272.0", { dir: "/opt/p/pulumi-3.272.0", sudo: true })).toContain('sudo tar -xzf "$t/$f" -C "/opt/p/pulumi-3.272.0" --strip-components=1');
|
|
301
|
+
expect(ciToolInstallLine("aws-cli", "2.37.9", { sudo: true })).toContain('sudo "$t/aws/install" -i "/opt/chant/aws-cli-2.37.9" -b "/opt/chant/aws-cli-2.37.9/bin"');
|
|
302
|
+
expect(ciToolInstallLine("tofu", "1.13.1")).not.toContain("sudo");
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
test("a root and a binDir under a variable the job expands, quoted", () => {
|
|
306
|
+
const line = ciToolInstallLine("aws-cli", "2.37.9", { root: "$RUNNER_TEMP/chant-tools", binDir: "${HOME}/.local/bin/" });
|
|
307
|
+
expect(line.startsWith('{ [ -x "$RUNNER_TEMP/chant-tools/aws-cli-2.37.9/v2/current/bin/aws" ] || (set -e;')).toBe(true);
|
|
308
|
+
expect(line.endsWith('mkdir -p "${HOME}/.local/bin" && ln -sf "$RUNNER_TEMP/chant-tools/aws-cli-2.37.9/v2/current/bin/aws" "${HOME}/.local/bin/aws"')).toBe(true);
|
|
309
|
+
expect(ciToolBin("tofu", "1.13.1", "$RUNNER_TEMP/t")).toBe("$RUNNER_TEMP/t/tofu-1.13.1/tofu");
|
|
310
|
+
expect(() => ciToolInstallLine("tofu", "1.13.1", { root: "$(id)/x" })).toThrow(/tool root/);
|
|
311
|
+
expect(() => ciToolInstallLine("tofu", "1.13.1", { root: "relative/x" })).toThrow(/tool root/);
|
|
312
|
+
expect(() => ciToolInstallLine("tofu", "1.13.1", { binDir: "$HOME x" })).toThrow(/binDir/);
|
|
313
|
+
// An image's COPY expands no shell variable.
|
|
314
|
+
expect(() => productImageStages({ name: "p", product: "p", description: "d", source: "s", toolRoot: "$HOME/t", tools: [{ tool: "tofu", version: "1.13.1" }], bundle: { file: "a", bin: "a" } })).toThrow(/toolRoot/);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
test("runs as a user: installs under a variable root and links into a variable binDir", () => {
|
|
318
|
+
const a = tarGz({ tofu: "#!/bin/sh\necho user-install\n" });
|
|
319
|
+
const home = tmp();
|
|
320
|
+
const line = ciToolInstallLine("tofu", "1.13.1", { root: "$TOOLS/t", binDir: "$TOOLS/bin", sha256: { amd64: sha(a), arm64: sha(a) } });
|
|
321
|
+
const files = { "tofu_1.13.1_linux_amd64.tar.gz": a, "tofu_1.13.1_linux_arm64.tar.gz": a, "tofu_1.13.1_SHA256SUMS": `${sha(a)} tofu_1.13.1_linux_amd64.tar.gz\n${sha(a)} tofu_1.13.1_linux_arm64.tar.gz\n` };
|
|
322
|
+
const r = runShell(line, files, { TOOLS: home });
|
|
323
|
+
expect(r.stderr).toBe("");
|
|
324
|
+
expect(r.status).toBe(0);
|
|
325
|
+
expect(readFileSync(`${home}/bin/tofu`, "utf-8")).toContain("echo user-install");
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
test("chant records terragucci's terraform and terragrunt pins and its drift job's AWS CLI", () => {
|
|
329
|
+
expect(ciToolSha256("terraform", "1.14.9")).toEqual({ amd64: "2e5cffc20a0b48a67a76268723bd5a10b8666f69b2aa4f04906e206726bedd63", arm64: "863002085b886453795d9ff4b8989b8468784478150b70ba8a1df3e3ad66da99" });
|
|
330
|
+
expect(ciToolSha256("terragrunt", "1.2.0")).toEqual({ amd64: "45b6df8a8494c8cfe34b4abf919e894709557163e4d3b5704d11083002ab787a", arm64: "b069ce4310572bc46ee6f057057acc4bc6a9077ef8687e157a64b0551290a371" });
|
|
331
|
+
expect(ciToolSha256("aws-cli", "2.37.9")).toEqual({ amd64: "6b3a6a3d7bb3997928f0bdf7b866914224abf242c2e54e1dcebbe84bee64f356", arm64: "e7d2cca3622af4765871fe9ce7eeed03acd09dca10a99ebc46e92f79d78765c0" });
|
|
332
|
+
// So an image carries them with no sums of the product's, and a job line can require the pin.
|
|
333
|
+
expect(() => productImageStages({ name: "t", product: "t", description: "d", source: "s", tools: [{ tool: "terraform", version: "1.14.9" }, { tool: "terragrunt", version: "1.2.0" }], bundle: { file: "a", bin: "a" } })).not.toThrow();
|
|
334
|
+
expect(ciToolInstallLine("terragrunt", "1.2.0", { requirePin: true, sudo: true, link: false })).toContain("want=45b6df8a");
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
288
338
|
describe("installCiTool", () => {
|
|
289
339
|
const a = tarGz({ tofu: "#!/bin/sh\necho node-install\n" });
|
|
290
340
|
const base = "https://github.com/opentofu/opentofu/releases/download/v1.13.1";
|
|
@@ -332,9 +382,9 @@ describe("installCiTool", () => {
|
|
|
332
382
|
test("unpacks a zip's member, a bare binary and a tree", async () => {
|
|
333
383
|
const root = tmp();
|
|
334
384
|
const z = zip({ terraform: "tf" });
|
|
335
|
-
const tf = "https://releases.hashicorp.com/terraform/1.14.
|
|
336
|
-
await installCiTool("terraform", "1.14.
|
|
337
|
-
expect(readFileSync(join(root, "terraform-1.14.
|
|
385
|
+
const tf = "https://releases.hashicorp.com/terraform/1.14.8";
|
|
386
|
+
await installCiTool("terraform", "1.14.8", { ...opts, root, download: served({ [`${tf}/terraform_1.14.8_linux_amd64.zip`]: z, [`${tf}/terraform_1.14.8_SHA256SUMS`]: `${sha(z)} terraform_1.14.8_linux_amd64.zip\n` }).download });
|
|
387
|
+
expect(readFileSync(join(root, "terraform-1.14.8", "terraform"), "utf-8")).toBe("tf");
|
|
338
388
|
|
|
339
389
|
const cosign = Buffer.from("cosign");
|
|
340
390
|
const cb = "https://github.com/sigstore/cosign/releases/download/v2.6.5";
|
|
@@ -407,7 +457,7 @@ describe("productImageStages", () => {
|
|
|
407
457
|
});
|
|
408
458
|
|
|
409
459
|
test("an image refuses an engine with no recorded sha256", () => {
|
|
410
|
-
expect(() => productImageStages({ ...terragucci, tools: [{ tool: "terragrunt", version: "1.
|
|
460
|
+
expect(() => productImageStages({ ...terragucci, tools: [{ tool: "terragrunt", version: "1.1.0" }] })).toThrow(/no recorded sha256 for terragrunt 1.1.0 on amd64 and arm64/);
|
|
411
461
|
expect(() => productImageStages({ ...terragucci, tools: [{ tool: "tofu", version: "1.13.1" }, { tool: "tofu", version: "1.13.1" }] })).toThrow(/listed twice/);
|
|
412
462
|
});
|
|
413
463
|
|