@intentius/chant 0.124.85 → 0.124.87
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/bundle-check.d.ts +102 -0
- package/dist/bundle-check.d.ts.map +1 -0
- package/dist/bundle-check.js +310 -0
- package/dist/chant-install.d.ts +100 -0
- package/dist/chant-install.d.ts.map +1 -0
- package/dist/chant-install.js +158 -0
- package/dist/ci-commit.d.ts +19 -6
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +23 -4
- package/dist/ci-evidence-jobs.d.ts +78 -0
- package/dist/ci-evidence-jobs.d.ts.map +1 -0
- package/dist/ci-evidence-jobs.js +85 -0
- package/dist/ci-image.d.ts +274 -0
- package/dist/ci-image.d.ts.map +1 -0
- package/dist/ci-image.js +635 -0
- package/dist/ci-login.d.ts +150 -0
- package/dist/ci-login.d.ts.map +1 -0
- package/dist/ci-login.js +240 -0
- package/dist/ci-product.d.ts +16 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +17 -0
- package/dist/cli/commands/import-index.js +2 -2
- package/dist/cli/handlers/build.d.ts +8 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -4
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +61 -2
- package/dist/cli/handlers/ci-evidence.d.ts +3 -0
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
- package/dist/cli/handlers/ci-evidence.js +174 -0
- package/dist/cli/handlers/components.js +3 -3
- package/dist/cli/handlers/dead-guards.d.ts +3 -0
- package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
- package/dist/cli/handlers/dead-guards.js +35 -0
- package/dist/cli/handlers/graph.js +4 -4
- package/dist/cli/handlers/lifecycle.d.ts +2 -1
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +5 -4
- package/dist/cli/handlers/local-chant.d.ts +16 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -0
- package/dist/cli/handlers/local-chant.js +109 -0
- package/dist/cli/handlers/operator.js +2 -2
- package/dist/cli/handlers/search.js +5 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +49 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +64 -4
- package/dist/components/check-steps.d.ts +17 -0
- package/dist/components/check-steps.d.ts.map +1 -1
- package/dist/components/check-steps.js +37 -5
- package/dist/components/product-pipeline.d.ts +23 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +6 -2
- package/dist/components/product-plan.d.ts +143 -0
- package/dist/components/product-plan.d.ts.map +1 -0
- package/dist/components/product-plan.js +145 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +2 -2
- package/dist/config.d.ts +39 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -3
- package/dist/dead-guards.d.ts +82 -0
- package/dist/dead-guards.d.ts.map +1 -0
- package/dist/dead-guards.js +436 -0
- package/dist/discovery/files.d.ts +3 -1
- package/dist/discovery/files.d.ts.map +1 -1
- package/dist/discovery/files.js +5 -3
- package/dist/drift-issue.d.ts +152 -0
- package/dist/drift-issue.d.ts.map +1 -0
- package/dist/drift-issue.js +167 -0
- package/dist/floor-table.d.ts +30 -0
- package/dist/floor-table.d.ts.map +1 -0
- package/dist/floor-table.data.d.ts +3 -0
- package/dist/floor-table.data.d.ts.map +1 -0
- package/dist/floor-table.data.js +179 -0
- package/dist/floor-table.js +56 -0
- package/dist/forge-flags.d.ts +90 -0
- package/dist/forge-flags.d.ts.map +1 -0
- package/dist/forge-flags.js +184 -0
- package/dist/lexicon.d.ts +69 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.d.ts +7 -1
- package/dist/lifecycle/gated-op.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.js +7 -4
- package/dist/local-chant.d.ts +98 -0
- package/dist/local-chant.d.ts.map +1 -0
- package/dist/local-chant.js +307 -0
- package/dist/op/activities/predict-behaviour.js +2 -2
- package/dist/op/op-waves-evidence-spec.d.ts +13 -0
- package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-spec.js +21 -0
- package/dist/op/op-waves-evidence.d.ts +40 -0
- package/dist/op/op-waves-evidence.d.ts.map +1 -0
- package/dist/op/op-waves-evidence.js +58 -0
- package/dist/op/op-waves-run.d.ts +4 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +24 -1
- package/dist/op/op-waves.d.ts +17 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +23 -0
- package/dist/op/schedule-overdue.d.ts +41 -9
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +154 -25
- package/dist/plan-summary.d.ts +25 -0
- package/dist/plan-summary.d.ts.map +1 -1
- package/dist/plan-summary.js +31 -0
- package/dist/pr-plan-note.d.ts +35 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +10 -0
- package/dist/pr-post.d.ts +23 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +125 -3
- package/dist/release-floors.d.ts +33 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +33 -1
- package/dist/state-migration.d.ts +24 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +100 -5
- package/dist/wave-runtime.mjs +309 -302
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +4 -3
- package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
- package/dist/workspace/lexicon-outputs.js +21 -7
- package/dist/workspace/reason-codes.d.ts +3 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +4 -0
- package/dist/workspace/ref-gate.schema.json +85 -0
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.d.ts +58 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence-report.js +109 -0
- package/dist/workspace/trust/check-evidence.d.ts +160 -0
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence.js +309 -0
- 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 +2 -2
- package/dist/workspace/trust/evidence.d.ts.map +1 -1
- 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 +123 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/local-evidence.js +259 -0
- 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/policy.d.ts +140 -1
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +197 -3
- package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-cli.js +234 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-fixture.js +97 -0
- package/dist/workspace/trust/ref-gate.d.ts +187 -0
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate.js +432 -0
- 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 +25 -1
- package/package.json +1 -1
- package/src/bundle-check.test.ts +140 -0
- package/src/bundle-check.ts +352 -0
- package/src/chant-install.test.ts +112 -0
- package/src/chant-install.ts +179 -0
- package/src/ci-commit.test.ts +45 -0
- package/src/ci-commit.ts +38 -4
- package/src/ci-evidence-jobs.ts +105 -0
- package/src/ci-image.test.ts +506 -0
- package/src/ci-image.ts +822 -0
- package/src/ci-login.test.ts +235 -0
- package/src/ci-login.ts +307 -0
- package/src/ci-product.ts +18 -0
- package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/import-index.ts +2 -2
- package/src/cli/handlers/build-source-dir.test.ts +64 -0
- package/src/cli/handlers/build.ts +21 -4
- package/src/cli/handlers/ci-check.ts +60 -3
- package/src/cli/handlers/ci-evidence.ts +167 -0
- package/src/cli/handlers/components.ts +3 -3
- package/src/cli/handlers/dead-guards.ts +37 -0
- package/src/cli/handlers/graph.ts +4 -4
- package/src/cli/handlers/lifecycle.ts +5 -4
- package/src/cli/handlers/local-chant.ts +106 -0
- package/src/cli/handlers/operator.ts +2 -2
- package/src/cli/handlers/search.ts +5 -5
- package/src/cli/main.test.ts +7 -0
- package/src/cli/main.ts +38 -0
- package/src/cli/parse-args.ts +21 -0
- package/src/cli/registry.ts +16 -0
- package/src/components/check-evidence-stage.test.ts +80 -0
- package/src/components/check-hooks.ts +84 -4
- package/src/components/check-local-evidence-stage.test.ts +141 -0
- package/src/components/check-steps.ts +56 -6
- package/src/components/product-pipeline.ts +28 -3
- package/src/components/product-plan.test.ts +87 -0
- package/src/components/product-plan.ts +230 -0
- package/src/components/release-compile.ts +2 -2
- package/src/config.ts +44 -3
- package/src/dead-guards.test.ts +206 -0
- package/src/dead-guards.ts +446 -0
- package/src/discovery/files.ts +5 -3
- package/src/drift-issue-bundle.test.ts +31 -0
- package/src/drift-issue.test.ts +206 -0
- package/src/drift-issue.ts +274 -0
- package/src/fit-note.test.ts +44 -0
- package/src/floor-table.data.ts +181 -0
- package/src/floor-table.ts +77 -0
- package/src/forge-flags.test.ts +110 -0
- package/src/forge-flags.ts +208 -0
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/lexicon.ts +68 -0
- package/src/lifecycle/gated-op.ts +10 -5
- package/src/local-chant.e2e.test.ts +94 -0
- package/src/local-chant.test.ts +162 -0
- package/src/local-chant.ts +341 -0
- package/src/op/activities/predict-behaviour.ts +2 -2
- package/src/op/op-waves-evidence-spec.ts +24 -0
- package/src/op/op-waves-evidence.test.ts +130 -0
- package/src/op/op-waves-evidence.ts +58 -0
- package/src/op/op-waves-run.ts +25 -1
- package/src/op/op-waves.ts +31 -1
- package/src/op/schedule-overdue.test.ts +85 -0
- package/src/op/schedule-overdue.ts +162 -26
- package/src/plan-summary.ts +40 -0
- package/src/pr-plan-note.ts +34 -0
- package/src/pr-post-plan-note.test.ts +146 -0
- package/src/pr-post.ts +127 -3
- package/src/release-floors.ts +47 -1
- package/src/stage-hooks-bundle.test.ts +1 -0
- package/src/state-migration.test.ts +52 -1
- package/src/state-migration.ts +107 -5
- package/src/workspace/ci-green.ts +4 -3
- package/src/workspace/lexicon-outputs.ts +23 -6
- package/src/workspace/reason-codes.test.ts +3 -0
- package/src/workspace/reason-codes.ts +4 -0
- package/src/workspace/ref-gate.schema.json +85 -0
- package/src/workspace/trust/check-evidence-report.ts +115 -0
- package/src/workspace/trust/check-evidence.test.ts +133 -0
- package/src/workspace/trust/check-evidence.ts +327 -0
- package/src/workspace/trust/ci-tag-statement.ts +2 -2
- package/src/workspace/trust/dsse.ts +48 -4
- package/src/workspace/trust/evidence.ts +2 -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.test.ts +127 -0
- package/src/workspace/trust/local-evidence.ts +268 -0
- package/src/workspace/trust/op-run-statement.ts +2 -2
- package/src/workspace/trust/policy.ts +263 -3
- package/src/workspace/trust/ref-gate-cli.ts +244 -0
- package/src/workspace/trust/ref-gate-fixture.ts +125 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
- package/src/workspace/trust/ref-gate.test.ts +247 -0
- package/src/workspace/trust/ref-gate.ts +539 -0
- 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 +22 -0
- package/src/workspace/trust/trust-files.ts +54 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local evidence (#4868): a check proven on a developer's or an agent's
|
|
3
|
+
* machine, which CI accepts in place of running the check again when the
|
|
4
|
+
* policy at base says so.
|
|
5
|
+
*
|
|
6
|
+
* - The statement is the check statement of ./check-evidence.ts with its own
|
|
7
|
+
* predicate type ({@link LOCAL_EVIDENCE_PREDICATE}) and the signer's class
|
|
8
|
+
* (`person` or `agent`) in place of a runner. It binds the commit and its
|
|
9
|
+
* tree, and counts for any commit with the same tree, so a rebase or an
|
|
10
|
+
* amend that keeps the tree keeps it current.
|
|
11
|
+
* - It is signed by a key `local.keys` of `.chant/trust.json` lists at base,
|
|
12
|
+
* for a person or an agent session, and kept under its own notes ref,
|
|
13
|
+
* {@link LOCAL_EVIDENCE_NOTES_REF}. The ref gate (#4867) and an Op waves
|
|
14
|
+
* spec's `evidence.requires` read only `refs/notes/chant/evidence` and only
|
|
15
|
+
* runner keys, so local evidence never counts as runner evidence.
|
|
16
|
+
* - `local.checks` at base names each check it stands in for, and from whom
|
|
17
|
+
* (`from`, default people only). A check it does not name accepts none.
|
|
18
|
+
* The checks that gate an apply, a release or a gate
|
|
19
|
+
* (`LOCAL_EVIDENCE_NEVER`: plan, policy, apply, drift, ...) can't be named:
|
|
20
|
+
* the policy that names one does not parse, and nothing is accepted.
|
|
21
|
+
*
|
|
22
|
+
* The check runner (`chant ci check`, ../../components/check-steps.ts) reads
|
|
23
|
+
* the evidence per hook with {@link acceptedLocalEvidence} and skips a hook
|
|
24
|
+
* whose evidence is current and accepted, so a job that runs several hooks
|
|
25
|
+
* runs the rest and still passes.
|
|
26
|
+
*/
|
|
27
|
+
import { execFileSync } from "node:child_process";
|
|
28
|
+
import { createHash } from "node:crypto";
|
|
29
|
+
import { z } from "zod";
|
|
30
|
+
import { canonicalJson } from "../../effect-receipt.js";
|
|
31
|
+
import { gitRevisionSource } from "../record-source.js";
|
|
32
|
+
import { IN_TOTO_PAYLOAD_TYPE, loadRunnerKey, signEnvelope, verifyEnvelope } from "./dsse.js";
|
|
33
|
+
import { STATEMENT_TYPE } from "./evidence.js";
|
|
34
|
+
import { commitAndTree, recordChecks } from "./check-evidence.js";
|
|
35
|
+
import { localEvidenceAllowedFor, readTrustPolicy } from "./policy.js";
|
|
36
|
+
import { parseEvidenceNote } from "./ref-gate.js";
|
|
37
|
+
/** The predicate type of a local check statement: never the runner evidence one. */
|
|
38
|
+
export const LOCAL_EVIDENCE_PREDICATE = "https://intentius.io/chant/local-evidence/v1";
|
|
39
|
+
/** Where local evidence is kept: a notes ref the ref gate never reads. */
|
|
40
|
+
export const LOCAL_EVIDENCE_NOTES_REF = "refs/notes/chant/local-evidence";
|
|
41
|
+
export { LOCAL_EVIDENCE_KEY_ENV } from "./check-evidence-report.js";
|
|
42
|
+
const sha256Hex = z.string().regex(/^[0-9a-f]{64}$/);
|
|
43
|
+
const fullCommit = z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/);
|
|
44
|
+
/** The statement a local key signs. Strict, as the runner statement is. */
|
|
45
|
+
export const localStatementSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
_type: z.literal(STATEMENT_TYPE),
|
|
48
|
+
subject: z.array(z.never()).length(0),
|
|
49
|
+
predicateType: z.literal(LOCAL_EVIDENCE_PREDICATE),
|
|
50
|
+
predicate: z
|
|
51
|
+
.object({
|
|
52
|
+
signer: z.string().min(1),
|
|
53
|
+
class: z.enum(["person", "agent"]),
|
|
54
|
+
commit: fullCommit,
|
|
55
|
+
tree: fullCommit,
|
|
56
|
+
check: z.string().min(1),
|
|
57
|
+
claim: z.object({ sha256: sha256Hex }).strict().optional(),
|
|
58
|
+
})
|
|
59
|
+
.strict(),
|
|
60
|
+
})
|
|
61
|
+
.strict();
|
|
62
|
+
/**
|
|
63
|
+
* The signer a local key makes, from `local.keys` of `.chant/trust.json` at
|
|
64
|
+
* `base`. Throws when the key is not an Ed25519 PEM key or is not listed
|
|
65
|
+
* there (a runner's key never is), so nobody keeps evidence CI would ignore.
|
|
66
|
+
*/
|
|
67
|
+
export function localKeyEvidenceSigner(repo, base, pem) {
|
|
68
|
+
let loaded;
|
|
69
|
+
try {
|
|
70
|
+
loaded = loadRunnerKey(pem);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
throw new Error(`the local evidence key is not an Ed25519 private key in PEM: ${err instanceof Error ? err.message : String(err)}`);
|
|
74
|
+
}
|
|
75
|
+
const policy = readTrustPolicy(gitRevisionSource(repo, base), base);
|
|
76
|
+
if (policy.problems.length > 0)
|
|
77
|
+
throw new Error(`the policy at ${base.slice(0, 12)} cannot be read: ${policy.problems.join("; ")}`);
|
|
78
|
+
const local = policy.local ?? { keys: [], excluded: [], checks: [] };
|
|
79
|
+
if (policy.runners.some((r) => r.key === loaded.publicKey)) {
|
|
80
|
+
throw new Error(`this is a runner's key in .chant/trust.json at ${base.slice(0, 12)}; local evidence is signed by a person's or an agent's key, and a runner signs with chant ci evidence sign`);
|
|
81
|
+
}
|
|
82
|
+
const listed = local.keys.find((k) => k.key === loaded.publicKey);
|
|
83
|
+
if (!listed) {
|
|
84
|
+
throw new Error(`.chant/trust.json at ${base.slice(0, 12)} lists no local key with this key, so CI would ignore the evidence. Add it under "local": { "keys": [...] } first, with class "person" or "agent":\n ${loaded.publicKey}`);
|
|
85
|
+
}
|
|
86
|
+
return { principal: listed.principal, class: listed.class, sign: (payloadType, payload) => signEnvelope(payloadType, payload, loaded.key, loaded.publicKey) };
|
|
87
|
+
}
|
|
88
|
+
/** The local statement for one check over `commit`. */
|
|
89
|
+
export function localStatement(input) {
|
|
90
|
+
if (!input.check.trim())
|
|
91
|
+
throw new Error("a check's evidence needs the check's name");
|
|
92
|
+
return {
|
|
93
|
+
_type: STATEMENT_TYPE,
|
|
94
|
+
subject: [],
|
|
95
|
+
predicateType: LOCAL_EVIDENCE_PREDICATE,
|
|
96
|
+
predicate: {
|
|
97
|
+
signer: input.signer,
|
|
98
|
+
class: input.class,
|
|
99
|
+
commit: input.commit,
|
|
100
|
+
tree: input.tree,
|
|
101
|
+
check: input.check,
|
|
102
|
+
...(input.claim !== undefined ? { claim: { sha256: createHash("sha256").update(input.claim).digest("hex") } } : {}),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Sign each of `checks` over `at` as local evidence. Writes nothing. */
|
|
107
|
+
export function signLocalChecks(repo, at, checks, signer) {
|
|
108
|
+
const { commit, tree } = commitAndTree(repo, at);
|
|
109
|
+
return checks.map(({ check, claim }) => {
|
|
110
|
+
const statement = localStatement({ commit, tree, check, signer: signer.principal, class: signer.class, ...(claim !== undefined ? { claim } : {}) });
|
|
111
|
+
return { check, commit, tree, runner: signer.principal, envelope: signer.sign(IN_TOTO_PAYLOAD_TYPE, Buffer.from(canonicalJson(statement), "utf8")) };
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/** Attach local envelopes under {@link LOCAL_EVIDENCE_NOTES_REF} and push that ref, as `recordChecks` does for runner evidence. */
|
|
115
|
+
export function recordLocalChecks(repo, signed, opts = {}) {
|
|
116
|
+
return recordChecks(repo, signed, { ...opts, notesRef: LOCAL_EVIDENCE_NOTES_REF });
|
|
117
|
+
}
|
|
118
|
+
function tryGit(repo, args) {
|
|
119
|
+
try {
|
|
120
|
+
return execFileSync("git", args, { cwd: repo, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Fetch {@link LOCAL_EVIDENCE_NOTES_REF} from `remote` into the checkout, so
|
|
128
|
+
* a CI job reads what developers pushed. A checkout without the remote, or a
|
|
129
|
+
* remote without the ref, keeps what it has; returns whether the fetch landed.
|
|
130
|
+
*/
|
|
131
|
+
export function fetchLocalEvidence(repo, remote = "origin") {
|
|
132
|
+
if (tryGit(repo, ["remote", "get-url", remote]) === undefined)
|
|
133
|
+
return false;
|
|
134
|
+
return tryGit(repo, ["fetch", "--quiet", "--no-tags", remote, `+${LOCAL_EVIDENCE_NOTES_REF}:${LOCAL_EVIDENCE_NOTES_REF}`]) !== undefined;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Every local envelope that may be for `tree`: the notes of `commit`, of other
|
|
138
|
+
* commits with that tree, and of commits this checkout doesn't have (a shallow
|
|
139
|
+
* CI clone), whose statements are then held to the tree they name.
|
|
140
|
+
*/
|
|
141
|
+
function localEnvelopes(repo, commit, tree) {
|
|
142
|
+
const list = tryGit(repo, ["notes", `--ref=${LOCAL_EVIDENCE_NOTES_REF}`, "list"]);
|
|
143
|
+
if (!list)
|
|
144
|
+
return [];
|
|
145
|
+
const own = [];
|
|
146
|
+
const others = [];
|
|
147
|
+
for (const line of list.split("\n")) {
|
|
148
|
+
const [blob, annotated] = line.trim().split(/\s+/);
|
|
149
|
+
if (!blob || !annotated)
|
|
150
|
+
continue;
|
|
151
|
+
if (annotated !== commit) {
|
|
152
|
+
const theirs = tryGit(repo, ["rev-parse", "--verify", "--quiet", `${annotated}^{tree}`]);
|
|
153
|
+
if (theirs !== undefined && theirs !== tree)
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const text = tryGit(repo, ["cat-file", "blob", blob]);
|
|
157
|
+
if (text !== undefined)
|
|
158
|
+
(annotated === commit ? own : others).push(...parseEvidenceNote(text));
|
|
159
|
+
}
|
|
160
|
+
return [...own, ...others];
|
|
161
|
+
}
|
|
162
|
+
/** One envelope verified against the local keys at base, or why it does not count. */
|
|
163
|
+
function verifyLocal(envelope, policy) {
|
|
164
|
+
const keys = policy.local?.keys ?? [];
|
|
165
|
+
const v = verifyEnvelope(envelope, keys);
|
|
166
|
+
if (!v.ok)
|
|
167
|
+
return { ok: false, reason: v.code === "envelope-untrusted" ? "no signature verifies against a local key the policy at base lists" : v.reason };
|
|
168
|
+
if (v.payloadType !== IN_TOTO_PAYLOAD_TYPE)
|
|
169
|
+
return { ok: false, reason: `payload type ${v.payloadType} is not ${IN_TOTO_PAYLOAD_TYPE}` };
|
|
170
|
+
let raw;
|
|
171
|
+
try {
|
|
172
|
+
raw = JSON.parse(v.payload.toString("utf8"));
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return { ok: false, reason: "the payload is not JSON" };
|
|
176
|
+
}
|
|
177
|
+
const parsed = localStatementSchema.safeParse(raw);
|
|
178
|
+
if (!parsed.success)
|
|
179
|
+
return { ok: false, reason: `the payload is not a ${LOCAL_EVIDENCE_PREDICATE} statement` };
|
|
180
|
+
const key = keys.find((k) => k.principal === v.principal);
|
|
181
|
+
// The signer and class inside are the key's own: a key cannot sign as someone else, or as a person when it is an agent's.
|
|
182
|
+
if (parsed.data.predicate.signer !== key.principal || parsed.data.predicate.class !== key.class) {
|
|
183
|
+
return { ok: false, reason: `the statement names ${parsed.data.predicate.class} ${JSON.stringify(parsed.data.predicate.signer)}, but the key of ${key.class} ${key.principal} signed it` };
|
|
184
|
+
}
|
|
185
|
+
return { ok: true, statement: parsed.data, class: key.class };
|
|
186
|
+
}
|
|
187
|
+
/** The check a local envelope says it is for, read without verifying. */
|
|
188
|
+
function claimedCheck(envelope) {
|
|
189
|
+
try {
|
|
190
|
+
const payload = envelope.payload;
|
|
191
|
+
if (typeof payload !== "string")
|
|
192
|
+
return undefined;
|
|
193
|
+
const check = JSON.parse(Buffer.from(payload, "base64").toString("utf8")).predicate?.check;
|
|
194
|
+
return typeof check === "string" ? check : undefined;
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Whether CI may skip each of `checks` at `at` on local evidence, judged by
|
|
202
|
+
* the policy at `base` (#4868):
|
|
203
|
+
*
|
|
204
|
+
* - `refused`: the check is one local evidence never stands in for, or the policy at base cannot be read.
|
|
205
|
+
* - `not-accepted`: `local.checks` at base does not name it (the default).
|
|
206
|
+
* - `missing`: nothing current is kept for the tree.
|
|
207
|
+
* - `untrusted`: an envelope is kept for it, and none verifies against a
|
|
208
|
+
* local key at base whose class the check accepts (a key the change adds
|
|
209
|
+
* itself, or an agent's key where the check takes people only).
|
|
210
|
+
* - `accepted`: an envelope for the check over `at`'s tree verifies, from a class the check takes.
|
|
211
|
+
*/
|
|
212
|
+
export function acceptedLocalEvidence(repo, at, base, checks) {
|
|
213
|
+
const policy = readTrustPolicy(gitRevisionSource(repo, base), base);
|
|
214
|
+
if (policy.problems.length > 0)
|
|
215
|
+
return checks.map((check) => ({ check, status: "refused", reason: `the policy at ${base.slice(0, 12)} cannot be read: ${policy.problems.join("; ")}` }));
|
|
216
|
+
const rules = new Map((policy.local?.checks ?? []).map((c) => [c.check, c.from]));
|
|
217
|
+
if (!checks.some((c) => rules.has(c) && localEvidenceAllowedFor(c))) {
|
|
218
|
+
return checks.map((check) => verdictWithoutEnvelopes(check, rules, base));
|
|
219
|
+
}
|
|
220
|
+
const { commit, tree } = commitAndTree(repo, at);
|
|
221
|
+
const envelopes = localEnvelopes(repo, commit, tree);
|
|
222
|
+
return checks.map((check) => {
|
|
223
|
+
const from = rules.get(check);
|
|
224
|
+
if (!from || !localEvidenceAllowedFor(check))
|
|
225
|
+
return verdictWithoutEnvelopes(check, rules, base);
|
|
226
|
+
let untrusted;
|
|
227
|
+
for (const envelope of envelopes) {
|
|
228
|
+
const v = verifyLocal(envelope, policy);
|
|
229
|
+
if (!v.ok) {
|
|
230
|
+
if (claimedCheck(envelope) === check)
|
|
231
|
+
untrusted ?? (untrusted = `the local evidence for ${check} does not verify against the local keys at ${base.slice(0, 12)}: ${v.reason}`);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const p = v.statement.predicate;
|
|
235
|
+
if (p.check !== check || p.tree !== tree)
|
|
236
|
+
continue;
|
|
237
|
+
if (!from.includes(v.class)) {
|
|
238
|
+
untrusted ?? (untrusted = `the local evidence for ${check} is from ${v.class} ${p.signer}, and the policy at ${base.slice(0, 12)} takes it from ${from.join(" or ")} only`);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
return { check, status: "accepted", signer: p.signer, class: v.class, commit: p.commit };
|
|
242
|
+
}
|
|
243
|
+
if (untrusted)
|
|
244
|
+
return { check, status: "untrusted", reason: untrusted };
|
|
245
|
+
return { check, status: "missing", reason: `no local evidence for ${check} is kept under ${LOCAL_EVIDENCE_NOTES_REF} for the tree of ${commit.slice(0, 12)}` };
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function verdictWithoutEnvelopes(check, rules, base) {
|
|
249
|
+
if (!localEvidenceAllowedFor(check))
|
|
250
|
+
return { check, status: "refused", reason: `${check} gates an apply, a release or a gate, so it runs whatever evidence exists` };
|
|
251
|
+
if (!rules.has(check))
|
|
252
|
+
return { check, status: "not-accepted", reason: `local.checks in .chant/trust.json at ${base.slice(0, 12)} does not name ${check}` };
|
|
253
|
+
return { check, status: "missing", reason: `no local evidence for ${check}` };
|
|
254
|
+
}
|
|
255
|
+
/** Whether the policy at `base` takes local evidence for any check, so a job knows whether to fetch the notes at all. */
|
|
256
|
+
export function acceptsLocalEvidence(repo, base) {
|
|
257
|
+
const policy = readTrustPolicy(gitRevisionSource(repo, base), base);
|
|
258
|
+
return policy.problems.length === 0 && (policy.local?.checks ?? []).some((c) => localEvidenceAllowedFor(c.check));
|
|
259
|
+
}
|
|
@@ -30,7 +30,7 @@ import { z } from "zod";
|
|
|
30
30
|
import type { OpRunRecord } from "../../op/runtime.js";
|
|
31
31
|
import { type DsseEnvelope } from "./dsse.js";
|
|
32
32
|
import { type CiTagFailure, type CiTagSigner } from "./ci-tag-statement.js";
|
|
33
|
-
import type {
|
|
33
|
+
import type { Runner } from "./policy.js";
|
|
34
34
|
export declare const OP_RUN_PREDICATE = "https://intentius.io/chant/op-run/v1";
|
|
35
35
|
/** The statement a runner signs for an Op run. Strict, so a verifier never acts on a field it does not know. */
|
|
36
36
|
export declare const opRunStatementSchema: z.ZodObject<{
|
|
@@ -87,5 +87,5 @@ export type OpRunVerdict = {
|
|
|
87
87
|
* `runner` role, over a statement for this run, its commit and its record as
|
|
88
88
|
* the ledger holds it. Never throws.
|
|
89
89
|
*/
|
|
90
|
-
export declare function verifyOpRunStatement(record: OpRunRecord, runners: readonly
|
|
90
|
+
export declare function verifyOpRunStatement(record: OpRunRecord, runners: readonly Runner[], roles: Readonly<Record<string, readonly string[]>>): OpRunVerdict;
|
|
91
91
|
//# sourceMappingURL=op-run-statement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"op-run-statement.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/op-run-statement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAsD,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE/F,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"op-run-statement.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/op-run-statement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAsD,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE/F,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,gBAAgB,yCAAyC,CAAC;AAKvE,gHAAgH;AAChH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2BtB,CAAC;AACZ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAG7D;AAED,wGAAwG;AACxG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAWvF;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAGtF;AAED,mHAAmH;AACnH,MAAM,MAAM,YAAY,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAI1I;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,GAAG,YAAY,CAgCtJ"}
|
|
@@ -24,7 +24,24 @@ import { z } from "zod";
|
|
|
24
24
|
import type { RecordSource } from "../record-source.js";
|
|
25
25
|
import { type ExcludedSigner, type Signer } from "./trust-files.js";
|
|
26
26
|
import type { PasskeySigner } from "../../lifecycle/gate-webauthn.js";
|
|
27
|
+
import { type KeylessRoots } from "./keyless.js";
|
|
28
|
+
import type { DsseSignature, KeylessCheck } from "./dsse.js";
|
|
27
29
|
export { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, renderAllowedSigners, type ExcludedSigner, type Signer, type SignerSet, } from "./trust-files.js";
|
|
30
|
+
/** A check name a ref rule requires (#4867): it is also part of an override's subject. */
|
|
31
|
+
export declare const REF_CHECK_NAME: RegExp;
|
|
32
|
+
/** A ref pattern (#4867): a full ref name, where `*` matches within one `/` segment and `**` matches across them. */
|
|
33
|
+
export declare const REF_PATTERN: RegExp;
|
|
34
|
+
/**
|
|
35
|
+
* Checks local evidence never stands in for (#4868): the ones that gate an
|
|
36
|
+
* apply, a release or a gate. A name is refused when it is one of these, or
|
|
37
|
+
* one of these followed by `:` (a wave's `plan:<wave>`).
|
|
38
|
+
*/
|
|
39
|
+
export declare const LOCAL_EVIDENCE_NEVER: readonly ["plan", "policy", "apply", "drift", "release", "gate", "approval", "confirm"];
|
|
40
|
+
/** Whether local evidence may ever be accepted for `check` (#4868). */
|
|
41
|
+
export declare function localEvidenceAllowedFor(check: string): boolean;
|
|
42
|
+
/** Who signs local evidence (#4868): a person on their machine, or an agent session as itself. */
|
|
43
|
+
export declare const LOCAL_SIGNER_CLASSES: readonly ["person", "agent"];
|
|
44
|
+
export type LocalSignerClass = (typeof LOCAL_SIGNER_CLASSES)[number];
|
|
28
45
|
export declare const trustConfigSchema: z.ZodObject<{
|
|
29
46
|
schema: z.ZodLiteral<1>;
|
|
30
47
|
signers: z.ZodOptional<z.ZodString>;
|
|
@@ -42,6 +59,22 @@ export declare const trustConfigSchema: z.ZodObject<{
|
|
|
42
59
|
}>;
|
|
43
60
|
key: z.ZodString;
|
|
44
61
|
}, z.core.$strict>>>;
|
|
62
|
+
keyless: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
trustedRoot: z.ZodString;
|
|
64
|
+
identities: z.ZodArray<z.ZodObject<{
|
|
65
|
+
principal: z.ZodString;
|
|
66
|
+
class: z.ZodEnum<{
|
|
67
|
+
runner: "runner";
|
|
68
|
+
service: "service";
|
|
69
|
+
}>;
|
|
70
|
+
issuer: z.ZodString;
|
|
71
|
+
subject: z.ZodString;
|
|
72
|
+
}, z.core.$strict>>;
|
|
73
|
+
since: z.ZodOptional<z.ZodString>;
|
|
74
|
+
fulcio: z.ZodOptional<z.ZodString>;
|
|
75
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
76
|
+
audience: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strict>>;
|
|
45
78
|
passkeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
46
79
|
principal: z.ZodString;
|
|
47
80
|
id: z.ZodString;
|
|
@@ -57,10 +90,75 @@ export declare const trustConfigSchema: z.ZodObject<{
|
|
|
57
90
|
}, z.core.$strict>>;
|
|
58
91
|
note: z.ZodOptional<z.ZodString>;
|
|
59
92
|
}, z.core.$strict>>>;
|
|
93
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
94
|
+
ref: z.ZodString;
|
|
95
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
96
|
+
check: z.ZodString;
|
|
97
|
+
action: z.ZodOptional<z.ZodEnum<{
|
|
98
|
+
block: "block";
|
|
99
|
+
warn: "warn";
|
|
100
|
+
}>>;
|
|
101
|
+
command: z.ZodString;
|
|
102
|
+
}, z.core.$strict>>;
|
|
103
|
+
status: z.ZodOptional<z.ZodString>;
|
|
104
|
+
overrides: z.ZodOptional<z.ZodEnum<{
|
|
105
|
+
ledger: "ledger";
|
|
106
|
+
sealed: "sealed";
|
|
107
|
+
}>>;
|
|
108
|
+
}, z.core.$strict>>>;
|
|
109
|
+
local: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
keys: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
111
|
+
principal: z.ZodString;
|
|
112
|
+
class: z.ZodEnum<{
|
|
113
|
+
agent: "agent";
|
|
114
|
+
person: "person";
|
|
115
|
+
}>;
|
|
116
|
+
key: z.ZodString;
|
|
117
|
+
}, z.core.$strict>>>;
|
|
118
|
+
checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
119
|
+
check: z.ZodString;
|
|
120
|
+
from: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
121
|
+
agent: "agent";
|
|
122
|
+
person: "person";
|
|
123
|
+
}>>>;
|
|
124
|
+
}, z.core.$strict>>>;
|
|
125
|
+
}, z.core.$strict>>;
|
|
60
126
|
}, z.core.$strict>;
|
|
61
127
|
export type TrustConfig = z.infer<typeof trustConfigSchema>;
|
|
62
128
|
/** The role whose holders may change the policy. Without any grant of it, every signer may. */
|
|
63
129
|
export declare const ADMIN_ROLE = "admin";
|
|
130
|
+
/** A ref rule of `.chant/trust.json` (#4867), with `action` filled in. */
|
|
131
|
+
export interface RefRule {
|
|
132
|
+
ref: string;
|
|
133
|
+
checks: Array<{
|
|
134
|
+
check: string;
|
|
135
|
+
action: "block" | "warn";
|
|
136
|
+
command: string;
|
|
137
|
+
}>;
|
|
138
|
+
status?: string;
|
|
139
|
+
overrides?: "ledger" | "sealed";
|
|
140
|
+
}
|
|
141
|
+
/** A key that signs local evidence (#4868): a person's or an agent session's. */
|
|
142
|
+
export interface LocalKey {
|
|
143
|
+
principal: string;
|
|
144
|
+
class: LocalSignerClass;
|
|
145
|
+
/** `ssh-ed25519 <base64>`. */
|
|
146
|
+
key: string;
|
|
147
|
+
}
|
|
148
|
+
/** What `local` in `.chant/trust.json` at base says (#4868), with `from` filled in (default: people only). */
|
|
149
|
+
export interface LocalEvidencePolicy {
|
|
150
|
+
keys: LocalKey[];
|
|
151
|
+
/** Keys left out, and why. */
|
|
152
|
+
excluded: Array<{
|
|
153
|
+
principal: string;
|
|
154
|
+
reason: string;
|
|
155
|
+
}>;
|
|
156
|
+
/** The checks local evidence stands in for, and from whom. */
|
|
157
|
+
checks: Array<{
|
|
158
|
+
check: string;
|
|
159
|
+
from: LocalSignerClass[];
|
|
160
|
+
}>;
|
|
161
|
+
}
|
|
64
162
|
/** A key that signs runner evidence: a service or CI identity. */
|
|
65
163
|
export interface RunnerKey {
|
|
66
164
|
principal: string;
|
|
@@ -68,6 +166,27 @@ export interface RunnerKey {
|
|
|
68
166
|
/** `ssh-ed25519 <base64>`. */
|
|
69
167
|
key: string;
|
|
70
168
|
}
|
|
169
|
+
/** A CI identity that signs runner statements keyless (#4869), with the trusted root it is verified against. */
|
|
170
|
+
export interface RunnerIdentity {
|
|
171
|
+
principal: string;
|
|
172
|
+
class: "runner" | "service";
|
|
173
|
+
issuer: string;
|
|
174
|
+
/** A pattern over the certificate's subject alternative name: `*` within a `/` segment, `**` across. */
|
|
175
|
+
subject: string;
|
|
176
|
+
roots: KeylessRoots;
|
|
177
|
+
/** Verifies one keyless signature against this identity and its trusted root (./dsse.ts's `TrustedIdentity`). */
|
|
178
|
+
verifyKeyless(message: Buffer, signature: DsseSignature): KeylessCheck;
|
|
179
|
+
}
|
|
180
|
+
/** A runner as a statement's verifier takes it: a key, or a keyless identity. */
|
|
181
|
+
export type Runner = RunnerKey | RunnerIdentity;
|
|
182
|
+
/** Where a keyless signing job trades its token (#4869), and from which commit only keyless statements count. */
|
|
183
|
+
export interface KeylessPolicy {
|
|
184
|
+
since?: string;
|
|
185
|
+
fulcio: string;
|
|
186
|
+
timestamp: string;
|
|
187
|
+
audience: string;
|
|
188
|
+
trustedRoot: string;
|
|
189
|
+
}
|
|
71
190
|
/** The policy a check applies, as read at base. */
|
|
72
191
|
export interface TrustPolicy {
|
|
73
192
|
/** The full commit id the policy was read at, or null when there is no base. */
|
|
@@ -85,6 +204,10 @@ export interface TrustPolicy {
|
|
|
85
204
|
}>;
|
|
86
205
|
/** Runner and service keys that may sign runner evidence (#2553). */
|
|
87
206
|
runners: RunnerKey[];
|
|
207
|
+
/** CI identities that sign runner statements keyless (#4869). Absent on a policy built by hand: none. */
|
|
208
|
+
runnerIdentities?: RunnerIdentity[];
|
|
209
|
+
/** The keyless settings (#4869), when `keyless` is set and its trusted root reads. */
|
|
210
|
+
keyless?: KeylessPolicy;
|
|
88
211
|
/** Runner entries that are not used, and why. */
|
|
89
212
|
excludedRunners: Array<{
|
|
90
213
|
principal: string;
|
|
@@ -94,6 +217,10 @@ export interface TrustPolicy {
|
|
|
94
217
|
passkeys?: PasskeySigner[];
|
|
95
218
|
/** Signers admitted per return (#2552), keyed by return id. They verify that return's commits and seals only. */
|
|
96
219
|
admitted: Record<string, Signer[]>;
|
|
220
|
+
/** The checks a ref update needs evidence for (#4867). Absent on a policy built by hand: none. */
|
|
221
|
+
refs?: RefRule[];
|
|
222
|
+
/** Local evidence (#4868). Absent on a policy built by hand: no key, no check accepts it. */
|
|
223
|
+
local?: LocalEvidencePolicy;
|
|
97
224
|
/**
|
|
98
225
|
* Set on a copy of the policy used for one returned record (#2552): the
|
|
99
226
|
* return it came back in. A seal by a principal the policy does not list
|
|
@@ -112,8 +239,20 @@ export interface TrustPolicy {
|
|
|
112
239
|
signers: Signer[];
|
|
113
240
|
} | null;
|
|
114
241
|
}
|
|
115
|
-
/** Paths whose change is a protected write under `policy`: the config, the signers file and its rotation file (#2553). */
|
|
242
|
+
/** Paths whose change is a protected write under `policy`: the config, the signers file and its rotation file (#2553), and the keyless trusted root (#4869). */
|
|
116
243
|
export declare function protectedPaths(policy: TrustPolicy): string[];
|
|
244
|
+
/**
|
|
245
|
+
* The runners whose statements over `commit` count (#4869): the runner keys
|
|
246
|
+
* and the keyless identities. With `keyless.since`, a runner key counts
|
|
247
|
+
* only for a commit that is a strict ancestor of `since`, the way
|
|
248
|
+
* `ci.green.signedSince` judges tags by position in history; a `since` the
|
|
249
|
+
* clone does not have leaves the keys out. Without `at`, under `since`, only
|
|
250
|
+
* the identities.
|
|
251
|
+
*/
|
|
252
|
+
export declare function runnersAt(policy: TrustPolicy, at?: {
|
|
253
|
+
repo: string;
|
|
254
|
+
commit: string;
|
|
255
|
+
}): Runner[];
|
|
117
256
|
/** Principals allowed to change the policy: the admins when any are granted, otherwise every signer. */
|
|
118
257
|
export declare function policyWriters(policy: TrustPolicy): Set<string>;
|
|
119
258
|
/** A policy with nothing in it: attestation off. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAgE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,SAAS,GACf,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAgE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAA0G,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AACtJ,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,SAAS,GACf,MAAM,eAAe,CAAC;AAiBvB,0FAA0F;AAC1F,eAAO,MAAM,cAAc,QAAkC,CAAC;AAC9D,qHAAqH;AACrH,eAAO,MAAM,WAAW,QAAqB,CAAC;AAE9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