fix(artifacts): authenticate file subjects across provider and view boundaries
Narrow WASM and EVM execution ports to file subjects and preserve supplied subject types at the shared execution factory. Authenticate format with path and digest before recording or projecting Evidence, using the existing WASM identity owner in both consumers. Validation: focused WASM/EVM service and public MCP workflows passed, including malformed provider subjects and self-contained retained Evidence with contradictory format. Global typecheck/lint and documentation checks passed. Real WABT/Evmole execution and the full suite were not run.
This commit is contained in:
@@ -76,6 +76,7 @@ export const projectEvmInterfaceView = (
|
||||
const report = parsed.data;
|
||||
if (
|
||||
parent.subject == null ||
|
||||
parent.subject.format !== "file" ||
|
||||
parent.subject.local_path !== report.artifact.path ||
|
||||
parent.subject.digest.sha256 !== report.artifact.sha256
|
||||
)
|
||||
|
||||
@@ -103,6 +103,7 @@ export const projectWasmArtifactView = (
|
||||
: {
|
||||
path: parent.subject.local_path,
|
||||
sha256: parent.subject.digest.sha256,
|
||||
format: parent.subject.format,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
import { createHash } from "node:crypto";
|
||||
import type { EvidenceSubjectTarget } from "../evidence.js";
|
||||
|
||||
import { localPathStringSchema } from "../localPath.js";
|
||||
|
||||
@@ -137,11 +138,20 @@ export type InspectWasmArtifactInput = z.infer<
|
||||
>;
|
||||
export type WasmArtifact = z.infer<typeof wasmArtifactSchema>;
|
||||
|
||||
/** A WASM observation must identify the exact selected path and byte digest. */
|
||||
/** A WASM observation must identify the selected file path and byte digest. */
|
||||
export type WasmArtifactSubject = Pick<
|
||||
EvidenceSubjectTarget,
|
||||
"path" | "sha256" | "format"
|
||||
>;
|
||||
type WasmArtifactFileSubject = WasmArtifactSubject & {
|
||||
readonly format: "file";
|
||||
};
|
||||
|
||||
export const wasmArtifactMatchesSubject = (
|
||||
artifact: WasmArtifact["artifact"],
|
||||
subject: Pick<WasmArtifact["artifact"], "path" | "sha256"> | null | undefined,
|
||||
): subject is Pick<WasmArtifact["artifact"], "path" | "sha256"> =>
|
||||
subject: WasmArtifactSubject | null | undefined,
|
||||
): subject is WasmArtifactFileSubject =>
|
||||
subject != null &&
|
||||
subject.path === artifact.path &&
|
||||
subject.sha256 === artifact.sha256;
|
||||
subject.sha256 === artifact.sha256 &&
|
||||
subject.format === "file";
|
||||
|
||||
Reference in New Issue
Block a user