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:
@@ -39,6 +39,8 @@ import {
|
||||
} from "../../fixtures/analysisView.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { BINARY_LAYOUT_TEST_PROVIDER } from "../../fixtures/binaryDiagnostics/layout.js";
|
||||
import { wasmArtifactFixture } from "../../fixtures/wasm/artifact.js";
|
||||
import { evmInterfaceFixture } from "../../fixtures/evm/interface.js";
|
||||
|
||||
const connect = async (
|
||||
binaryLayout?: BinaryLayoutService,
|
||||
@@ -310,6 +312,65 @@ it("reports a tampered inline Evidence ID at its full MCP source path", async ()
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects self-contained WASM and EVM Evidence views when the subject format differs", async () => {
|
||||
const { client } = await connect();
|
||||
const wasm = wasmArtifactFixture();
|
||||
const evm = evmInterfaceFixture();
|
||||
const cases = [
|
||||
{
|
||||
evidence: createEvidence(
|
||||
{
|
||||
path: wasm.artifact.path,
|
||||
format: "elf",
|
||||
sha256: wasm.artifact.sha256,
|
||||
},
|
||||
{ id: "fixture-wabt", name: "WABT", version: "1" },
|
||||
{
|
||||
operation: "inspect_wasm_artifact",
|
||||
parameters: { path: wasm.artifact.path },
|
||||
result: wasm,
|
||||
},
|
||||
),
|
||||
},
|
||||
{
|
||||
evidence: createEvidence(
|
||||
{
|
||||
path: evm.artifact.path,
|
||||
format: "elf",
|
||||
sha256: evm.artifact.sha256,
|
||||
},
|
||||
{ id: "fixture-evm", name: "EVMole", version: "1" },
|
||||
{
|
||||
operation: "inspect_evm_interface",
|
||||
parameters: { path: evm.artifact.path, encoding: "hex" },
|
||||
result: evm,
|
||||
},
|
||||
),
|
||||
},
|
||||
] as const;
|
||||
|
||||
for (const { evidence } of cases) {
|
||||
const response = await client.callTool({
|
||||
name: "inspect_analysis_view",
|
||||
arguments: {
|
||||
source: { kind: "inline", evidence },
|
||||
view: { kind: "summary" },
|
||||
},
|
||||
});
|
||||
expect(parseMcpToolError(response).error).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: [
|
||||
expect.objectContaining({
|
||||
path: ["source", "subject"],
|
||||
reason: "invalid_value",
|
||||
}),
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it("admits portable captures before SDK Evidence parsing and preserves capture caveats", async () => {
|
||||
const { client } = await connect();
|
||||
const dense = analysisViewCaptureEvidence(analysisViewObjectDenseCapture());
|
||||
|
||||
@@ -107,6 +107,30 @@ it("advertises exact valid schemas and records inline EVM interface evidence wit
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects an EVM provider response with a non-file subject before recording Evidence", async () => {
|
||||
const value = evmInterfaceFixture();
|
||||
const execution = evmInterfaceExecution(value);
|
||||
const malformed = {
|
||||
...execution,
|
||||
subject: { ...execution.subject, format: "elf" },
|
||||
} as unknown as typeof execution;
|
||||
const harness = await createApplicationMcpHarness({
|
||||
serverOptions: {
|
||||
evmInterface: new EvmInterfaceService({
|
||||
inspect: () => Promise.resolve(ok(malformed)),
|
||||
}),
|
||||
},
|
||||
});
|
||||
onTestFinished(harness.close);
|
||||
const before = harness.session.exportEvidenceBundle().records.length;
|
||||
const response = await harness.client.callTool({
|
||||
name: "inspect_evm_interface",
|
||||
arguments: { path: value.artifact.path, encoding: "hex" },
|
||||
});
|
||||
expect(parseMcpToolError(response).error.code).toBe("unreadable_output");
|
||||
expect(harness.session.exportEvidenceBundle().records).toHaveLength(before);
|
||||
});
|
||||
|
||||
it.each(["unavailable", "incompatible-output"])(
|
||||
"preserves a healthy WASM peer and explicit EVM failure: %s",
|
||||
async (scenario) => {
|
||||
|
||||
@@ -213,6 +213,31 @@ it("advertises exact valid schemas and records inline WASM interface evidence wi
|
||||
expect(close).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects a WASM provider response with a non-file subject before recording Evidence", async () => {
|
||||
const value = wasmArtifactFixture();
|
||||
const execution = wasmArtifactExecution(value);
|
||||
const malformed = {
|
||||
...execution,
|
||||
subject: { ...execution.subject, format: "elf" },
|
||||
} as unknown as typeof execution;
|
||||
const harness = await createApplicationMcpHarness({
|
||||
serverOptions: {
|
||||
wasmArtifact: new WasmArtifactService({
|
||||
close: () => Promise.resolve(),
|
||||
inspect: () => Promise.resolve(ok(malformed)),
|
||||
}),
|
||||
},
|
||||
});
|
||||
onTestFinished(harness.close);
|
||||
const before = harness.session.exportEvidenceBundle().records.length;
|
||||
const response = await harness.client.callTool({
|
||||
name: "inspect_wasm_artifact",
|
||||
arguments: { path: value.artifact.path },
|
||||
});
|
||||
expect(parseMcpToolError(response).error.code).toBe("unreadable_output");
|
||||
expect(harness.session.exportEvidenceBundle().records).toHaveLength(before);
|
||||
});
|
||||
|
||||
it("reads an oversized completed WASM result through its reported retained reference", async () => {
|
||||
const text = "(module)\n" + ";;😀\n" + " ".repeat(6 * 1024 * 1024);
|
||||
const value = {
|
||||
|
||||
Vendored
+6
-2
@@ -1,5 +1,6 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { createAnalysisExecution } from "../../../src/application/AnalysisProvider.js";
|
||||
import type { EvmInterfaceExecution } from "../../../src/application/evm/EvmInterfacePort.js";
|
||||
import type { EvmInterface } from "../../../src/domain/evm/evmInterface.js";
|
||||
|
||||
/** Source-owned transport seam, independent of real engine verification. */
|
||||
@@ -27,8 +28,10 @@ export const evmInterfaceFixture = (
|
||||
});
|
||||
|
||||
/** Bind a fixture to its explicit producing seam and carrier identity. */
|
||||
export const evmInterfaceExecution = (value = evmInterfaceFixture()) =>
|
||||
createAnalysisExecution(
|
||||
export const evmInterfaceExecution = (
|
||||
value = evmInterfaceFixture(),
|
||||
): EvmInterfaceExecution => {
|
||||
return createAnalysisExecution(
|
||||
value,
|
||||
{ id: "fixture-evm", name: "Source-owned EVM seam", version: "1" },
|
||||
{
|
||||
@@ -42,3 +45,4 @@ export const evmInterfaceExecution = (value = evmInterfaceFixture()) =>
|
||||
locations: [{ kind: "artifact-path", path: value.artifact.path }],
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
Vendored
+6
-2
@@ -1,5 +1,6 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { createAnalysisExecution } from "../../../src/application/AnalysisProvider.js";
|
||||
import type { WasmArtifactExecution } from "../../../src/application/wasm/WasmArtifactPort.js";
|
||||
import type { WasmArtifact } from "../../../src/domain/wasm/wasmArtifact.js";
|
||||
/** Source-owned transport seam; upstream binaries are verified in a separate lane. */
|
||||
export const wasmArtifactFixture = (
|
||||
@@ -42,8 +43,10 @@ export const wasmArtifactFixture = (
|
||||
network_fetch: "not-performed" as const,
|
||||
limitations: ["Source-owned transport seam."],
|
||||
});
|
||||
export const wasmArtifactExecution = (value = wasmArtifactFixture()) =>
|
||||
createAnalysisExecution(
|
||||
export const wasmArtifactExecution = (
|
||||
value = wasmArtifactFixture(),
|
||||
): WasmArtifactExecution => {
|
||||
return createAnalysisExecution(
|
||||
value,
|
||||
{ id: "fixture-wabt", name: "Source-owned WABT seam", version: "1" },
|
||||
{
|
||||
@@ -55,3 +58,4 @@ export const wasmArtifactExecution = (value = wasmArtifactFixture()) =>
|
||||
limitations: value.limitations,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user