@intentius/chant 0.124.40 → 0.124.41
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/__fixtures__/oidc-emulator.d.ts +49 -0
- package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -0
- package/dist/__fixtures__/oidc-emulator.js +89 -0
- package/dist/ci-handover.d.ts +117 -0
- package/dist/ci-handover.d.ts.map +1 -0
- package/dist/ci-handover.js +217 -0
- package/dist/ci-identity.d.ts +190 -0
- package/dist/ci-identity.d.ts.map +1 -0
- package/dist/ci-identity.js +219 -0
- package/dist/cli/handlers/approve.d.ts +2 -1
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +20 -6
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +15 -1
- package/dist/cli/handlers/fan-out.js +16 -3
- package/dist/cli/handlers/gate-resume.d.ts +3 -0
- package/dist/cli/handlers/gate-resume.d.ts.map +1 -1
- package/dist/cli/handlers/gate-resume.js +15 -2
- package/dist/cli/handlers/lock.d.ts +8 -0
- package/dist/cli/handlers/lock.d.ts.map +1 -0
- package/dist/cli/handlers/lock.js +197 -0
- package/dist/cli/handlers/pr-env.d.ts +34 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -0
- package/dist/cli/handlers/pr-env.js +436 -0
- package/dist/cli/handlers/pr.d.ts +74 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +503 -53
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +9 -0
- package/dist/cli/handlers/query.d.ts +6 -0
- package/dist/cli/handlers/query.d.ts.map +1 -0
- package/dist/cli/handlers/query.js +80 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +41 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +31 -2
- package/dist/cli/registry.d.ts +12 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/fan-out-run.d.ts +28 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +27 -3
- package/dist/components/pr-environment.d.ts +298 -0
- package/dist/components/pr-environment.d.ts.map +1 -0
- package/dist/components/pr-environment.js +406 -0
- package/dist/components/pr-hooks.d.ts +66 -0
- package/dist/components/pr-hooks.d.ts.map +1 -0
- package/dist/components/pr-hooks.js +119 -0
- package/dist/components/pr-pipeline.d.ts +72 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +96 -5
- package/dist/components/pr-policy.d.ts +109 -0
- package/dist/components/pr-policy.d.ts.map +1 -0
- package/dist/components/pr-policy.js +150 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +5 -3
- package/dist/gate-decision.d.ts +15 -2
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +17 -2
- package/dist/gate-policy.d.ts +140 -0
- package/dist/gate-policy.d.ts.map +1 -0
- package/dist/gate-policy.js +242 -0
- package/dist/lifecycle/gate-checkpoint.d.ts +1 -1
- package/dist/lifecycle/gate-checkpoint.js +1 -1
- package/dist/{workspace/trust → lifecycle}/gate-seal.d.ts +1 -1
- package/dist/lifecycle/gate-seal.d.ts.map +1 -0
- package/dist/lifecycle/query.d.ts +68 -0
- package/dist/lifecycle/query.d.ts.map +1 -0
- package/dist/lifecycle/query.js +246 -0
- package/dist/lifecycle/run-ledger.d.ts +13 -0
- package/dist/lifecycle/run-ledger.d.ts.map +1 -1
- package/dist/lifecycle/run-ledger.js +16 -0
- package/dist/lifecycle/target-lock.d.ts +97 -0
- package/dist/lifecycle/target-lock.d.ts.map +1 -0
- package/dist/lifecycle/target-lock.js +286 -0
- package/dist/op/activities/activity-contracts.d.ts +30 -0
- package/dist/op/activities/activity-contracts.d.ts.map +1 -1
- package/dist/op/activities/activity-contracts.js +26 -0
- package/dist/op/activities/index.d.ts +2 -0
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/index.js +4 -0
- package/dist/op/activities/review-agent.d.ts +137 -0
- package/dist/op/activities/review-agent.d.ts.map +1 -0
- package/dist/op/activities/review-agent.js +266 -0
- package/dist/op/builders.d.ts +9 -0
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/op/builders.js +11 -0
- package/dist/op/cron.d.ts +8 -0
- package/dist/op/cron.d.ts.map +1 -1
- package/dist/op/cron.js +51 -0
- package/dist/op/gate-approval.d.ts +20 -13
- package/dist/op/gate-approval.d.ts.map +1 -1
- package/dist/op/gate-approval.js +13 -18
- package/dist/op/gate-quorum.d.ts +131 -0
- package/dist/op/gate-quorum.d.ts.map +1 -0
- package/dist/op/gate-quorum.js +183 -0
- package/dist/op/gate-resume.d.ts +4 -2
- package/dist/op/gate-resume.d.ts.map +1 -1
- package/dist/op/gate-resume.js +5 -4
- package/dist/op/gate-review.js +1 -1
- package/dist/op/gate.d.ts +32 -4
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +40 -24
- package/dist/op/index.d.ts +6 -4
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +4 -3
- package/dist/op/local-executor.d.ts.map +1 -1
- package/dist/op/local-executor.js +9 -3
- package/dist/op/op-waves-run.d.ts +62 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +190 -11
- package/dist/op/op-waves.d.ts +55 -3
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +63 -8
- package/dist/op/schedule-overdue.d.ts +57 -0
- package/dist/op/schedule-overdue.d.ts.map +1 -0
- package/dist/op/schedule-overdue.js +138 -0
- package/dist/override-gate.d.ts +2 -2
- package/dist/override-gate.d.ts.map +1 -1
- package/dist/override-gate.js +1 -1
- package/dist/pr-forge.d.ts +36 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +82 -0
- package/dist/pr-loop.d.ts +90 -1
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +77 -3
- package/dist/pr-post.d.ts +72 -0
- package/dist/pr-post.d.ts.map +1 -0
- package/dist/pr-post.js +134 -0
- package/dist/wave-blocked.d.ts +79 -0
- package/dist/wave-blocked.d.ts.map +1 -0
- package/dist/wave-blocked.js +245 -0
- package/dist/wave-engine.d.ts +6 -0
- package/dist/wave-engine.d.ts.map +1 -1
- package/dist/wave-engine.js +2 -0
- package/dist/wave-runtime.mjs +242 -242
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts +1 -0
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts.map +1 -1
- package/dist/workspace/__fixtures__/two-member-workspace.js +1 -1
- package/dist/workspace/ci-branches.d.ts +51 -0
- package/dist/workspace/ci-branches.d.ts.map +1 -0
- package/dist/workspace/ci-branches.js +69 -0
- package/dist/workspace/ci-cloud-identity.d.ts +11 -0
- package/dist/workspace/ci-cloud-identity.d.ts.map +1 -0
- package/dist/workspace/ci-cloud-identity.js +24 -0
- package/dist/workspace/ci-locks.d.ts +12 -0
- package/dist/workspace/ci-locks.d.ts.map +1 -0
- package/dist/workspace/ci-locks.js +6 -0
- package/dist/workspace/ci-run.d.ts +17 -1
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +64 -3
- package/dist/workspace/declaration.d.ts +63 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +72 -1
- package/dist/workspace/declaration.schema.json +147 -0
- package/dist/workspace/identity-gate-rule.d.ts +1 -1
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +1 -1
- package/dist/workspace/identity.d.ts +1 -1
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.js +8 -5
- package/dist/workspace/member-pipeline.d.ts +6 -0
- package/dist/workspace/member-pipeline.d.ts.map +1 -1
- package/dist/workspace/member-pipeline.js +23 -0
- package/dist/workspace/pr-report.schema.json +73 -2
- package/dist/workspace/security.d.ts.map +1 -1
- package/dist/workspace/security.js +4 -0
- package/dist/workspace/status-gates.d.ts +3 -2
- package/dist/workspace/status-gates.d.ts.map +1 -1
- package/dist/workspace/status-gates.js +8 -7
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/status.js +4 -1
- package/dist/workspace/trust/seal.d.ts +2 -2
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +2 -2
- package/package.json +1 -1
- package/src/__fixtures__/oidc-emulator.ts +118 -0
- package/src/ci-handover.test.ts +209 -0
- package/src/ci-handover.ts +237 -0
- package/src/ci-identity.test.ts +201 -0
- package/src/ci-identity.ts +310 -0
- package/src/cli/handlers/approve.ts +18 -5
- package/src/cli/handlers/build.ts +15 -1
- package/src/cli/handlers/fan-out.ts +17 -4
- package/src/cli/handlers/gate-resume.ts +16 -2
- package/src/cli/handlers/lock.test.ts +98 -0
- package/src/cli/handlers/lock.ts +202 -0
- package/src/cli/handlers/operator.test.ts +3 -1
- package/src/cli/handlers/pr-env.ts +462 -0
- package/src/cli/handlers/pr-waves-blocked.test.ts +247 -0
- package/src/cli/handlers/pr.test.ts +184 -0
- package/src/cli/handlers/pr.ts +496 -59
- package/src/cli/handlers/promote.ts +9 -0
- package/src/cli/handlers/query.ts +78 -0
- package/src/cli/main.ts +41 -2
- package/src/cli/parse-args.ts +23 -2
- package/src/cli/registry.ts +12 -2
- package/src/components/fan-out-run.ts +39 -2
- package/src/components/fan-out-waves.test.ts +45 -1
- package/src/components/pr-environment.test.ts +249 -0
- package/src/components/pr-environment.ts +538 -0
- package/src/components/pr-hooks.test.ts +118 -0
- package/src/components/pr-hooks.ts +157 -0
- package/src/components/pr-pipeline.ts +130 -5
- package/src/components/pr-policy.test.ts +145 -0
- package/src/components/pr-policy.ts +211 -0
- package/src/components/pr-run.ts +5 -2
- package/src/gate-decision-bundle.test.ts +4 -3
- package/src/gate-decision.ts +39 -2
- package/src/gate-policy-bundle.test.ts +28 -0
- package/src/gate-policy.test.ts +162 -0
- package/src/gate-policy.ts +298 -0
- package/src/lifecycle/gate-checkpoint.ts +1 -1
- package/src/{workspace/trust → lifecycle}/gate-seal.ts +1 -1
- package/src/lifecycle/query.test.ts +91 -0
- package/src/lifecycle/query.ts +315 -0
- package/src/lifecycle/run-ledger.ts +18 -0
- package/src/lifecycle/target-lock.test.ts +195 -0
- package/src/lifecycle/target-lock.ts +347 -0
- package/src/op/activities/activity-contracts.ts +31 -0
- package/src/op/activities/index.ts +6 -0
- package/src/op/activities/review-agent.test.ts +240 -0
- package/src/op/activities/review-agent.ts +355 -0
- package/src/op/builders.ts +13 -0
- package/src/op/cron.ts +44 -0
- package/src/op/gate-alias.test.ts +2 -2
- package/src/op/gate-approval.test.ts +30 -9
- package/src/op/gate-approval.ts +23 -26
- package/src/op/gate-quorum.test.ts +139 -0
- package/src/op/gate-quorum.ts +248 -0
- package/src/op/gate-resume.ts +6 -3
- package/src/op/gate-review.ts +1 -1
- package/src/op/gate.ts +64 -23
- package/src/op/index.ts +13 -1
- package/src/op/local-executor.ts +9 -2
- package/src/op/op-waves-hook-targets.test.ts +126 -0
- package/src/op/op-waves-policy-hold.test.ts +66 -0
- package/src/op/op-waves-quorum.test.ts +101 -0
- package/src/op/op-waves-run.ts +233 -11
- package/src/op/op-waves.ts +83 -10
- package/src/op/schedule-overdue.test.ts +220 -0
- package/src/op/schedule-overdue.ts +161 -0
- package/src/override-gate-bundle.test.ts +1 -1
- package/src/override-gate.ts +2 -2
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +33 -0
- package/src/pr-forge.ts +114 -0
- package/src/pr-loop-bundle.test.ts +2 -2
- package/src/pr-loop.test.ts +58 -0
- package/src/pr-loop.ts +146 -4
- package/src/pr-post.test.ts +141 -0
- package/src/pr-post.ts +159 -0
- package/src/wave-blocked-bundle.test.ts +25 -0
- package/src/wave-blocked.test.ts +146 -0
- package/src/wave-blocked.ts +271 -0
- package/src/wave-engine.ts +8 -0
- package/src/workspace/__fixtures__/two-member-workspace.ts +2 -2
- package/src/workspace/ci-branches.test.ts +62 -0
- package/src/workspace/ci-branches.ts +79 -0
- package/src/workspace/ci-cloud-identity.test.ts +53 -0
- package/src/workspace/ci-cloud-identity.ts +23 -0
- package/src/workspace/ci-locks.ts +16 -0
- package/src/workspace/ci-run-index.test.ts +2 -1
- package/src/workspace/ci-run.test.ts +107 -8
- package/src/workspace/ci-run.ts +72 -4
- package/src/workspace/declaration.schema.json +147 -0
- package/src/workspace/declaration.test.ts +76 -0
- package/src/workspace/declaration.ts +134 -2
- package/src/workspace/identity-gate-rule.ts +1 -1
- package/src/workspace/identity.ts +1 -1
- package/src/workspace/lineage-upgrade.ts +11 -8
- package/src/workspace/member-pipeline.test.ts +29 -0
- package/src/workspace/member-pipeline.ts +30 -0
- package/src/workspace/pr-report.schema.json +73 -2
- package/src/workspace/security.ts +4 -0
- package/src/workspace/status-gates.ts +9 -6
- package/src/workspace/status.ts +4 -1
- package/src/workspace/trust/gate-seal.test.ts +1 -1
- package/src/workspace/trust/seal.ts +2 -2
- package/dist/workspace/trust/gate-seal.d.ts.map +0 -1
- /package/dist/{workspace/trust → lifecycle}/gate-seal.js +0 -0
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* Its human quorum reaches back to `humanQuorumSince` (#3206), as a run's does.
|
|
20
20
|
*/
|
|
21
21
|
import { type GateApprovalRule } from "../op/gate.js";
|
|
22
|
+
import type { GateQuorumJudge } from "../op/gate-quorum.js";
|
|
22
23
|
import type { ReleaseRevocation } from "../lifecycle/release-revocation.js";
|
|
23
24
|
/** Why a member's gates can't be listed. Closed: a new code is a contract change. */
|
|
24
25
|
export declare const GATE_REASON_CODES: readonly ["gates-no-ledger", "gates-no-gate-ledger", "gates-ledger-unreadable"];
|
|
@@ -145,12 +146,12 @@ export declare function approveCommand(component: string, gate: string, env: str
|
|
|
145
146
|
* gate whose other facts have one is left out, as a run leaves it out: such a
|
|
146
147
|
* line binds no environment, and `chant approve --expire` writes one.
|
|
147
148
|
*/
|
|
148
|
-
export declare function gatesInLedger(component: string, content: string, envs: readonly string[], now: string, rules?: GateRuleLookup): {
|
|
149
|
+
export declare function gatesInLedger(component: string, content: string, envs: readonly string[], now: string, rules?: GateRuleLookup, judge?: GateQuorumJudge): {
|
|
149
150
|
gates: StatusGate[];
|
|
150
151
|
malformed: number;
|
|
151
152
|
};
|
|
152
153
|
/** Read one member's gate ledger directory at `commit` and list its gates. */
|
|
153
|
-
export declare function readMemberGates(dir: string, layout: "members" | "flat", commit: string | null, envs: readonly string[], cwd: string, now: string, read?: GateLedgerReader, rules?: GateRuleLookup, listChangeSets?: ChangeSetLister): Promise<{
|
|
154
|
+
export declare function readMemberGates(dir: string, layout: "members" | "flat", commit: string | null, envs: readonly string[], cwd: string, now: string, read?: GateLedgerReader, rules?: GateRuleLookup, listChangeSets?: ChangeSetLister, judge?: GateQuorumJudge): Promise<{
|
|
154
155
|
gates: StatusGate[];
|
|
155
156
|
ledger: StatusGateLedger;
|
|
156
157
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-gates.d.ts","sourceRoot":"","sources":["../../src/workspace/status-gates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAwC,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"status-gates.d.ts","sourceRoot":"","sources":["../../src/workspace/status-gates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAwC,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AASzE,qFAAqF;AACrF,eAAO,MAAM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AAM,CAEtI;AA4DD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,cAA2B,EAAE,KAAK,CAAC,EAAE,eAAe,GAAG;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAmB/M;AAED,8EAA8E;AAC9E,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,GAAG,MAAM,EAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,gBAA0C,EAChD,KAAK,GAAE,cAA2B,EAClC,cAAc,GAAE,eAAwC,EACxD,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC,CA8B5D"}
|
|
@@ -74,7 +74,7 @@ export function approveCommand(component, gate, env, planDigest, signed = false)
|
|
|
74
74
|
}
|
|
75
75
|
const approvalOf = (r) => ({ principal: r.resolvedBy, channel: r.origin ?? null, relayedBy: r.relayedBy ?? null, at: r.timestamp });
|
|
76
76
|
/** One gate in one environment, decided against its newest pending fact. */
|
|
77
|
-
function decide(component, standing, facts, all, now, rule) {
|
|
77
|
+
function decide(component, standing, facts, all, now, rule, judge) {
|
|
78
78
|
const gate = standing.gate;
|
|
79
79
|
// #3163: under identity.gates, an unsigned approval, or one from outside the class, doesn't count, as a run reads it.
|
|
80
80
|
// #4045: nor does an approval for another release, and an `empty` pass is never an approval.
|
|
@@ -93,8 +93,9 @@ function decide(component, standing, facts, all, now, rule) {
|
|
|
93
93
|
let mismatched;
|
|
94
94
|
if (standing.approval) {
|
|
95
95
|
// #3206: a human approval from before a fact re-recorded for a mode or context change still counts.
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
// #4290: approval rules count roles from .chant/trust.json at base, for a proven approver.
|
|
97
|
+
const tally = tallyGateApprovals(own, gate, since, planDigest, standing.approval, humanQuorumSince(facts, standing), judge);
|
|
98
|
+
approved = tally.permit !== undefined || tally.met;
|
|
98
99
|
approvals = tally.permit && !tally.counted.includes(tally.permit) ? [...tally.counted, tally.permit] : tally.counted;
|
|
99
100
|
needed = tally.need;
|
|
100
101
|
mismatched = tally.mismatched;
|
|
@@ -133,7 +134,7 @@ function decide(component, standing, facts, all, now, rule) {
|
|
|
133
134
|
* gate whose other facts have one is left out, as a run leaves it out: such a
|
|
134
135
|
* line binds no environment, and `chant approve --expire` writes one.
|
|
135
136
|
*/
|
|
136
|
-
export function gatesInLedger(component, content, envs, now, rules = () => null) {
|
|
137
|
+
export function gatesInLedger(component, content, envs, now, rules = () => null, judge) {
|
|
137
138
|
const { pending, resolutions, malformed } = parseGateLedger(content);
|
|
138
139
|
const gates = [];
|
|
139
140
|
for (const gate of [...new Set(pending.map((p) => p.gate))].sort()) {
|
|
@@ -150,13 +151,13 @@ export function gatesInLedger(component, content, envs, now, rules = () => null)
|
|
|
150
151
|
}
|
|
151
152
|
for (const env of [...byEnv.keys()].sort((a, b) => envs.indexOf(a ?? "") - envs.indexOf(b ?? ""))) {
|
|
152
153
|
const envFacts = byEnv.get(env);
|
|
153
|
-
gates.push(decide(component, latestPendingGate(envFacts, gate), envFacts, resolutions, now, rules(gate)));
|
|
154
|
+
gates.push(decide(component, latestPendingGate(envFacts, gate), envFacts, resolutions, now, rules(gate), judge));
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
return { gates, malformed };
|
|
157
158
|
}
|
|
158
159
|
/** Read one member's gate ledger directory at `commit` and list its gates. */
|
|
159
|
-
export async function readMemberGates(dir, layout, commit, envs, cwd, now, read = defaultGateLedgerReader, rules = () => null, listChangeSets = defaultChangeSetLister) {
|
|
160
|
+
export async function readMemberGates(dir, layout, commit, envs, cwd, now, read = defaultGateLedgerReader, rules = () => null, listChangeSets = defaultChangeSetLister, judge) {
|
|
160
161
|
const ledger = { layout, path: dir, shared: false, malformed: 0, reason: null };
|
|
161
162
|
if (commit === null) {
|
|
162
163
|
return { gates: [], ledger: { ...ledger, reason: { code: "gates-no-ledger", message: "the checkout has no chant/lifecycle branch, so no gate is recorded in it" } } };
|
|
@@ -174,7 +175,7 @@ export async function readMemberGates(dir, layout, commit, envs, cwd, now, read
|
|
|
174
175
|
}
|
|
175
176
|
const gates = [];
|
|
176
177
|
for (const component of [...files.keys()].sort()) {
|
|
177
|
-
const read = gatesInLedger(component, files.get(component), envs, now, rules);
|
|
178
|
+
const read = gatesInLedger(component, files.get(component), envs, now, rules, judge);
|
|
178
179
|
gates.push(...read.gates);
|
|
179
180
|
ledger.malformed += read.malformed;
|
|
180
181
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/workspace/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAyC,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAChI,OAAO,EAAsF,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC1J,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAyD,KAAK,gBAAgB,EAAqB,MAAM,gCAAgC,CAAC;AACjJ,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAqC,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;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MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,iIAAiI;IACjI,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,YAAY,CAAC,EAAE,OAAO,kBAAkB,CAAC;IACzC,yGAAyG;IACzG,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC,CAAC;CACvE;AA8FD,kFAAkF;AAClF,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;AAO7E,gJAAgJ;AAChJ,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAuID,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAW7F;AAED,6FAA6F;AAC7F,wBAAsB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CA8IjF;AAiFD,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuC7E;AAeD,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,MAAM,CA0GvF"}
|
package/dist/workspace/status.js
CHANGED
|
@@ -55,6 +55,7 @@ import { gateAdmissionFrom, releaseRuleFrom } from "./identity.js";
|
|
|
55
55
|
import { checkReleaseSignature } from "./identity-gate-rule.js";
|
|
56
56
|
import { scopeSource } from "./write-scope.js";
|
|
57
57
|
import { GATE_REASON_CODES, readMemberGates } from "./status-gates.js";
|
|
58
|
+
import { trustQuorumJudge } from "../op/gate-quorum.js";
|
|
58
59
|
import { STEWARD_REASON_CODES, readMemberStewards } from "./status-stewards.js";
|
|
59
60
|
import { gitTop, workingTree } from "./tree.js";
|
|
60
61
|
import { handToRootChant } from "./which-chant.js";
|
|
@@ -356,6 +357,8 @@ export async function workspaceStatus(query) {
|
|
|
356
357
|
const ruleSource = scopeSource(found.dir);
|
|
357
358
|
const rules = (gate) => gateAdmissionFrom(ruleSource, gate);
|
|
358
359
|
const releaseRule = releaseRuleFrom(ruleSource).rule;
|
|
360
|
+
// #4290: approval rules read roles from the trust policy at base, for a proven approver.
|
|
361
|
+
const judge = trustQuorumJudge({ signers: ruleSource.policy, roles: ruleSource.policy.roles });
|
|
359
362
|
// #4033 (ws-105): revoked commits, read from local tags once and only when a release is met.
|
|
360
363
|
// Tags that can't be judged read as none revoked; workspace check reports the declaration.
|
|
361
364
|
let revokedCommits;
|
|
@@ -369,7 +372,7 @@ export async function workspaceStatus(query) {
|
|
|
369
372
|
for (const env of envs)
|
|
370
373
|
environments.push(await readEnvironment(m, env, found.dir, read, revokedOf, query.readOutcomes));
|
|
371
374
|
const own = await hasMemberLedger(m, found.dir);
|
|
372
|
-
const gates = await readMemberGates(own ? `${MEMBERS_DIR}/${m.name}/${GATES_DIR}` : GATES_DIR, own ? "members" : "flat", commit, envs, found.dir, now, query.readGates, rules);
|
|
375
|
+
const gates = await readMemberGates(own ? `${MEMBERS_DIR}/${m.name}/${GATES_DIR}` : GATES_DIR, own ? "members" : "flat", commit, envs, found.dir, now, query.readGates, rules, undefined, judge);
|
|
373
376
|
const stewards = await (query.readStewards ?? readMemberStewards)(resolve(found.dir, m.dir), query.env, now, m.kind, m.box);
|
|
374
377
|
// The declaration's x- keys go back on the objects that hold them (#3595).
|
|
375
378
|
const x = (pointer) => extensionsAt(declaration, pointer);
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import type { SealCode } from "../records.js";
|
|
25
25
|
import { type TrustPolicy } from "./policy.js";
|
|
26
|
-
import { type SealedGateApproval } from "
|
|
27
|
-
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf, type SealedGateApproval } from "
|
|
26
|
+
import { type SealedGateApproval } from "../../lifecycle/gate-seal.js";
|
|
27
|
+
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf, type SealedGateApproval } from "../../lifecycle/gate-seal.js";
|
|
28
28
|
/** The ssh signature namespace of a verdict seal. */
|
|
29
29
|
export declare const REVIEW_SEAL_NAMESPACE = "chant-review";
|
|
30
30
|
/** The ssh signature namespace of a record's author seal (#2688). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/seal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAmG,KAAK,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/seal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAmG,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGrK,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3I,qDAAqD;AACrD,eAAO,MAAM,q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BAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CAEnJ"}
|
|
@@ -26,9 +26,9 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
|
26
26
|
import { homedir, tmpdir } from "node:os";
|
|
27
27
|
import { join, resolve } from "node:path";
|
|
28
28
|
import { sshKeygen, verifySshSignature } from "./ssh-commit.js";
|
|
29
|
-
import { GATE_SEAL_NAMESPACE, gateSealPayload, namespaceAllowed, sshSignatureKey, verifySshSignatureWith } from "
|
|
29
|
+
import { GATE_SEAL_NAMESPACE, gateSealPayload, namespaceAllowed, sshSignatureKey, verifySshSignatureWith } from "../../lifecycle/gate-seal.js";
|
|
30
30
|
import { RELEASE_SEAL_NAMESPACE, releaseSealPayload } from "../identity-gate-rule.js";
|
|
31
|
-
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf } from "
|
|
31
|
+
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf } from "../../lifecycle/gate-seal.js";
|
|
32
32
|
/** The ssh signature namespace of a verdict seal. */
|
|
33
33
|
export const REVIEW_SEAL_NAMESPACE = "chant-review";
|
|
34
34
|
/** The ssh signature namespace of a record's author seal (#2688). */
|
package/package.json
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A local emulator of every service the OIDC trade (#4296, ../ci-identity.ts)
|
|
3
|
+
* talks to, for tests: the forge's token request URL, AWS STS, Google's STS
|
|
4
|
+
* and IAM credentials, and Entra's token endpoint. It answers with test
|
|
5
|
+
* values only and keeps every request, so a test can say which identity
|
|
6
|
+
* was asked for and how many tokens were minted.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createServer, type IncomingMessage, type Server } from "node:http";
|
|
10
|
+
import type { AddressInfo } from "node:net";
|
|
11
|
+
import type { CloudTradeSpec } from "../ci-identity";
|
|
12
|
+
|
|
13
|
+
/** What the emulator was asked. */
|
|
14
|
+
export interface EmulatorLog {
|
|
15
|
+
/** Each OIDC token minted: its audience. */
|
|
16
|
+
minted: string[];
|
|
17
|
+
/** Each AWS role assumed, with the token it was assumed with. */
|
|
18
|
+
assumed: Array<{ role: string; token: string }>;
|
|
19
|
+
/** Each GCP service account impersonated. */
|
|
20
|
+
impersonated: string[];
|
|
21
|
+
/** Each Azure client a token was traded for, with the token. */
|
|
22
|
+
clients: Array<{ clientId: string; token: string }>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface OidcEmulator {
|
|
26
|
+
url: string;
|
|
27
|
+
log: EmulatorLog;
|
|
28
|
+
/** The forge's token request variables, as a GitHub or Forgejo job with `id-token: write` has them. */
|
|
29
|
+
requestEnv: { ACTIONS_ID_TOKEN_REQUEST_URL: string; ACTIONS_ID_TOKEN_REQUEST_TOKEN: string };
|
|
30
|
+
/** `spec` with each cloud pointed at the emulator. */
|
|
31
|
+
pointAt(spec: CloudTradeSpec): CloudTradeSpec;
|
|
32
|
+
close(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The request token the emulator accepts, and the prefix of every token it mints. */
|
|
36
|
+
export const EMULATED_REQUEST_TOKEN = "emulated-oidc-request-token-4296";
|
|
37
|
+
export const EMULATED_JWT_PREFIX = "eyJemulated4296";
|
|
38
|
+
|
|
39
|
+
/** The test credentials the emulator hands out for an identity: they name it, so a test can tell which was traded. */
|
|
40
|
+
export function emulatedCredentials(identity: string): { accessKeyId: string; secret: string; token: string } {
|
|
41
|
+
const tag = identity.replace(/[^A-Za-z0-9]/g, "").slice(-24);
|
|
42
|
+
return { accessKeyId: `ASIATEST${tag}`, secret: `secret-${tag}`, token: `session-${tag}` };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const body = (req: IncomingMessage): Promise<string> =>
|
|
46
|
+
new Promise((ok) => {
|
|
47
|
+
let b = "";
|
|
48
|
+
req.on("data", (c) => (b += c));
|
|
49
|
+
req.on("end", () => ok(b));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/** Start the emulator on a free local port. */
|
|
53
|
+
export async function startOidcEmulator(): Promise<OidcEmulator> {
|
|
54
|
+
const log: EmulatorLog = { minted: [], assumed: [], impersonated: [], clients: [] };
|
|
55
|
+
const server: Server = createServer(async (req, res) => {
|
|
56
|
+
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
57
|
+
const text = await body(req);
|
|
58
|
+
const send = (status: number, payload: unknown, type = "application/json") => {
|
|
59
|
+
res.writeHead(status, { "content-type": type });
|
|
60
|
+
res.end(typeof payload === "string" ? payload : JSON.stringify(payload));
|
|
61
|
+
};
|
|
62
|
+
if (url.pathname === "/oidc") {
|
|
63
|
+
if (req.headers.authorization !== `bearer ${EMULATED_REQUEST_TOKEN}`) return send(401, { message: "bad request token" });
|
|
64
|
+
const aud = url.searchParams.get("audience") ?? "";
|
|
65
|
+
log.minted.push(aud);
|
|
66
|
+
return send(200, { value: `${EMULATED_JWT_PREFIX}.${Buffer.from(aud).toString("base64url")}.${log.minted.length}` });
|
|
67
|
+
}
|
|
68
|
+
if (url.pathname === "/aws/") {
|
|
69
|
+
const form = new URLSearchParams(text);
|
|
70
|
+
const role = form.get("RoleArn") ?? "";
|
|
71
|
+
const token = form.get("WebIdentityToken") ?? "";
|
|
72
|
+
if (form.get("Action") !== "AssumeRoleWithWebIdentity" || !token.startsWith("eyJ")) return send(400, "<Error>bad request</Error>", "text/xml");
|
|
73
|
+
log.assumed.push({ role, token });
|
|
74
|
+
const c = emulatedCredentials(role);
|
|
75
|
+
return send(
|
|
76
|
+
200,
|
|
77
|
+
`<AssumeRoleWithWebIdentityResponse><AssumeRoleWithWebIdentityResult><Credentials><AccessKeyId>${c.accessKeyId}</AccessKeyId><SecretAccessKey>${c.secret}</SecretAccessKey><SessionToken>${c.token}</SessionToken><Expiration>2026-10-22T23:00:00Z</Expiration></Credentials></AssumeRoleWithWebIdentityResult></AssumeRoleWithWebIdentityResponse>`,
|
|
78
|
+
"text/xml",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (url.pathname === "/gcp-sts/v1/token") {
|
|
82
|
+
const j = JSON.parse(text) as { subjectToken?: string };
|
|
83
|
+
if (!j.subjectToken?.startsWith("eyJ")) return send(400, { error: "bad subject token" });
|
|
84
|
+
return send(200, { access_token: "federated-test-token", token_type: "Bearer" });
|
|
85
|
+
}
|
|
86
|
+
const sa = /^\/gcp-iam\/v1\/projects\/-\/serviceAccounts\/([^/:]+):generateAccessToken$/.exec(url.pathname);
|
|
87
|
+
if (sa) {
|
|
88
|
+
if (req.headers.authorization !== "Bearer federated-test-token") return send(401, { error: "bad federated token" });
|
|
89
|
+
const name = decodeURIComponent(sa[1]!);
|
|
90
|
+
log.impersonated.push(name);
|
|
91
|
+
return send(200, { accessToken: `ya29.${emulatedCredentials(name).token}`, expireTime: "2026-10-22T23:00:00Z" });
|
|
92
|
+
}
|
|
93
|
+
if (/^\/azure\/[^/]+\/oauth2\/v2\.0\/token$/.test(url.pathname)) {
|
|
94
|
+
const form = new URLSearchParams(text);
|
|
95
|
+
const clientId = form.get("client_id") ?? "";
|
|
96
|
+
const token = form.get("client_assertion") ?? "";
|
|
97
|
+
if (form.get("grant_type") !== "client_credentials" || !token.startsWith("eyJ")) return send(400, { error: "bad grant" });
|
|
98
|
+
log.clients.push({ clientId, token });
|
|
99
|
+
return send(200, { access_token: `azure.${emulatedCredentials(clientId).token}`, token_type: "Bearer" });
|
|
100
|
+
}
|
|
101
|
+
send(404, { message: `no route ${url.pathname}` });
|
|
102
|
+
});
|
|
103
|
+
await new Promise<void>((ok) => server.listen(0, "127.0.0.1", ok));
|
|
104
|
+
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
|
|
105
|
+
return {
|
|
106
|
+
url,
|
|
107
|
+
log,
|
|
108
|
+
requestEnv: { ACTIONS_ID_TOKEN_REQUEST_URL: `${url}/oidc?api-version=2.0`, ACTIONS_ID_TOKEN_REQUEST_TOKEN: EMULATED_REQUEST_TOKEN },
|
|
109
|
+
pointAt(spec) {
|
|
110
|
+
return {
|
|
111
|
+
...(spec.aws ? { aws: { ...spec.aws, endpoint: `${url}/aws` } } : {}),
|
|
112
|
+
...(spec.gcp ? { gcp: { ...spec.gcp, stsEndpoint: `${url}/gcp-sts`, iamEndpoint: `${url}/gcp-iam` } } : {}),
|
|
113
|
+
...(spec.azure ? { azure: { ...spec.azure, authority: `${url}/azure` } } : {}),
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
close: () => new Promise<void>((ok) => server.close(() => ok())),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4295: the forge token handover. A step that runs the pull request's code
|
|
3
|
+
* starts again without the forge token variables, the report it writes goes
|
|
4
|
+
* to the next job as data, and the checkout keeps no credentials.
|
|
5
|
+
*
|
|
6
|
+
* Each test runs the generated shell for real, with `sh`, in a temp
|
|
7
|
+
* directory, with every token variable set to a value it then looks for.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
11
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { gzipSync } from "node:zlib";
|
|
15
|
+
import { afterAll, describe, expect, test } from "vitest";
|
|
16
|
+
import {
|
|
17
|
+
CHECKOUT_TOKEN_ENV,
|
|
18
|
+
checkoutScript,
|
|
19
|
+
dropForgeTokens,
|
|
20
|
+
FORGE_TOKEN_VARS,
|
|
21
|
+
GITLAB_DROP_FORGE_TOKENS,
|
|
22
|
+
HANDOVER_LIMITS,
|
|
23
|
+
handoverKeys,
|
|
24
|
+
handoverTrap,
|
|
25
|
+
holdsForgeToken,
|
|
26
|
+
packJs,
|
|
27
|
+
UNPACK_JS,
|
|
28
|
+
withoutForgeTokens,
|
|
29
|
+
} from "./ci-handover";
|
|
30
|
+
|
|
31
|
+
const dirs: string[] = [];
|
|
32
|
+
afterAll(() => {
|
|
33
|
+
for (const d of dirs) rmSync(d, { recursive: true, force: true });
|
|
34
|
+
});
|
|
35
|
+
function scratch(prefix: string): string {
|
|
36
|
+
const d = mkdtempSync(join(tmpdir(), prefix));
|
|
37
|
+
dirs.push(d);
|
|
38
|
+
return d;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const SECRET = "ghs_handover_secret_4295";
|
|
42
|
+
/** Every forge token variable, set to a value a leak would show. */
|
|
43
|
+
const TOKENS = Object.fromEntries(FORGE_TOKEN_VARS.map((v) => [v, `${SECRET}_${v}`]));
|
|
44
|
+
const BASE = { PATH: process.env.PATH ?? "/usr/bin:/bin", HOME: process.env.HOME ?? "/tmp" };
|
|
45
|
+
|
|
46
|
+
/** Run `body` after the drop line as a script file, as a forge runs a step, and return what `env` printed in it. */
|
|
47
|
+
function stepEnv(body: string, extra: Record<string, string> = {}): { env: string; status: number | null } {
|
|
48
|
+
const dir = scratch("chant-handover-step-");
|
|
49
|
+
const out = join(dir, "env.txt");
|
|
50
|
+
const file = join(dir, "step.sh");
|
|
51
|
+
writeFileSync(file, `${dropForgeTokens("sh")}\n${body.replaceAll("$OUT", out)}\n`);
|
|
52
|
+
const r = spawnSync("sh", ["-e", file], { cwd: dir, env: { ...BASE, ...TOKENS, ...extra }, encoding: "utf-8" });
|
|
53
|
+
return { env: existsSync(out) ? readFileSync(out, "utf-8") : "", status: r.status };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe("a step that runs the change's code holds no forge token (#4295)", () => {
|
|
57
|
+
test("the step's shell and every process it starts see none of the token variables", () => {
|
|
58
|
+
const { env, status } = stepEnv('env > "$OUT"; sh -c \'env\' >> "$OUT"');
|
|
59
|
+
expect(status).toBe(0);
|
|
60
|
+
expect(env).not.toContain(SECRET);
|
|
61
|
+
for (const name of FORGE_TOKEN_VARS) expect(env).not.toMatch(new RegExp(`^${name}=`, "m"));
|
|
62
|
+
// It restarted once, which the marker says, so it does not loop.
|
|
63
|
+
expect(env).toMatch(/^CHANT_NO_FORGE_TOKEN=1$/m);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test.skipIf(process.platform !== "linux")("the restart leaves no token in the shell's own initial environment, which a child reads from /proc", () => {
|
|
67
|
+
const { env } = stepEnv('tr "\\0" "\\n" < /proc/$$/environ > "$OUT"; sh -c \'tr "\\0" "\\n" < /proc/$PPID/environ\' >> "$OUT"');
|
|
68
|
+
expect(env).toContain("CHANT_NO_FORGE_TOKEN=1");
|
|
69
|
+
expect(env).not.toContain(SECRET);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("a step's exit code is its own after the restart", () => {
|
|
73
|
+
expect(stepEnv("exit 3").status).toBe(3);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("a shell that cannot restart, such as sh -c, unsets them", () => {
|
|
77
|
+
const r = spawnSync("sh", ["-c", `${dropForgeTokens("sh")}\nenv`], { env: { ...BASE, ...TOKENS }, encoding: "utf-8" });
|
|
78
|
+
expect(r.status).toBe(0);
|
|
79
|
+
expect(r.stdout).not.toContain(SECRET);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("bash restarts with pipefail", () => {
|
|
83
|
+
const dir = scratch("chant-handover-bash-");
|
|
84
|
+
const file = join(dir, "step.sh");
|
|
85
|
+
writeFileSync(file, `${dropForgeTokens("bash")}\nenv\n`);
|
|
86
|
+
const r = spawnSync("bash", ["-e", file], { env: { ...BASE, ...TOKENS }, encoding: "utf-8" });
|
|
87
|
+
expect(r.stdout).not.toContain(SECRET);
|
|
88
|
+
expect(r.stdout).toContain("CHANT_NO_FORGE_TOKEN=1");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("GitLab's line unsets them for every line after it in the job's one shell", () => {
|
|
92
|
+
const r = spawnSync("sh", ["-c", `${GITLAB_DROP_FORGE_TOKENS}\nenv`], { env: { ...BASE, ...TOKENS }, encoding: "utf-8" });
|
|
93
|
+
expect(r.stdout).not.toContain(SECRET);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("withoutForgeTokens and holdsForgeToken cover chant's, GitHub's, Forgejo's and GitLab's names", () => {
|
|
97
|
+
const env = { ...TOKENS, AWS_ACCESS_KEY_ID: "floci", GITHUB_REPOSITORY: "acme/estate" };
|
|
98
|
+
expect(withoutForgeTokens(env)).toEqual({ AWS_ACCESS_KEY_ID: "floci", GITHUB_REPOSITORY: "acme/estate" });
|
|
99
|
+
expect(holdsForgeToken(env)).toBe(true);
|
|
100
|
+
expect(holdsForgeToken({ GITHUB_TOKEN: "" })).toBe(false);
|
|
101
|
+
for (const name of ["GITHUB_TOKEN", "GH_TOKEN", "CHANT_FORGE_TOKEN", "FORGEJO_TOKEN", "GITLAB_TOKEN", "CI_JOB_TOKEN", "ACTIONS_RUNTIME_TOKEN"]) {
|
|
102
|
+
expect(FORGE_TOKEN_VARS).toContain(name);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/** Run the plan step's trap with `files` in its report directory, and return the outputs it wrote. */
|
|
108
|
+
function handOn(files: Record<string, string>, forge: "github" | "forgejo" = "github"): string {
|
|
109
|
+
const dir = scratch("chant-handover-pack-");
|
|
110
|
+
for (const [name, body] of Object.entries(files)) {
|
|
111
|
+
mkdirSync(join(dir, ".chant/pr", name, ".."), { recursive: true });
|
|
112
|
+
writeFileSync(join(dir, ".chant/pr", name), body);
|
|
113
|
+
}
|
|
114
|
+
const output = join(dir, "github-output");
|
|
115
|
+
const file = join(dir, "step.sh");
|
|
116
|
+
writeFileSync(file, [dropForgeTokens("sh"), ...handoverTrap(".chant/pr", forge), "cd /", "exit 1", ""].join("\n"));
|
|
117
|
+
spawnSync("sh", ["-e", file], { cwd: dir, env: { ...BASE, ...TOKENS, GITHUB_OUTPUT: output }, encoding: "utf-8" });
|
|
118
|
+
return readFileSync(output, "utf-8");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** What the note job writes back from `outputs`, one `key=value` a line, as toJSON hands each value in. */
|
|
122
|
+
function takeBack(outputs: string, forge: "github" | "forgejo" = "github"): { dir: string; log: string } {
|
|
123
|
+
const values = Object.fromEntries(outputs.trimEnd().split("\n").map((l) => [l.slice(0, l.indexOf("=")), l.slice(l.indexOf("=") + 1)]));
|
|
124
|
+
const stdin = handoverKeys(forge).map((k) => JSON.stringify(values[k] ?? "")).join("\n") + "\n";
|
|
125
|
+
const dir = scratch("chant-handover-take-");
|
|
126
|
+
const log = execFileSync("node", ["-e", UNPACK_JS, join(dir, ".chant/pr")], { input: stdin, encoding: "utf-8" });
|
|
127
|
+
return { dir: join(dir, ".chant/pr"), log };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
describe("the plan step hands its report to the note job as data (#4295)", () => {
|
|
131
|
+
test("every file goes on as the job's outputs, even when the step fails after changing directory, and comes back the same", () => {
|
|
132
|
+
const files = { "pr-plan.json": '{"stage":"plan"}\n', "pr-note.md": "note\n", "run-events/a.jsonl": "{}\n" };
|
|
133
|
+
const outputs = handOn(files);
|
|
134
|
+
expect(outputs).toMatch(/^report_0=/);
|
|
135
|
+
// The output carries no token, though the step started with every one.
|
|
136
|
+
expect(outputs).not.toContain(Buffer.from(SECRET).toString("base64").slice(0, 12));
|
|
137
|
+
const { dir, log } = takeBack(outputs);
|
|
138
|
+
expect(log).toContain("took 3 report files");
|
|
139
|
+
for (const [name, body] of Object.entries(files)) expect(readFileSync(join(dir, name), "utf-8")).toBe(body);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("a path that leaves the directory is left out", () => {
|
|
143
|
+
const payload = gzipSync(JSON.stringify({ "../escape": Buffer.from("x").toString("base64"), "ok.txt": Buffer.from("y").toString("base64") })).toString("base64");
|
|
144
|
+
const { dir, log } = takeBack(`report_0=${payload}\n`);
|
|
145
|
+
expect(log).toContain('left out "../escape"');
|
|
146
|
+
expect(existsSync(join(dir, "..", "escape"))).toBe(false);
|
|
147
|
+
expect(readFileSync(join(dir, "ok.txt"), "utf-8")).toBe("y");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("outputs that do not read hand on nothing, and the note job carries on", () => {
|
|
151
|
+
expect(takeBack("report_0=not-base64-gzip\n").log).toContain("does not read");
|
|
152
|
+
expect(takeBack("").log).toContain("handed on no report");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("a report too large is cut to the plan report and the note", () => {
|
|
156
|
+
const saved = { ...HANDOVER_LIMITS.github };
|
|
157
|
+
HANDOVER_LIMITS.github.chunk = 2_000;
|
|
158
|
+
try {
|
|
159
|
+
expect(packJs("github")).toContain("CHUNK=2000");
|
|
160
|
+
const big = Array.from({ length: 4000 }, (_, i) => `${i}-${Math.random()}`).join("\n");
|
|
161
|
+
const { dir } = takeBack(handOn({ "pr-plan.json": "{}", "pr-note.md": "n", "change-set.json": big }));
|
|
162
|
+
expect(existsSync(join(dir, "pr-plan.json"))).toBe(true);
|
|
163
|
+
expect(existsSync(join(dir, "change-set.json"))).toBe(false);
|
|
164
|
+
} finally {
|
|
165
|
+
Object.assign(HANDOVER_LIMITS.github, saved);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("Forgejo hands on up to four outputs of a MiB each", () => {
|
|
170
|
+
expect(handoverKeys("forgejo")).toEqual(["report_0", "report_1", "report_2", "report_3"]);
|
|
171
|
+
expect(handoverKeys("github")).toEqual(["report_0"]);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe("the checkout keeps no credentials (#4295)", () => {
|
|
176
|
+
test("it checks the run's commit out with the token in the fetch's environment alone, and fetches chant/lifecycle while it can", () => {
|
|
177
|
+
const top = scratch("chant-handover-checkout-");
|
|
178
|
+
const origin = join(top, "acme", "estate");
|
|
179
|
+
const seed = join(top, "seed");
|
|
180
|
+
mkdirSync(origin, { recursive: true });
|
|
181
|
+
mkdirSync(seed);
|
|
182
|
+
const g = (cwd: string, ...args: string[]) => execFileSync("git", ["-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false", ...args], { cwd, encoding: "utf-8" }).trim();
|
|
183
|
+
g(origin, "init", "-q", "--bare");
|
|
184
|
+
g(seed, "init", "-q");
|
|
185
|
+
writeFileSync(join(seed, "a.txt"), "a\n");
|
|
186
|
+
g(seed, "add", "-A");
|
|
187
|
+
g(seed, "commit", "-q", "-m", "a");
|
|
188
|
+
const sha = g(seed, "rev-parse", "HEAD");
|
|
189
|
+
g(seed, "push", "-q", origin, "HEAD:refs/heads/main", "HEAD:refs/heads/chant/lifecycle", "HEAD:refs/pull/7/merge");
|
|
190
|
+
|
|
191
|
+
const work = join(top, "work");
|
|
192
|
+
mkdirSync(work);
|
|
193
|
+
const file = join(top, "checkout.sh");
|
|
194
|
+
writeFileSync(file, checkoutScript(true, true) + "\n");
|
|
195
|
+
const r = spawnSync("sh", ["-e", file], {
|
|
196
|
+
cwd: work,
|
|
197
|
+
env: { ...BASE, GIT_CONFIG_GLOBAL: join(top, "gitconfig"), [CHECKOUT_TOKEN_ENV]: SECRET, GITHUB_SERVER_URL: `file://${top}`, GITHUB_REPOSITORY: "acme/estate", GITHUB_REF: "refs/pull/7/merge", GITHUB_SHA: sha },
|
|
198
|
+
encoding: "utf-8",
|
|
199
|
+
});
|
|
200
|
+
expect(r.stderr).toBe("");
|
|
201
|
+
expect(r.status).toBe(0);
|
|
202
|
+
expect(g(work, "rev-parse", "HEAD")).toBe(sha);
|
|
203
|
+
expect(g(work, "rev-parse", "chant/lifecycle")).toBe(sha);
|
|
204
|
+
// Nothing of the token is left in the repository's config.
|
|
205
|
+
const config = readFileSync(join(work, ".git", "config"), "utf-8");
|
|
206
|
+
expect(config).not.toContain("extraheader");
|
|
207
|
+
expect(config).not.toContain(Buffer.from(`x-access-token:${SECRET}`).toString("base64"));
|
|
208
|
+
});
|
|
209
|
+
});
|