@codyswann/lisa 8.6.0 → 8.7.0
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/all/copy-overwrite/scripts/lib/completion-authorization.mjs +3 -3
- package/all/copy-overwrite/scripts/lib/completion-proof-publisher.mjs +2 -1
- package/all/copy-overwrite/scripts/lib/completion-proof-shape.mjs +21 -1
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +3 -3
- package/dist/controls/attest-check.d.ts.map +1 -1
- package/dist/controls/attest-check.js +31 -18
- package/dist/controls/attest-check.js.map +1 -1
- package/dist/controls/attest-record.d.ts +3 -0
- package/dist/controls/attest-record.d.ts.map +1 -1
- package/dist/controls/attest-record.js +28 -5
- package/dist/controls/attest-record.js.map +1 -1
- package/dist/controls/checks-binding.d.ts.map +1 -1
- package/dist/controls/checks-binding.js +28 -1
- package/dist/controls/checks-binding.js.map +1 -1
- package/dist/controls/commands/attest-host-proof.d.ts +18 -0
- package/dist/controls/commands/attest-host-proof.d.ts.map +1 -0
- package/dist/controls/commands/attest-host-proof.js +168 -0
- package/dist/controls/commands/attest-host-proof.js.map +1 -0
- package/dist/controls/commands/attest-options.d.ts +4 -0
- package/dist/controls/commands/attest-options.d.ts.map +1 -1
- package/dist/controls/commands/attest.d.ts.map +1 -1
- package/dist/controls/commands/attest.js +52 -0
- package/dist/controls/commands/attest.js.map +1 -1
- package/dist/controls/commands/declaration-check.d.ts.map +1 -1
- package/dist/controls/commands/declaration-check.js +19 -5
- package/dist/controls/commands/declaration-check.js.map +1 -1
- package/dist/controls/commands/register.d.ts.map +1 -1
- package/dist/controls/commands/register.js +4 -1
- package/dist/controls/commands/register.js.map +1 -1
- package/dist/controls/evidence-document.d.ts.map +1 -1
- package/dist/controls/evidence-document.js +12 -0
- package/dist/controls/evidence-document.js.map +1 -1
- package/dist/controls/evidence-gather.d.ts +1 -0
- package/dist/controls/evidence-gather.d.ts.map +1 -1
- package/dist/controls/evidence-gather.js +5 -2
- package/dist/controls/evidence-gather.js.map +1 -1
- package/dist/controls/evidence-types.d.ts +19 -1
- package/dist/controls/evidence-types.d.ts.map +1 -1
- package/dist/controls/evidence-types.js +11 -0
- package/dist/controls/evidence-types.js.map +1 -1
- package/dist/controls/evidence-write.d.ts.map +1 -1
- package/dist/controls/evidence-write.js +7 -1
- package/dist/controls/evidence-write.js.map +1 -1
- package/dist/controls/exercise-declaration.d.ts +58 -0
- package/dist/controls/exercise-declaration.d.ts.map +1 -0
- package/dist/controls/exercise-declaration.js +138 -0
- package/dist/controls/exercise-declaration.js.map +1 -0
- package/dist/controls/exercise-observations.d.ts +32 -0
- package/dist/controls/exercise-observations.d.ts.map +1 -0
- package/dist/controls/exercise-observations.js +141 -0
- package/dist/controls/exercise-observations.js.map +1 -0
- package/dist/controls/exercise-record-shape.d.ts +10 -0
- package/dist/controls/exercise-record-shape.d.ts.map +1 -0
- package/dist/controls/exercise-record-shape.js +29 -0
- package/dist/controls/exercise-record-shape.js.map +1 -0
- package/dist/controls/exercise-records.d.ts +28 -0
- package/dist/controls/exercise-records.d.ts.map +1 -0
- package/dist/controls/exercise-records.js +113 -0
- package/dist/controls/exercise-records.js.map +1 -0
- package/dist/controls/exercise-result.d.ts +23 -0
- package/dist/controls/exercise-result.d.ts.map +1 -0
- package/dist/controls/exercise-result.js +186 -0
- package/dist/controls/exercise-result.js.map +1 -0
- package/dist/controls/host-proof-input.d.ts +53 -0
- package/dist/controls/host-proof-input.d.ts.map +1 -0
- package/dist/controls/host-proof-input.js +129 -0
- package/dist/controls/host-proof-input.js.map +1 -0
- package/dist/controls/host-proof-receipt.d.ts +47 -0
- package/dist/controls/host-proof-receipt.d.ts.map +1 -0
- package/dist/controls/host-proof-receipt.js +132 -0
- package/dist/controls/host-proof-receipt.js.map +1 -0
- package/dist/controls/host-proof-register.d.ts +37 -0
- package/dist/controls/host-proof-register.d.ts.map +1 -0
- package/dist/controls/host-proof-register.js +153 -0
- package/dist/controls/host-proof-register.js.map +1 -0
- package/dist/controls/host-proof-signature.d.ts +30 -0
- package/dist/controls/host-proof-signature.d.ts.map +1 -0
- package/dist/controls/host-proof-signature.js +49 -0
- package/dist/controls/host-proof-signature.js.map +1 -0
- package/dist/controls/host-proof-trust.d.ts +33 -0
- package/dist/controls/host-proof-trust.d.ts.map +1 -0
- package/dist/controls/host-proof-trust.js +124 -0
- package/dist/controls/host-proof-trust.js.map +1 -0
- package/dist/controls/pull-request-executor.d.ts +18 -6
- package/dist/controls/pull-request-executor.d.ts.map +1 -1
- package/dist/controls/pull-request-executor.js +19 -24
- package/dist/controls/pull-request-executor.js.map +1 -1
- package/dist/controls/register-types.d.ts +3 -4
- package/dist/controls/register-types.d.ts.map +1 -1
- package/dist/controls/register-types.js +3 -4
- package/dist/controls/register-types.js.map +1 -1
- package/dist/controls/register.d.ts +4 -7
- package/dist/controls/register.d.ts.map +1 -1
- package/dist/controls/register.js +17 -6
- package/dist/controls/register.js.map +1 -1
- package/dist/controls/verdict-answers.d.ts.map +1 -1
- package/dist/controls/verdict-answers.js +6 -2
- package/dist/controls/verdict-answers.js.map +1 -1
- package/dist/controls/verdict-types.d.ts +1 -1
- package/dist/controls/verdict-types.d.ts.map +1 -1
- package/dist/controls/verdict-types.js +2 -0
- package/dist/controls/verdict-types.js.map +1 -1
- package/dist/controls/verdict-wording.d.ts +2 -0
- package/dist/controls/verdict-wording.d.ts.map +1 -1
- package/dist/controls/verdict-wording.js +7 -0
- package/dist/controls/verdict-wording.js.map +1 -1
- package/dist/controls/verdict.d.ts +2 -0
- package/dist/controls/verdict.d.ts.map +1 -1
- package/dist/controls/verdict.js +17 -2
- package/dist/controls/verdict.js.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.json +14 -0
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.json +64 -9
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/scripts/human-gate-act.mjs +50 -21
- package/plugins/lisa/.codex-plugin/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa/.codex-plugin/skills/lisa-usage-accounting/references/estimate.md +5 -5
- package/plugins/lisa/scripts/human-gate-act.mjs +50 -21
- package/plugins/lisa/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa/skills/lisa-usage-accounting/references/estimate.md +5 -5
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/scripts/human-gate-act.mjs +50 -21
- package/plugins/lisa-agy/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-agy/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-agy/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-agy/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-agy/skills/lisa-usage-accounting/references/estimate.md +5 -5
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/scripts/human-gate-act.mjs +50 -21
- package/plugins/lisa-copilot/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-copilot/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-copilot/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-copilot/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-copilot/skills/lisa-usage-accounting/references/estimate.md +5 -5
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/scripts/human-gate-act.mjs +50 -21
- package/plugins/lisa-cursor/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-cursor/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-cursor/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-cursor/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-cursor/skills/lisa-usage-accounting/references/estimate.md +5 -5
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/scripts/human-gate-act.mjs +50 -21
- package/plugins/lisa-devin/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-devin/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-devin/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-devin/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-devin/skills/lisa-usage-accounting/references/estimate.md +5 -5
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/scripts/human-gate-act.mjs +50 -21
- package/plugins/src/base/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/src/base/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/src/base/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/src/base/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/src/base/skills/lisa-usage-accounting/references/estimate.md +5 -5
- package/schemas/control-evidence.schema.json +39 -1
- package/schemas/control-verdict.schema.json +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Receipts authenticate what attest recorded for a specific hosted check. */
|
|
2
|
+
import type { KeyObject } from "node:crypto";
|
|
3
|
+
import type { EvidenceDocument } from "./evidence-types.js";
|
|
4
|
+
import { type HostProofInput, type HostProofRunIdentity, type HostProofSubject } from "./host-proof-input.js";
|
|
5
|
+
import type { HostProofTrust } from "./host-proof-trust.js";
|
|
6
|
+
import type { PullRequestExecutor } from "./register-types.js";
|
|
7
|
+
/** Where the attest writer places its authenticated receipts. */
|
|
8
|
+
export declare const HOST_PROOF_RECEIPTS_PATH = ".lisa/controls/host-proof-receipts.json";
|
|
9
|
+
/** A checked receipt binds the exact records written for both runs. */
|
|
10
|
+
interface HostProofReceipt {
|
|
11
|
+
readonly schema_version: 1;
|
|
12
|
+
readonly subject: HostProofSubject;
|
|
13
|
+
readonly adjudicator: string;
|
|
14
|
+
readonly attestor: string;
|
|
15
|
+
readonly issued_at: string;
|
|
16
|
+
readonly input_digest: string;
|
|
17
|
+
readonly records_digest: string;
|
|
18
|
+
readonly runs: Readonly<Record<"clean" | "violation", HostProofRunIdentity>>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sign the passed pair that attest is about to write, using the protected issuer.
|
|
22
|
+
* @param source - The independently adjudicated input
|
|
23
|
+
* @param evidence - The exact evidence text's parsed data
|
|
24
|
+
* @param trust - The external authorization for this repository
|
|
25
|
+
* @param signer - The matching private key, available only to the attestor
|
|
26
|
+
* @param now - When these records are written
|
|
27
|
+
* @returns A signed receipt, or null when the completed pair did not hold
|
|
28
|
+
*/
|
|
29
|
+
export declare function sealHostProof(source: HostProofInput, evidence: EvidenceDocument, trust: HostProofTrust, signer: KeyObject, now: Date): import("./host-proof-signature.js").SignedHostProof<HostProofReceipt> | null;
|
|
30
|
+
/** All information needed to check one receipt against current evidence. */
|
|
31
|
+
interface ReceiptCheck {
|
|
32
|
+
readonly evidence: EvidenceDocument;
|
|
33
|
+
readonly checkedDigest: string;
|
|
34
|
+
readonly trust: HostProofTrust;
|
|
35
|
+
readonly entry: string;
|
|
36
|
+
readonly executor: PullRequestExecutor;
|
|
37
|
+
readonly now: Date;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check the attestor, target, written records and evidence age together.
|
|
41
|
+
* @param envelope - A candidate receipt read from the checkout
|
|
42
|
+
* @param check - The actual repository, authority, entry and current evidence
|
|
43
|
+
* @returns Why the receipt cannot clear the mark, or null when it can
|
|
44
|
+
*/
|
|
45
|
+
export declare function hostProofReceiptProblem(envelope: unknown, check: ReceiptCheck): string | null;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=host-proof-receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-receipt.d.ts","sourceRoot":"","sources":["../../src/controls/host-proof-receipt.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,4CACM,CAAC;AAK5C,uEAAuE;AACvE,UAAU,gBAAgB;IACxB,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,GAAG,WAAW,EAAE,oBAAoB,CAAC,CAAC,CAAC;CAC9E;AAgED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,IAAI,gFAoBV;AAED,4EAA4E;AAC5E,UAAU,YAAY;IACpB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;CACpB;AAqBD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,YAAY,GAClB,MAAM,GAAG,IAAI,CAkCf"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { isJsonObject } from "../sync/json-path.js";
|
|
2
|
+
import { isCanonicalUtc, isEvidenceFresh } from "./evidence.js";
|
|
3
|
+
import { isSha256 } from "./evidence-binding.js";
|
|
4
|
+
import { isHostProofRunIdentity, isHostProofSubject, } from "./host-proof-input.js";
|
|
5
|
+
import { signHostProof, verifyHostProof } from "./host-proof-signature.js";
|
|
6
|
+
import { digestOf } from "./verdict-digest.js";
|
|
7
|
+
/** Where the attest writer places its authenticated receipts. */
|
|
8
|
+
export const HOST_PROOF_RECEIPTS_PATH = ".lisa/controls/host-proof-receipts.json";
|
|
9
|
+
/** Do not let an input signature stand in for this receipt's signature. */
|
|
10
|
+
const RECEIPT = "host-proof-receipt";
|
|
11
|
+
/**
|
|
12
|
+
* Hide the raw captured text while retaining the evidence identity.
|
|
13
|
+
* @param run - One authorized run
|
|
14
|
+
* @returns Its host identifier, locator, commit, and artifact hash
|
|
15
|
+
*/
|
|
16
|
+
function runIdentity(run) {
|
|
17
|
+
const { run_id, run_url, commit, artifact_sha256 } = run;
|
|
18
|
+
return { run_id, run_url, commit, artifact_sha256 };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Select the finalized exercised evidence for one entry and moment.
|
|
22
|
+
* @param evidence - The complete evidence document
|
|
23
|
+
* @param entry - The register entry whose records are being sealed or checked
|
|
24
|
+
* @returns The exact records, in evidence order
|
|
25
|
+
*/
|
|
26
|
+
function recordsFor(evidence, entry) {
|
|
27
|
+
return evidence.records.filter(record => record.entry_id === entry &&
|
|
28
|
+
record.moment === "pull-request" &&
|
|
29
|
+
record.rung === "exercised");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Tell whether the paired records both held while the approved binding was current.
|
|
33
|
+
* @param records - All exercised records of the entry
|
|
34
|
+
* @param checksDigest - The digest of the currently bound check definitions
|
|
35
|
+
* @param now - The clock used by attest and register
|
|
36
|
+
* @returns The reason the pair cannot be relied on, or null
|
|
37
|
+
*/
|
|
38
|
+
function pairProblem(records, checksDigest, now) {
|
|
39
|
+
const clean = records.filter(record => record.half === "clean");
|
|
40
|
+
const violating = new Set(records
|
|
41
|
+
.filter(record => record.half === "violation")
|
|
42
|
+
.map(record => record.criterion));
|
|
43
|
+
if (clean.length === 0 ||
|
|
44
|
+
records.length !== 2 * clean.length ||
|
|
45
|
+
violating.size !== clean.length ||
|
|
46
|
+
clean.some(record => !violating.has(record.criterion)) ||
|
|
47
|
+
records.some(record => record.result !== "held" || record.checks_digest !== checksDigest))
|
|
48
|
+
return "The evidence does not contain both held halves for the current check definitions.";
|
|
49
|
+
return records.every(record => isEvidenceFresh(record, now))
|
|
50
|
+
? null
|
|
51
|
+
: "At least one half of the recorded proof is outside its evidence lifetime.";
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sign the passed pair that attest is about to write, using the protected issuer.
|
|
55
|
+
* @param source - The independently adjudicated input
|
|
56
|
+
* @param evidence - The exact evidence text's parsed data
|
|
57
|
+
* @param trust - The external authorization for this repository
|
|
58
|
+
* @param signer - The matching private key, available only to the attestor
|
|
59
|
+
* @param now - When these records are written
|
|
60
|
+
* @returns A signed receipt, or null when the completed pair did not hold
|
|
61
|
+
*/
|
|
62
|
+
export function sealHostProof(source, evidence, trust, signer, now) {
|
|
63
|
+
const { subject, clean, violation } = source;
|
|
64
|
+
const records = recordsFor(evidence, subject.entry_id);
|
|
65
|
+
if (subject.checks_digest !== evidence.checks.digest ||
|
|
66
|
+
pairProblem(records, subject.checks_digest, now) !== null)
|
|
67
|
+
return null;
|
|
68
|
+
const receipt = {
|
|
69
|
+
schema_version: 1,
|
|
70
|
+
subject,
|
|
71
|
+
adjudicator: trust.adjudicator.id,
|
|
72
|
+
attestor: trust.attestor.id,
|
|
73
|
+
issued_at: now.toISOString(),
|
|
74
|
+
input_digest: digestOf(source),
|
|
75
|
+
records_digest: digestOf(records),
|
|
76
|
+
runs: { clean: runIdentity(clean), violation: runIdentity(violation) },
|
|
77
|
+
};
|
|
78
|
+
return signHostProof(RECEIPT, receipt, signer);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check the shape of both immutable run identities recorded by the attestor.
|
|
82
|
+
* @param runs - Run fields in the signed receipt
|
|
83
|
+
* @returns Whether the receipt describes two distinct commits and runs
|
|
84
|
+
*/
|
|
85
|
+
function receiptRuns(runs) {
|
|
86
|
+
return (isJsonObject(runs) &&
|
|
87
|
+
Object.keys(runs).length === 2 &&
|
|
88
|
+
isHostProofRunIdentity(runs.clean) &&
|
|
89
|
+
isHostProofRunIdentity(runs.violation) &&
|
|
90
|
+
Object.keys(runs.clean).length === 4 &&
|
|
91
|
+
Object.keys(runs.violation).length === 4 &&
|
|
92
|
+
runs.clean.run_id !== runs.violation.run_id &&
|
|
93
|
+
runs.clean.run_url !== runs.violation.run_url &&
|
|
94
|
+
runs.clean.commit !== runs.violation.commit);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check the attestor, target, written records and evidence age together.
|
|
98
|
+
* @param envelope - A candidate receipt read from the checkout
|
|
99
|
+
* @param check - The actual repository, authority, entry and current evidence
|
|
100
|
+
* @returns Why the receipt cannot clear the mark, or null when it can
|
|
101
|
+
*/
|
|
102
|
+
export function hostProofReceiptProblem(envelope, check) {
|
|
103
|
+
const { evidence, checkedDigest, trust, entry, executor, now } = check;
|
|
104
|
+
const receipt = verifyHostProof(envelope, RECEIPT, trust.attestor.key);
|
|
105
|
+
if (receipt === null)
|
|
106
|
+
return "The receipt signature could not be verified with the authorized attestor key.";
|
|
107
|
+
if (Object.keys(receipt).length !== 8 ||
|
|
108
|
+
receipt.schema_version !== 1 ||
|
|
109
|
+
receipt.adjudicator !== trust.adjudicator.id ||
|
|
110
|
+
receipt.attestor !== trust.attestor.id ||
|
|
111
|
+
!isCanonicalUtc(receipt.issued_at) ||
|
|
112
|
+
Date.parse(receipt.issued_at) > now.getTime() ||
|
|
113
|
+
!isSha256(receipt.input_digest) ||
|
|
114
|
+
!isSha256(receipt.records_digest) ||
|
|
115
|
+
!isHostProofSubject(receipt.subject) ||
|
|
116
|
+
!receiptRuns(receipt.runs))
|
|
117
|
+
return "The signed receipt has an invalid schema, run identity, or issuing authority.";
|
|
118
|
+
const { subject } = receipt;
|
|
119
|
+
if (subject.repository !== trust.repository ||
|
|
120
|
+
subject.environment !== trust.environment ||
|
|
121
|
+
subject.entry_id !== entry ||
|
|
122
|
+
subject.platform !== executor.platform ||
|
|
123
|
+
subject.executor_path !== executor.path ||
|
|
124
|
+
subject.checks_digest !== checkedDigest ||
|
|
125
|
+
evidence.checks.digest !== checkedDigest)
|
|
126
|
+
return "The receipt targets a different repository, environment, entry, executor, or check definition.";
|
|
127
|
+
const records = recordsFor(evidence, entry);
|
|
128
|
+
return receipt.records_digest === digestOf(records)
|
|
129
|
+
? pairProblem(records, checkedDigest, now)
|
|
130
|
+
: "The recorded evidence does not match the signed receipt.";
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=host-proof-receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-receipt.js","sourceRoot":"","sources":["../../src/controls/host-proof-receipt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MA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AC,CAAC,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,CAAC;QAC1C,CAAC,CAAC,0DAA0D,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Resolve which hosted checks have a current receipt from an authorized attestor. */
|
|
2
|
+
import type { KeyObject } from "node:crypto";
|
|
3
|
+
import type { EvidenceDocument } from "./evidence-types.js";
|
|
4
|
+
import type { HostProofInput } from "./host-proof-input.js";
|
|
5
|
+
import { type HostProofTrust } from "./host-proof-trust.js";
|
|
6
|
+
import type { ControlRegisterEntry } from "./register-types.js";
|
|
7
|
+
/** The verified input and protected issuer of the next receipt. */
|
|
8
|
+
export interface PendingHostReceipt {
|
|
9
|
+
readonly source: HostProofInput;
|
|
10
|
+
readonly trust: HostProofTrust;
|
|
11
|
+
readonly signer: KeyObject;
|
|
12
|
+
}
|
|
13
|
+
/** Current entry ids and fixed diagnostic text for any remaining gaps. */
|
|
14
|
+
interface HostProofStatus {
|
|
15
|
+
readonly current: ReadonlySet<string>;
|
|
16
|
+
readonly notes: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Seal only the records the next attest write will actually store.
|
|
20
|
+
* @param root - Real checkout path
|
|
21
|
+
* @param evidence - The finalized evidence to be written with the receipt
|
|
22
|
+
* @param pending - The approved input and private attestor identity
|
|
23
|
+
* @param now - When the proof was recorded
|
|
24
|
+
* @returns The receipt file text, or null if the update could not be produced
|
|
25
|
+
*/
|
|
26
|
+
export declare function hostReceiptText(root: string, evidence: EvidenceDocument, pending: PendingHostReceipt, now: Date): Promise<string | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Recompute the current binding and check the attest signature for each entry.
|
|
29
|
+
* @param root - Real checkout path
|
|
30
|
+
* @param entries - Register entries marked unproved before checking receipts
|
|
31
|
+
* @param now - The same clock used to assess the evidence's expiry
|
|
32
|
+
* @param trustPath - Externally selected trust configuration for this process
|
|
33
|
+
* @returns Entries whose exact stored proof is current and notes for the other entries
|
|
34
|
+
*/
|
|
35
|
+
export declare function evaluateHostReceipts(root: string, entries: readonly ControlRegisterEntry[], now: Date, trustPath?: string | undefined): Promise<HostProofStatus>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=host-proof-register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-register.d.ts","sourceRoot":"","sources":["../../src/controls/host-proof-register.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAS7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM5D,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,0EAA0E;AAC1E,UAAU,eAAe;IACvB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAyED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,IAAI,GACR,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxB;AA+BD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,oBAAoB,EAAE,EACxC,GAAG,EAAE,IAAI,EACT,SAAS,qBAAiC,GACzC,OAAO,CAAC,eAAe,CAAC,CAkC1B"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { isJsonObject } from "../sync/json-path.js";
|
|
2
|
+
import { readEnv } from "../utils/process-environment.js";
|
|
3
|
+
import { canonicalFileText } from "./canonical-json.js";
|
|
4
|
+
import { bindChecks } from "./checks-binding.js";
|
|
5
|
+
import { readControlFile } from "./control-files.js";
|
|
6
|
+
import { EVIDENCE_PATH } from "./evidence.js";
|
|
7
|
+
import { parseEvidenceDocument } from "./evidence-document.js";
|
|
8
|
+
import { HOST_PROOF_RECEIPTS_PATH, hostProofReceiptProblem, sealHostProof, } from "./host-proof-receipt.js";
|
|
9
|
+
import { HOST_PROOF_TRUST_FILE, loadHostProofTrust, } from "./host-proof-trust.js";
|
|
10
|
+
import { readOriginUrl } from "./protect-platform.js";
|
|
11
|
+
import { unwrittenExecutor } from "./pull-request-executor.js";
|
|
12
|
+
/**
|
|
13
|
+
* Read the receipt list without assuming any row is trustworthy.
|
|
14
|
+
* @param root - Real checkout path
|
|
15
|
+
* @returns The proposed receipts, or null when the file cannot be used
|
|
16
|
+
*/
|
|
17
|
+
async function readHostProofReceipts(root) {
|
|
18
|
+
const file = await readControlFile(root, HOST_PROOF_RECEIPTS_PATH);
|
|
19
|
+
if (file.kind === "missing")
|
|
20
|
+
return [];
|
|
21
|
+
if (file.kind !== "text")
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
const value = JSON.parse(file.text);
|
|
25
|
+
return Array.isArray(value) ? value : null;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Find the reason this entry's signed record cannot be used.
|
|
33
|
+
* @param entry - A hosted register entry
|
|
34
|
+
* @param evidence - The exact stored evidence, bound to the current files
|
|
35
|
+
* @param receipts - Candidate receipts from the checkout
|
|
36
|
+
* @param trust - The authorized parties for the checkout
|
|
37
|
+
* @param now - The same clock used to check the evidence lifetime
|
|
38
|
+
* @returns A fixed diagnostic, or null when the receipt is current
|
|
39
|
+
*/
|
|
40
|
+
function entryProofProblem(entry, evidence, receipts, trust, now) {
|
|
41
|
+
const executor = unwrittenExecutor(entry);
|
|
42
|
+
if (executor === null ||
|
|
43
|
+
!evidence.checks.covered.some(file => file.path === executor.path))
|
|
44
|
+
return "The evidence does not cover the declared executor file.";
|
|
45
|
+
const candidates = receipts.filter(receipt => receiptEntry(receipt) === entry.id);
|
|
46
|
+
const problems = candidates.map(receipt => hostProofReceiptProblem(receipt, {
|
|
47
|
+
evidence,
|
|
48
|
+
checkedDigest: evidence.checks.digest,
|
|
49
|
+
trust,
|
|
50
|
+
entry: entry.id,
|
|
51
|
+
executor,
|
|
52
|
+
now,
|
|
53
|
+
}));
|
|
54
|
+
if (problems.includes(null))
|
|
55
|
+
return null;
|
|
56
|
+
return problems[0] ?? "There is no signed receipt for this entry.";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Read the entry name out of an existing list slot so attest can replace it.
|
|
60
|
+
* @param value - A receipt candidate that may have been edited
|
|
61
|
+
* @returns The claimed entry, or undefined when there is none
|
|
62
|
+
*/
|
|
63
|
+
function receiptEntry(value) {
|
|
64
|
+
return isJsonObject(value) &&
|
|
65
|
+
isJsonObject(value.body) &&
|
|
66
|
+
isJsonObject(value.body.subject)
|
|
67
|
+
? value.body.subject.entry_id
|
|
68
|
+
: undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Seal only the records the next attest write will actually store.
|
|
72
|
+
* @param root - Real checkout path
|
|
73
|
+
* @param evidence - The finalized evidence to be written with the receipt
|
|
74
|
+
* @param pending - The approved input and private attestor identity
|
|
75
|
+
* @param now - When the proof was recorded
|
|
76
|
+
* @returns The receipt file text, or null if the update could not be produced
|
|
77
|
+
*/
|
|
78
|
+
export async function hostReceiptText(root, evidence, pending, now) {
|
|
79
|
+
const receipt = sealHostProof(pending.source, evidence, pending.trust, pending.signer, now);
|
|
80
|
+
if (receipt === null)
|
|
81
|
+
return null;
|
|
82
|
+
const earlier = await readHostProofReceipts(root);
|
|
83
|
+
if (earlier === null)
|
|
84
|
+
return null;
|
|
85
|
+
return canonicalFileText([
|
|
86
|
+
...earlier.filter(row => receiptEntry(row) !== pending.source.subject.entry_id),
|
|
87
|
+
receipt,
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Read the evidence and candidate receipts with a current binding.
|
|
92
|
+
* @param root - Real checkout path
|
|
93
|
+
* @returns The current evidence and candidate receipts, or why they cannot be used
|
|
94
|
+
*/
|
|
95
|
+
async function currentReceiptInputs(root) {
|
|
96
|
+
const [evidenceFile, receipts] = await Promise.all([
|
|
97
|
+
readControlFile(root, EVIDENCE_PATH),
|
|
98
|
+
readHostProofReceipts(root),
|
|
99
|
+
]);
|
|
100
|
+
if (receipts === null)
|
|
101
|
+
return "The host proof receipt file is unreadable or invalid.";
|
|
102
|
+
if (receipts.length === 0)
|
|
103
|
+
return "No signed host proof receipt is on record.";
|
|
104
|
+
if (evidenceFile.kind !== "text")
|
|
105
|
+
return "The signed receipts have no readable evidence file.";
|
|
106
|
+
const parsed = parseEvidenceDocument(JSON.parse(evidenceFile.text));
|
|
107
|
+
if (parsed.problems !== null)
|
|
108
|
+
return "The evidence file does not match the required schema.";
|
|
109
|
+
const evidence = parsed.document;
|
|
110
|
+
const covered = evidence.checks.covered.map(file => file.path);
|
|
111
|
+
const binding = await bindChecks({ repository: root, also: covered });
|
|
112
|
+
return binding.digest === evidence.checks.digest
|
|
113
|
+
? { evidence, receipts }
|
|
114
|
+
: "The check definitions changed after the host proof was recorded.";
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Recompute the current binding and check the attest signature for each entry.
|
|
118
|
+
* @param root - Real checkout path
|
|
119
|
+
* @param entries - Register entries marked unproved before checking receipts
|
|
120
|
+
* @param now - The same clock used to assess the evidence's expiry
|
|
121
|
+
* @param trustPath - Externally selected trust configuration for this process
|
|
122
|
+
* @returns Entries whose exact stored proof is current and notes for the other entries
|
|
123
|
+
*/
|
|
124
|
+
export async function evaluateHostReceipts(root, entries, now, trustPath = readEnv(HOST_PROOF_TRUST_FILE)) {
|
|
125
|
+
const wanted = entries.filter(entry => entry.status === "unproved");
|
|
126
|
+
const unresolved = (message) => ({
|
|
127
|
+
current: new Set(),
|
|
128
|
+
notes: [message],
|
|
129
|
+
});
|
|
130
|
+
if (wanted.length === 0 || trustPath === undefined)
|
|
131
|
+
return { current: new Set(), notes: [] };
|
|
132
|
+
try {
|
|
133
|
+
const trust = await loadHostProofTrust(root, trustPath);
|
|
134
|
+
if (trust === null || (await readOriginUrl(root)) !== trust.repository)
|
|
135
|
+
return unresolved("The external host proof trust file is invalid or does not match this repository's origin.");
|
|
136
|
+
const inputs = await currentReceiptInputs(root);
|
|
137
|
+
if (typeof inputs === "string")
|
|
138
|
+
return unresolved(inputs);
|
|
139
|
+
const { evidence, receipts } = inputs;
|
|
140
|
+
const outcomes = wanted.map(entry => ({
|
|
141
|
+
id: entry.id,
|
|
142
|
+
problem: entryProofProblem(entry, evidence, receipts, trust, now),
|
|
143
|
+
}));
|
|
144
|
+
return {
|
|
145
|
+
current: new Set(outcomes.flatMap(({ id, problem }) => (problem === null ? [id] : []))),
|
|
146
|
+
notes: outcomes.flatMap(({ id, problem }) => problem === null ? [] : [`${id}: ${problem}`]),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return unresolved("The host proof receipt or evidence could not be checked.");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=host-proof-register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-register.js","sourceRoot":"","sources":["../../src/controls/host-proof-register.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CA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,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACpC,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,OAAO,EAAE,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC;SAClE,CAAC,CAAC,CAAC;QACJ,OAAO;YACL,OAAO,EAAE,IAAI,GAAG,CACd,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CACtE;YACD,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAC1C,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,OAAO,EAAE,CAAC,CAC9C;SACF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CACf,0DAA0D,CAC3D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Sign adjudicated host proof input and the receipts generated by attest. */
|
|
2
|
+
import { type KeyObject } from "node:crypto";
|
|
3
|
+
/** Each signed statement is valid only for its intended proof route. */
|
|
4
|
+
type ProofPurpose = "host-proof-import" | "host-proof-receipt" | "artifact-exercise";
|
|
5
|
+
/** The canonical output covers the phase as well as the evidence body. */
|
|
6
|
+
export interface SignedHostProof<Body> {
|
|
7
|
+
readonly purpose: ProofPurpose;
|
|
8
|
+
readonly body: Body;
|
|
9
|
+
readonly signature: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Sign the canonical body and its intended use with a trusted private key.
|
|
13
|
+
* @param purpose - Whether this is an adjudicated input or an attest receipt
|
|
14
|
+
* @param body - The validated statement
|
|
15
|
+
* @param key - The signer's private Ed25519 key
|
|
16
|
+
* @returns A signed envelope
|
|
17
|
+
* @throws {TypeError} When the supplied key cannot sign this envelope
|
|
18
|
+
*/
|
|
19
|
+
export declare function signHostProof<Body extends object>(purpose: ProofPurpose, body: Body, key: KeyObject): SignedHostProof<Body>;
|
|
20
|
+
/**
|
|
21
|
+
* Return a signed statement only when the authorized signer and phase match.
|
|
22
|
+
* The caller validates the authenticated body's structure and applicability.
|
|
23
|
+
* @param envelope - The untrusted statement and its signature
|
|
24
|
+
* @param purpose - The expected use of the signed statement
|
|
25
|
+
* @param key - The trusted public Ed25519 key for that use
|
|
26
|
+
* @returns The authenticated body, or null when the signature cannot be used
|
|
27
|
+
*/
|
|
28
|
+
export declare function verifyHostProof(envelope: unknown, purpose: ProofPurpose, key: KeyObject): Readonly<Record<string, unknown>> | null;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=host-proof-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-signature.d.ts","sourceRoot":"","sources":["../../src/controls/host-proof-signature.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAK3D,wEAAwE;AACxE,KAAK,YAAY,GACb,mBAAmB,GACnB,oBAAoB,GACpB,mBAAmB,CAAC;AAExB,0EAA0E;AAC1E,MAAM,WAAW,eAAe,CAAC,IAAI;IACnC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAKD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,EAC/C,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,SAAS,GACb,eAAe,CAAC,IAAI,CAAC,CAOvB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,SAAS,GACb,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAmB1C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Sign adjudicated host proof input and the receipts generated by attest. */
|
|
2
|
+
import { sign, verify } from "node:crypto";
|
|
3
|
+
import { isJsonObject } from "../sync/json-path.js";
|
|
4
|
+
import { canonicalText } from "./canonical-json.js";
|
|
5
|
+
/** An Ed25519 signature without Base64 padding occupies 86 characters. */
|
|
6
|
+
const ENCODED_SIGNATURE = /^[A-Za-z0-9_-]{86}$/u;
|
|
7
|
+
/**
|
|
8
|
+
* Sign the canonical body and its intended use with a trusted private key.
|
|
9
|
+
* @param purpose - Whether this is an adjudicated input or an attest receipt
|
|
10
|
+
* @param body - The validated statement
|
|
11
|
+
* @param key - The signer's private Ed25519 key
|
|
12
|
+
* @returns A signed envelope
|
|
13
|
+
* @throws {TypeError} When the supplied key cannot sign this envelope
|
|
14
|
+
*/
|
|
15
|
+
export function signHostProof(purpose, body, key) {
|
|
16
|
+
if (key.type !== "private" || key.asymmetricKeyType !== "ed25519") {
|
|
17
|
+
throw new TypeError("Host proof signing needs a private Ed25519 key.");
|
|
18
|
+
}
|
|
19
|
+
const payload = { purpose, body };
|
|
20
|
+
const signature = sign(null, Buffer.from(canonicalText(payload)), key);
|
|
21
|
+
return { ...payload, signature: signature.toString("base64url") };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Return a signed statement only when the authorized signer and phase match.
|
|
25
|
+
* The caller validates the authenticated body's structure and applicability.
|
|
26
|
+
* @param envelope - The untrusted statement and its signature
|
|
27
|
+
* @param purpose - The expected use of the signed statement
|
|
28
|
+
* @param key - The trusted public Ed25519 key for that use
|
|
29
|
+
* @returns The authenticated body, or null when the signature cannot be used
|
|
30
|
+
*/
|
|
31
|
+
export function verifyHostProof(envelope, purpose, key) {
|
|
32
|
+
if (key.type !== "public" ||
|
|
33
|
+
key.asymmetricKeyType !== "ed25519" ||
|
|
34
|
+
!isJsonObject(envelope) ||
|
|
35
|
+
Object.keys(envelope).length !== 3 ||
|
|
36
|
+
envelope.purpose !== purpose ||
|
|
37
|
+
!isJsonObject(envelope.body) ||
|
|
38
|
+
typeof envelope.signature !== "string" ||
|
|
39
|
+
!ENCODED_SIGNATURE.test(envelope.signature))
|
|
40
|
+
return null;
|
|
41
|
+
const signature = Buffer.from(envelope.signature, "base64url");
|
|
42
|
+
if (signature.toString("base64url") !== envelope.signature)
|
|
43
|
+
return null;
|
|
44
|
+
const message = canonicalText({ purpose, body: envelope.body });
|
|
45
|
+
return verify(null, Buffer.from(message), key, signature)
|
|
46
|
+
? envelope.body
|
|
47
|
+
: null;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=host-proof-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-signature.js","sourceRoot":"","sources":["../../src/controls/host-proof-signature.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAkB,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAepD,0EAA0E;AAC1E,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAqB,EACrB,IAAU,EACV,GAAc;IAEd,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAClE,MAAM,IAAI,SAAS,CAAC,iDAAiD,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,OAAO,GAAG,EAAE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|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Read trust keys from operator configuration outside the audited checkout. */
|
|
2
|
+
import { type KeyObject } from "node:crypto";
|
|
3
|
+
/** Where the operator can identify the trusted issuers for this process. */
|
|
4
|
+
export declare const HOST_PROOF_TRUST_FILE = "LISA_HOST_PROOF_TRUST_FILE";
|
|
5
|
+
/** The issuer's identity is fixed by each external trust configuration. */
|
|
6
|
+
interface Identity {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly key: KeyObject;
|
|
9
|
+
}
|
|
10
|
+
/** Trusted roles and the repository they can speak for. */
|
|
11
|
+
export interface HostProofTrust {
|
|
12
|
+
readonly repository: string;
|
|
13
|
+
readonly environment: string;
|
|
14
|
+
readonly adjudicator: Identity;
|
|
15
|
+
readonly attestor: Identity;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load the independent adjudicator and attest issuer for this checkout.
|
|
19
|
+
* @param root - Real path of the checkout under evaluation
|
|
20
|
+
* @param named - Path selected by the operator through the process environment
|
|
21
|
+
* @returns The issuers and scope, or null if no trusted configuration is usable
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadHostProofTrust(root: string, named: string | undefined): Promise<HostProofTrust | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Load the protected private key for the attest process only.
|
|
26
|
+
* @param root - Real path of the checkout under evaluation
|
|
27
|
+
* @param named - Explicit private key path supplied to attest
|
|
28
|
+
* @param trust - The public attestor key pinned outside the checkout
|
|
29
|
+
* @returns The matching private key, or null when it cannot be used
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadHostProofSigningKey(root: string, named: string, trust: HostProofTrust): Promise<KeyObject | null>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=host-proof-trust.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-trust.d.ts","sourceRoot":"","sources":["../../src/controls/host-proof-trust.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAqC,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAQhF,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,+BAA+B,CAAC;AAKlE,2EAA2E;AAC3E,UAAU,QAAQ;IAChB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AA8DD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAiChC;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAY3B"}
|