@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,29 @@
|
|
|
1
|
+
/** Structural requirements for an exercised artifact in the evidence file. */
|
|
2
|
+
import { ARTIFACT_EXERCISED, exerciseRecordId, } from "./evidence-types.js";
|
|
3
|
+
import { EXERCISE_CRITERIA } from "./exercise-declaration.js";
|
|
4
|
+
/**
|
|
5
|
+
* Check the exercise's identity, outcome and relationship to the evidence file.
|
|
6
|
+
* @param record - A record whose fields are individually well formed
|
|
7
|
+
* @param exercise - Its typed artifact identity
|
|
8
|
+
* @returns Why its fields cannot form an exercised artifact, if anything differs
|
|
9
|
+
*/
|
|
10
|
+
export function exerciseRecordProblems(record, exercise) {
|
|
11
|
+
return record.rung === "exercised" &&
|
|
12
|
+
record.result === "held" &&
|
|
13
|
+
record.reason === ARTIFACT_EXERCISED &&
|
|
14
|
+
record.entry_id === null &&
|
|
15
|
+
record.moment === null &&
|
|
16
|
+
record.command === null &&
|
|
17
|
+
record.commit === null &&
|
|
18
|
+
record.exit_status === null &&
|
|
19
|
+
record.output_excerpt === "" &&
|
|
20
|
+
!record.output_truncated &&
|
|
21
|
+
record.half === undefined &&
|
|
22
|
+
EXERCISE_CRITERIA.some(criterion => criterion === record.criterion) &&
|
|
23
|
+
record.id === exerciseRecordId(record.criterion, exercise.target)
|
|
24
|
+
? []
|
|
25
|
+
: [
|
|
26
|
+
"An artifact exercise needs its typed criterion and target, the exercised rung and a held result without a gate or half",
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=exercise-record-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exercise-record-shape.js","sourceRoot":"","sources":["../../src/controls/exercise-record-shape.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GAGjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAsB,EACtB,QAAgC;IAEhC,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW;QAChC,MAAM,CAAC,MAAM,KAAK,MAAM;QACxB,MAAM,CAAC,MAAM,KAAK,kBAAkB;QACpC,MAAM,CAAC,QAAQ,KAAK,IAAI;QACxB,MAAM,CAAC,MAAM,KAAK,IAAI;QACtB,MAAM,CAAC,OAAO,KAAK,IAAI;QACvB,MAAM,CAAC,MAAM,KAAK,IAAI;QACtB,MAAM,CAAC,WAAW,KAAK,IAAI;QAC3B,MAAM,CAAC,cAAc,KAAK,EAAE;QAC5B,CAAC,MAAM,CAAC,gBAAgB;QACxB,MAAM,CAAC,IAAI,KAAK,SAAS;QACzB,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,CAAC;QACnE,MAAM,CAAC,EAAE,KAAK,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC;QACjE,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACE,wHAAwH;SACzH,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ChecksBinding, type EvidenceBatch, type EvidenceRecord } from "./evidence-types.js";
|
|
2
|
+
import type { ControlRegister } from "./register-types.js";
|
|
3
|
+
/** Exercise records and operator diagnostics derived from the same inputs. */
|
|
4
|
+
interface ExerciseRecords {
|
|
5
|
+
readonly batch: EvidenceBatch;
|
|
6
|
+
readonly notes: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Match saved exercise records to records rebuilt from authorized statements.
|
|
10
|
+
* @param stored - Evidence records already on disk
|
|
11
|
+
* @param rebuilt - Exercise records authenticated for the current binding
|
|
12
|
+
* @returns The verified ids and whether the stored set differs
|
|
13
|
+
*/
|
|
14
|
+
export declare function compareExerciseRecords(stored: readonly EvidenceRecord[], rebuilt: readonly EvidenceRecord[]): {
|
|
15
|
+
current: Set<string>;
|
|
16
|
+
differs: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Rebuild the complete evidence for each criterion from current signed results.
|
|
20
|
+
* @param root - Real checkout path
|
|
21
|
+
* @param register - Current repository controls
|
|
22
|
+
* @param checks - Current check binding to compare with the signed results
|
|
23
|
+
* @param now - The time against which the results' freshness is checked
|
|
24
|
+
* @returns The artifact batch and any gaps the operator must address
|
|
25
|
+
*/
|
|
26
|
+
export declare function verifiedExerciseRecords(root: string, register: ControlRegister, checks: ChecksBinding, now: Date): Promise<ExerciseRecords>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=exercise-records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exercise-records.d.ts","sourceRoot":"","sources":["../../src/controls/exercise-records.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAY3D,8EAA8E;AAC9E,UAAU,eAAe;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,cAAc,EAAE,EACjC,OAAO,EAAE,SAAS,cAAc,EAAE;;;EAenC;AA+DD;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,IAAI,GACR,OAAO,CAAC,eAAe,CAAC,CAoC1B"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn verified typed exercises into the evidence the verdict can use.
|
|
3
|
+
* @module controls/exercise-records
|
|
4
|
+
*/
|
|
5
|
+
import { canonicalText } from "./canonical-json.js";
|
|
6
|
+
import { ARTIFACT_EXERCISED, DEFAULT_FRESHNESS_SECONDS, exerciseRecordId, } from "./evidence-types.js";
|
|
7
|
+
import { readExerciseObservations, } from "./exercise-observations.js";
|
|
8
|
+
import { isRequiredBeyondTheAuthor } from "./register-tier-rule.js";
|
|
9
|
+
/** What a record says without copying raw producer logs or credentials. */
|
|
10
|
+
const DESCRIPTION = {
|
|
11
|
+
"AC5.5": "The authoritative gate refused the known violation.",
|
|
12
|
+
"AC6.4": "The expected connection verified an identity on the declared execution surface.",
|
|
13
|
+
"AC7.2": "The rollback restored the preceding generation and verified recovery.",
|
|
14
|
+
"AC8.9": "The shadow comparison and adversarial qualification both passed.",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Match saved exercise records to records rebuilt from authorized statements.
|
|
18
|
+
* @param stored - Evidence records already on disk
|
|
19
|
+
* @param rebuilt - Exercise records authenticated for the current binding
|
|
20
|
+
* @returns The verified ids and whether the stored set differs
|
|
21
|
+
*/
|
|
22
|
+
export function compareExerciseRecords(stored, rebuilt) {
|
|
23
|
+
const saved = stored.filter(record => record.exercise !== undefined);
|
|
24
|
+
const exact = new Map(saved.map(record => [record.id, canonicalText(record)]));
|
|
25
|
+
const current = new Set(rebuilt.flatMap(record => exact.get(record.id) === canonicalText(record) ? [record.id] : []));
|
|
26
|
+
return {
|
|
27
|
+
current,
|
|
28
|
+
differs: current.size !== saved.length || current.size !== rebuilt.length,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check that an exercise plan covers each authoritative gate in its own scope.
|
|
33
|
+
* @param register - The current controls
|
|
34
|
+
* @param observations - The declared target observations from this repository
|
|
35
|
+
* @returns The gate entries the plan omitted
|
|
36
|
+
*/
|
|
37
|
+
function uncoveredGates(register, observations) {
|
|
38
|
+
const gates = observations.flatMap(({ target }) => target.criterion === "AC5.5" ? [target] : []);
|
|
39
|
+
if (gates.length === 0)
|
|
40
|
+
return [];
|
|
41
|
+
return register.entries
|
|
42
|
+
.filter(entry => entry.tier === "authoritative" &&
|
|
43
|
+
isRequiredBeyondTheAuthor(entry.enforcement_points) &&
|
|
44
|
+
!gates.some(target => target.gate === entry.gate && target.scope === entry.scope))
|
|
45
|
+
.map(entry => entry.id);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Record one exercised artifact with its independently verifiable identity.
|
|
49
|
+
* @param observation - A result that was just verified
|
|
50
|
+
* @param checksDigest - Current definitions of the checks
|
|
51
|
+
* @returns A record when the measurement stood, or no record
|
|
52
|
+
*/
|
|
53
|
+
function evidenceOf(observation, checksDigest) {
|
|
54
|
+
const { result, target } = observation;
|
|
55
|
+
if (result === null)
|
|
56
|
+
return null;
|
|
57
|
+
return {
|
|
58
|
+
id: exerciseRecordId(target.criterion, target.id),
|
|
59
|
+
criterion: target.criterion,
|
|
60
|
+
entry_id: null,
|
|
61
|
+
scope: target.scope,
|
|
62
|
+
rung: "exercised",
|
|
63
|
+
exercise: { target: target.id, statement_sha256: result.statementDigest },
|
|
64
|
+
moment: null,
|
|
65
|
+
result: "held",
|
|
66
|
+
reason: ARTIFACT_EXERCISED,
|
|
67
|
+
detail: DESCRIPTION[target.criterion],
|
|
68
|
+
commit: null,
|
|
69
|
+
checks_digest: checksDigest,
|
|
70
|
+
command: null,
|
|
71
|
+
exit_status: null,
|
|
72
|
+
started_at: result.completedAt,
|
|
73
|
+
completed_at: result.completedAt,
|
|
74
|
+
freshness_seconds: DEFAULT_FRESHNESS_SECONDS,
|
|
75
|
+
output_excerpt: "",
|
|
76
|
+
output_truncated: false,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Rebuild the complete evidence for each criterion from current signed results.
|
|
81
|
+
* @param root - Real checkout path
|
|
82
|
+
* @param register - Current repository controls
|
|
83
|
+
* @param checks - Current check binding to compare with the signed results
|
|
84
|
+
* @param now - The time against which the results' freshness is checked
|
|
85
|
+
* @returns The artifact batch and any gaps the operator must address
|
|
86
|
+
*/
|
|
87
|
+
export async function verifiedExerciseRecords(root, register, checks, now) {
|
|
88
|
+
const { targets, problems } = await readExerciseObservations({
|
|
89
|
+
root,
|
|
90
|
+
register,
|
|
91
|
+
checks,
|
|
92
|
+
now,
|
|
93
|
+
});
|
|
94
|
+
const missingGates = uncoveredGates(register, targets);
|
|
95
|
+
const incomplete = new Set(targets.flatMap(({ target, problem }) => problem === null ? [] : [target.criterion]));
|
|
96
|
+
const exercises = targets.flatMap(row => {
|
|
97
|
+
const { criterion } = row.target;
|
|
98
|
+
if (incomplete.has(criterion) ||
|
|
99
|
+
(criterion === "AC5.5" && missingGates.length > 0))
|
|
100
|
+
return [];
|
|
101
|
+
const record = evidenceOf(row, checks.digest);
|
|
102
|
+
return record === null ? [] : [record];
|
|
103
|
+
});
|
|
104
|
+
const notes = [
|
|
105
|
+
...problems,
|
|
106
|
+
...missingGates.map(entry => `AC5.5 is missing an exercise target for the authoritative gate ${entry}.`),
|
|
107
|
+
...targets.flatMap(({ target, problem }) => problem === null
|
|
108
|
+
? []
|
|
109
|
+
: [`${target.criterion} exercise ${target.id}: ${problem}`]),
|
|
110
|
+
];
|
|
111
|
+
return { batch: { entries: [], moments: [], results: [], exercises }, notes };
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=exercise-records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exercise-records.js","sourceRoot":"","sources":["../../src/controls/exercise-records.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,GAIjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,2EAA2E;AAC3E,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,qDAAqD;IAC9D,OAAO,EACL,iFAAiF;IACnF,OAAO,EACL,uEAAuE;IACzE,OAAO,EAAE,kEAAkE;CACnE,CAAC;AAQX;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAiC,EACjC,OAAkC;IAElC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;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CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ExerciseTarget } from "./exercise-declaration.js";
|
|
2
|
+
import type { ControlRegister } from "./register-types.js";
|
|
3
|
+
/** The inputs attest can verify against the same signed statement later. */
|
|
4
|
+
export interface ExerciseBinding {
|
|
5
|
+
readonly repository: string;
|
|
6
|
+
readonly environment: string;
|
|
7
|
+
readonly checksDigest: string;
|
|
8
|
+
readonly now: Date;
|
|
9
|
+
readonly register: ControlRegister;
|
|
10
|
+
}
|
|
11
|
+
/** What a valid result establishes without including any raw command log. */
|
|
12
|
+
export interface AcceptedExercise {
|
|
13
|
+
readonly completedAt: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bind an authenticated result to the exact target, environment, and current checks.
|
|
17
|
+
* @param target - The applicable criterion and declared surface
|
|
18
|
+
* @param result - A statement whose signer has already been checked
|
|
19
|
+
* @param binding - The current evidence context
|
|
20
|
+
* @returns The result's durable identity and completion time, or a fixed refusal
|
|
21
|
+
*/
|
|
22
|
+
export declare function acceptExercise(target: ExerciseTarget, result: Readonly<Record<string, unknown>>, binding: ExerciseBinding): AcceptedExercise | string;
|
|
23
|
+
//# sourceMappingURL=exercise-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exercise-result.d.ts","sourceRoot":"","sources":["../../src/controls/exercise-result.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhF,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,qBAAqB,CAAC;AAE7B,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;CACpC;AAED,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAoMD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,OAAO,EAAE,eAAe,GACvB,gBAAgB,GAAG,MAAM,CA+B3B"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate the producer's independently reviewed result for one exercise.
|
|
3
|
+
* @module controls/exercise-result
|
|
4
|
+
*/
|
|
5
|
+
import { isJsonObject } from "../sync/json-path.js";
|
|
6
|
+
import { isCanonicalUtc, isEvidenceFresh } from "./evidence.js";
|
|
7
|
+
import { isSha256 } from "./evidence-binding.js";
|
|
8
|
+
import { DEFAULT_FRESHNESS_SECONDS } from "./evidence-types.js";
|
|
9
|
+
import { isExerciseName } from "./exercise-declaration.js";
|
|
10
|
+
import { declaredFailureText } from "./proof-plan.js";
|
|
11
|
+
import { isRequiredBeyondTheAuthor } from "./register-tier-rule.js";
|
|
12
|
+
/** A versioned source locator names a file at an exact Git object. */
|
|
13
|
+
const IMMUTABLE_SOURCE = /^git:[0-9a-f]{40}(?:[0-9a-f]{24})?:[^\r\n]{1,160}$/u;
|
|
14
|
+
/** A verified principal can be a service name, email address, or provider role id. */
|
|
15
|
+
const PRINCIPAL = /^[a-zA-Z0-9][a-zA-Z0-9._@:/-]{0,159}$/u;
|
|
16
|
+
/**
|
|
17
|
+
* Check the signed artifact's hash or immutable source locator.
|
|
18
|
+
* @param artifact - The claimed result's immutable identity
|
|
19
|
+
* @returns Whether it identifies immutable evidence
|
|
20
|
+
*/
|
|
21
|
+
function isImmutableArtifact(artifact) {
|
|
22
|
+
return (isJsonObject(artifact) &&
|
|
23
|
+
Object.keys(artifact).length === 1 &&
|
|
24
|
+
(isSha256(artifact.sha256) ||
|
|
25
|
+
(typeof artifact.locator === "string" &&
|
|
26
|
+
IMMUTABLE_SOURCE.test(artifact.locator))));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The control gate exercise must reach the real declaration and named scope.
|
|
30
|
+
* @param target - The declared gate and moment to exercise
|
|
31
|
+
* @param register - The repository's current control register
|
|
32
|
+
* @returns Its authoritative entry for that scope and moment, if any
|
|
33
|
+
*/
|
|
34
|
+
function authoritativeGate(target, register) {
|
|
35
|
+
return register.entries.find(entry => entry.gate === target.gate &&
|
|
36
|
+
entry.scope === target.scope &&
|
|
37
|
+
entry.tier === "authoritative" &&
|
|
38
|
+
isRequiredBeyondTheAuthor(entry.enforcement_points.filter(point => point.moment === target.moment)));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Validate the gate runner's refusal and the clean result when the gate declares one.
|
|
42
|
+
* @param target - Gate identity and the expected moment
|
|
43
|
+
* @param outcome - Signed observation from the authoritative gate runner
|
|
44
|
+
* @param register - Current declaration-derived register
|
|
45
|
+
* @returns Whether the observed results fit the declared failure
|
|
46
|
+
*/
|
|
47
|
+
function gateExercise(target, outcome, register) {
|
|
48
|
+
const entry = authoritativeGate(target, register);
|
|
49
|
+
if (entry === undefined ||
|
|
50
|
+
outcome.gate !== target.gate ||
|
|
51
|
+
outcome.moment !== target.moment)
|
|
52
|
+
return false;
|
|
53
|
+
const { violation_exit, violation_output, clean_exit } = outcome;
|
|
54
|
+
const declared = declaredFailureText(entry);
|
|
55
|
+
const shape = declared.length === 0 ? [`required gate FAILED: ${entry.gate}`] : declared;
|
|
56
|
+
if (typeof violation_exit !== "number" ||
|
|
57
|
+
!Number.isInteger(violation_exit) ||
|
|
58
|
+
violation_exit <= 0 ||
|
|
59
|
+
violation_exit > 255 ||
|
|
60
|
+
typeof violation_output !== "string" ||
|
|
61
|
+
violation_output.length > 16_384 ||
|
|
62
|
+
!shape.some(line => violation_output.includes(line)))
|
|
63
|
+
return false;
|
|
64
|
+
const paired = entry.proof.clean !== null || entry.proof.violation !== null;
|
|
65
|
+
return paired || clean_exit !== undefined
|
|
66
|
+
? Object.keys(outcome).length === 5 && clean_exit === 0
|
|
67
|
+
: Object.keys(outcome).length === 4;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Verify the declared connection and execution surface with an identified principal.
|
|
71
|
+
* @param target - The expected connection and surface
|
|
72
|
+
* @param outcome - Signed identity check result
|
|
73
|
+
* @returns Whether the result proves identity on that exact surface
|
|
74
|
+
*/
|
|
75
|
+
function credentialExercise(target, outcome) {
|
|
76
|
+
return (Object.keys(outcome).length === 4 &&
|
|
77
|
+
outcome.connection === target.connection &&
|
|
78
|
+
outcome.surface === target.surface &&
|
|
79
|
+
outcome.identity_verified === true &&
|
|
80
|
+
typeof outcome.principal === "string" &&
|
|
81
|
+
PRINCIPAL.test(outcome.principal));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Confirm that the documented incident exercise reached the restored generation.
|
|
85
|
+
* @param target - The release track in the plan
|
|
86
|
+
* @param outcome - Signed incident and rollback result
|
|
87
|
+
* @param completed - When the full exercise finished
|
|
88
|
+
* @returns Whether the result contains an ordered, verified recovery
|
|
89
|
+
*/
|
|
90
|
+
function rollbackExercise(target, outcome, completed) {
|
|
91
|
+
const { detected_at, rolled_back_at, verified_at } = outcome;
|
|
92
|
+
return (Object.keys(outcome).length === 11 &&
|
|
93
|
+
outcome.release_track === target.release_track &&
|
|
94
|
+
[
|
|
95
|
+
outcome.incident,
|
|
96
|
+
outcome.actor,
|
|
97
|
+
outcome.finding,
|
|
98
|
+
outcome.previous_generation,
|
|
99
|
+
outcome.rolled_back_from,
|
|
100
|
+
].every(isExerciseName) &&
|
|
101
|
+
outcome.restored_generation === outcome.previous_generation &&
|
|
102
|
+
outcome.rolled_back_from !== outcome.previous_generation &&
|
|
103
|
+
outcome.recovery_verified === true &&
|
|
104
|
+
isCanonicalUtc(detected_at) &&
|
|
105
|
+
isCanonicalUtc(rolled_back_at) &&
|
|
106
|
+
isCanonicalUtc(verified_at) &&
|
|
107
|
+
detected_at <= rolled_back_at &&
|
|
108
|
+
rolled_back_at <= verified_at &&
|
|
109
|
+
verified_at <= completed);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Confirm independent shadow comparisons and adversarial staff qualification.
|
|
113
|
+
* @param target - The declared role and minimum shadow period
|
|
114
|
+
* @param outcome - Signed qualification result
|
|
115
|
+
* @param completed - When the full exercise finished
|
|
116
|
+
* @returns Whether the required period and both checks are present
|
|
117
|
+
*/
|
|
118
|
+
function staffExercise(target, outcome, completed) {
|
|
119
|
+
const { shadow_started_at, shadow_completed_at, comparisons } = outcome;
|
|
120
|
+
return (Object.keys(outcome).length === 9 &&
|
|
121
|
+
outcome.role === target.role &&
|
|
122
|
+
isExerciseName(outcome.actor) &&
|
|
123
|
+
isSha256(outcome.roster_sha256) &&
|
|
124
|
+
isCanonicalUtc(shadow_started_at) &&
|
|
125
|
+
isCanonicalUtc(shadow_completed_at) &&
|
|
126
|
+
shadow_completed_at <= completed &&
|
|
127
|
+
Date.parse(shadow_completed_at) - Date.parse(shadow_started_at) >=
|
|
128
|
+
target.minimum_shadow_seconds * 1000 &&
|
|
129
|
+
typeof comparisons === "number" &&
|
|
130
|
+
Number.isSafeInteger(comparisons) &&
|
|
131
|
+
comparisons > 0 &&
|
|
132
|
+
outcome.shadow_agreed === true &&
|
|
133
|
+
outcome.adversarial_passed === true &&
|
|
134
|
+
outcome.qualification === "qualified");
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Apply the exact schema and completion test for the declared criterion.
|
|
138
|
+
* @param target - The typed target from the repository's plan
|
|
139
|
+
* @param outcome - The independently reviewed result fields
|
|
140
|
+
* @param register - Current gate declaration and scope
|
|
141
|
+
* @param completed - The signed completion timestamp
|
|
142
|
+
* @returns Whether the exercise measured what its target requires
|
|
143
|
+
*/
|
|
144
|
+
function acceptedOutcome(target, outcome, register, completed) {
|
|
145
|
+
switch (target.criterion) {
|
|
146
|
+
case "AC5.5":
|
|
147
|
+
return gateExercise(target, outcome, register);
|
|
148
|
+
case "AC6.4":
|
|
149
|
+
return credentialExercise(target, outcome);
|
|
150
|
+
case "AC7.2":
|
|
151
|
+
return rollbackExercise(target, outcome, completed);
|
|
152
|
+
case "AC8.9":
|
|
153
|
+
return staffExercise(target, outcome, completed);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Bind an authenticated result to the exact target, environment, and current checks.
|
|
158
|
+
* @param target - The applicable criterion and declared surface
|
|
159
|
+
* @param result - A statement whose signer has already been checked
|
|
160
|
+
* @param binding - The current evidence context
|
|
161
|
+
* @returns The result's durable identity and completion time, or a fixed refusal
|
|
162
|
+
*/
|
|
163
|
+
export function acceptExercise(target, result, binding) {
|
|
164
|
+
if (Object.keys(result).length !== 12 ||
|
|
165
|
+
result.schema_version !== 1 ||
|
|
166
|
+
result.repository !== binding.repository ||
|
|
167
|
+
result.environment !== binding.environment ||
|
|
168
|
+
result.checks_digest !== binding.checksDigest ||
|
|
169
|
+
result.target_id !== target.id ||
|
|
170
|
+
result.criterion !== target.criterion ||
|
|
171
|
+
result.scope !== target.scope ||
|
|
172
|
+
result.producer !== target.producer ||
|
|
173
|
+
result.adjudicator !== target.adjudicator)
|
|
174
|
+
return "The exercise is bound to a different target, environment, check definition, or authority.";
|
|
175
|
+
const { artifact, completed_at: completed, outcome } = result;
|
|
176
|
+
if (!isImmutableArtifact(artifact) ||
|
|
177
|
+
!isCanonicalUtc(completed) ||
|
|
178
|
+
!isJsonObject(outcome))
|
|
179
|
+
return "The exercise needs an immutable artifact identity, a UTC completion time, and a typed result.";
|
|
180
|
+
if (!isEvidenceFresh({ completed_at: completed, freshness_seconds: DEFAULT_FRESHNESS_SECONDS }, binding.now))
|
|
181
|
+
return "The exercise is outside its evidence lifetime.";
|
|
182
|
+
return acceptedOutcome(target, outcome, binding.register, completed)
|
|
183
|
+
? { completedAt: completed }
|
|
184
|
+
: "The result does not establish the declared exercise.";
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=exercise-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exercise-result.js","sourceRoot":"","sources":["../../src/controls/exercise-result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAuB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAoBpE,sEAAsE;AACtE,MAAM,gBAAgB,GAAG,qDAAqD,CAAC;AAE/E,sFAAsF;AACtF,MAAM,SAAS,GAAG,wCAAwC,CAAC;AAE3D;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,QAAiB;IAC5C,OAAO,CACL,YAAY,CAAC,QAAQ,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC;QAClC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YACxB,CAAC,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;gBACnC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CACxB,MAAuD,EACvD,QAAyB;IAEzB,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAC1B,KAAK,CAAC,EAAE,CACN,KAAK,CAAC,IAAI,KA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iB,EAAE,yBAAyB,EAAE,EACzE,OAAO,CAAC,GAAG,CACZ;QAED,OAAO,gDAAgD,CAAC;IAC1D,OAAO,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC;QAClE,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE;QAC5B,CAAC,CAAC,sDAAsD,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** What both halves of the check were tied to in the host. */
|
|
2
|
+
export interface HostProofSubject {
|
|
3
|
+
readonly repository: string;
|
|
4
|
+
readonly environment: string;
|
|
5
|
+
readonly work_item: string;
|
|
6
|
+
readonly entry_id: string;
|
|
7
|
+
readonly platform: string;
|
|
8
|
+
readonly executor_path: string;
|
|
9
|
+
readonly checks_digest: string;
|
|
10
|
+
}
|
|
11
|
+
/** The identity retained when a run's output is kept separately. */
|
|
12
|
+
export interface HostProofRunIdentity {
|
|
13
|
+
readonly run_id: string;
|
|
14
|
+
readonly run_url: string;
|
|
15
|
+
readonly commit: string;
|
|
16
|
+
readonly artifact_sha256: string;
|
|
17
|
+
}
|
|
18
|
+
/** One immutable platform run and the end of its check output. */
|
|
19
|
+
interface HostProofRun extends HostProofRunIdentity {
|
|
20
|
+
readonly started_at: string;
|
|
21
|
+
readonly completed_at: string;
|
|
22
|
+
readonly exit_status: number;
|
|
23
|
+
readonly output_excerpt: string;
|
|
24
|
+
}
|
|
25
|
+
/** A signed input stays distinct from the receipt that attest writes. */
|
|
26
|
+
export interface HostProofInput {
|
|
27
|
+
readonly schema_version: 1;
|
|
28
|
+
readonly subject: HostProofSubject;
|
|
29
|
+
readonly producer: string;
|
|
30
|
+
readonly adjudicator: string;
|
|
31
|
+
readonly clean: HostProofRun;
|
|
32
|
+
readonly violation: HostProofRun;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate the target of a paired proof.
|
|
36
|
+
* @param value - The signed subject
|
|
37
|
+
* @returns Whether it names the specific repository, entry and check files
|
|
38
|
+
*/
|
|
39
|
+
export declare function isHostProofSubject(value: unknown): value is HostProofSubject;
|
|
40
|
+
/**
|
|
41
|
+
* Validate the provenance fields shared between an input run and its receipt.
|
|
42
|
+
* @param value - A run record supplied by either authorized role
|
|
43
|
+
* @returns Whether it identifies one hosted run and its artifact
|
|
44
|
+
*/
|
|
45
|
+
export declare function isHostProofRunIdentity(value: unknown): value is HostProofRunIdentity;
|
|
46
|
+
/**
|
|
47
|
+
* Read the two halves and their common binding from an authenticated input.
|
|
48
|
+
* @param value - The body of an authorized signed envelope
|
|
49
|
+
* @returns The well-formed pair, or null when the declaration cannot be used
|
|
50
|
+
*/
|
|
51
|
+
export declare function hostProofInput(value: unknown): HostProofInput | null;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=host-proof-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-input.d.ts","sourceRoot":"","sources":["../../src/controls/host-proof-input.ts"],"names":[],"mappings":"AAQA,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,oEAAoE;AACpE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,kEAAkE;AAClE,UAAU,YAAa,SAAQ,oBAAoB;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;CAClC;AAuDD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAO5E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,oBAAoB,CAS/B;AAwBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAgCpE"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The independent adjudicator's account of two pull-request runs.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { isJsonObject } from "../sync/json-path.js";
|
|
6
|
+
import { isCanonicalUtc } from "./evidence.js";
|
|
7
|
+
import { isSha256 } from "./evidence-binding.js";
|
|
8
|
+
/** Fields describing which declared check the proof ran. */
|
|
9
|
+
const SUBJECT_LABELS = [
|
|
10
|
+
"repository",
|
|
11
|
+
"environment",
|
|
12
|
+
"work_item",
|
|
13
|
+
"entry_id",
|
|
14
|
+
"platform",
|
|
15
|
+
"executor_path",
|
|
16
|
+
];
|
|
17
|
+
/** Git object ids may be SHA-1 or SHA-256, according to the host repository. */
|
|
18
|
+
const OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
|
|
19
|
+
/** Limit prose to the evidence document's role as a short record. */
|
|
20
|
+
const EXCERPT_LIMIT = 16_384;
|
|
21
|
+
/**
|
|
22
|
+
* Tell whether a name or identifier fits on one line.
|
|
23
|
+
* @param value - A name supplied by the adjudicator
|
|
24
|
+
* @returns Whether it can be used as a label
|
|
25
|
+
*/
|
|
26
|
+
function label(value) {
|
|
27
|
+
return (typeof value === "string" &&
|
|
28
|
+
value.length <= 512 &&
|
|
29
|
+
value.trim() === value &&
|
|
30
|
+
value !== "" &&
|
|
31
|
+
!/[\r\n\t]/u.test(value));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A proof refers to a hosted run without including authentication material.
|
|
35
|
+
* @param value - The recorded run locator
|
|
36
|
+
* @returns Whether it is an HTTPS resource with a path and no credentials
|
|
37
|
+
*/
|
|
38
|
+
function runLocator(value) {
|
|
39
|
+
if (!label(value))
|
|
40
|
+
return false;
|
|
41
|
+
try {
|
|
42
|
+
const url = new URL(value);
|
|
43
|
+
return (url.protocol === "https:" &&
|
|
44
|
+
url.pathname !== "/" &&
|
|
45
|
+
url.username === "" &&
|
|
46
|
+
url.password === "" &&
|
|
47
|
+
url.search === "" &&
|
|
48
|
+
url.hash === "");
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Validate the target of a paired proof.
|
|
56
|
+
* @param value - The signed subject
|
|
57
|
+
* @returns Whether it names the specific repository, entry and check files
|
|
58
|
+
*/
|
|
59
|
+
export function isHostProofSubject(value) {
|
|
60
|
+
return (isJsonObject(value) &&
|
|
61
|
+
Object.keys(value).length === SUBJECT_LABELS.length + 1 &&
|
|
62
|
+
SUBJECT_LABELS.every(key => label(value[key])) &&
|
|
63
|
+
isSha256(value.checks_digest));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validate the provenance fields shared between an input run and its receipt.
|
|
67
|
+
* @param value - A run record supplied by either authorized role
|
|
68
|
+
* @returns Whether it identifies one hosted run and its artifact
|
|
69
|
+
*/
|
|
70
|
+
export function isHostProofRunIdentity(value) {
|
|
71
|
+
return (isJsonObject(value) &&
|
|
72
|
+
label(value.run_id) &&
|
|
73
|
+
runLocator(value.run_url) &&
|
|
74
|
+
typeof value.commit === "string" &&
|
|
75
|
+
OBJECT_ID.test(value.commit) &&
|
|
76
|
+
isSha256(value.artifact_sha256));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validate the result of one platform run.
|
|
80
|
+
* @param value - The signed account of the run
|
|
81
|
+
* @returns Whether the run carries all data needed to record what it measured
|
|
82
|
+
*/
|
|
83
|
+
function hostRun(value) {
|
|
84
|
+
return (isJsonObject(value) &&
|
|
85
|
+
Object.keys(value).length === 8 &&
|
|
86
|
+
isCanonicalUtc(value.started_at) &&
|
|
87
|
+
isCanonicalUtc(value.completed_at) &&
|
|
88
|
+
value.started_at <= value.completed_at &&
|
|
89
|
+
typeof value.exit_status === "number" &&
|
|
90
|
+
Number.isInteger(value.exit_status) &&
|
|
91
|
+
value.exit_status >= 0 &&
|
|
92
|
+
value.exit_status <= 255 &&
|
|
93
|
+
typeof value.output_excerpt === "string" &&
|
|
94
|
+
value.output_excerpt.length <= EXCERPT_LIMIT &&
|
|
95
|
+
isHostProofRunIdentity(value));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Read the two halves and their common binding from an authenticated input.
|
|
99
|
+
* @param value - The body of an authorized signed envelope
|
|
100
|
+
* @returns The well-formed pair, or null when the declaration cannot be used
|
|
101
|
+
*/
|
|
102
|
+
export function hostProofInput(value) {
|
|
103
|
+
if (!isJsonObject(value) ||
|
|
104
|
+
Object.keys(value).length !== 6 ||
|
|
105
|
+
value.schema_version !== 1 ||
|
|
106
|
+
!isHostProofSubject(value.subject) ||
|
|
107
|
+
!label(value.producer) ||
|
|
108
|
+
!label(value.adjudicator) ||
|
|
109
|
+
!hostRun(value.clean) ||
|
|
110
|
+
!hostRun(value.violation))
|
|
111
|
+
return null;
|
|
112
|
+
const { subject, producer, adjudicator, clean, violation } = value;
|
|
113
|
+
if (producer === adjudicator ||
|
|
114
|
+
clean.run_id === violation.run_id ||
|
|
115
|
+
clean.run_url === violation.run_url ||
|
|
116
|
+
clean.commit === violation.commit ||
|
|
117
|
+
clean.exit_status !== 0 ||
|
|
118
|
+
violation.exit_status === 0)
|
|
119
|
+
return null;
|
|
120
|
+
return {
|
|
121
|
+
schema_version: 1,
|
|
122
|
+
subject,
|
|
123
|
+
producer,
|
|
124
|
+
adjudicator,
|
|
125
|
+
clean,
|
|
126
|
+
violation,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=host-proof-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-proof-input.js","sourceRoot":"","sources":["../../src/controls/host-proof-input.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAuCjD,4DAA4D;AAC5D,MAAM,cAAc,GAAG;IACrB,YAAY;IACZ,aAAa;IACb,WAAW;IACX,UAAU;IACV,UAAU;IACV,eAAe;CACP,CAAC;AAEX,gFAAgF;AAChF,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAErD,qEAAqE;AACrE,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B;;;;GAIG;AACH,SAAS,KAAK,CAAC,KAAc;IAC3B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,MAAM,IAAI,GAAG;QACnB,KAAK,CAAC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