fix(apple): distinguish cache loadability and propagate search uncertainty
This commit is contained in:
@@ -62,6 +62,40 @@ it("inspects a standalone keyed archive through MCP with original object identit
|
||||
arguments: { path: "other.plist" },
|
||||
});
|
||||
expect(rejected.isError).toBe(true);
|
||||
expect(rejected.structuredContent).toMatchObject({
|
||||
error: {
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_value",
|
||||
expected: "archive.plist",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
const missingRoot = await client.callTool({
|
||||
name: "inspect_keyed_archive",
|
||||
arguments: { root: "missing" },
|
||||
});
|
||||
expect(missingRoot.isError).toBe(true);
|
||||
expect(missingRoot.structuredContent).toMatchObject({
|
||||
error: {
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: [
|
||||
{
|
||||
path: ["root"],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining("missing"),
|
||||
expected: Object.keys(graph.roots),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
await client.close();
|
||||
await server.close();
|
||||
|
||||
@@ -106,6 +106,42 @@ describe("bundle comparison MCP integration", () => {
|
||||
await connected.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("explains that a single Evidence record is not a bundle", async () => {
|
||||
const root = await createTestTempDirectory("rea-bundle-record-");
|
||||
roots.push(root);
|
||||
const record = sourceEvidence("single");
|
||||
const recordPath = join(root, "record.json");
|
||||
const bundlePath = join(root, "bundle.json");
|
||||
await Promise.all([
|
||||
writeFile(recordPath, JSON.stringify(record)),
|
||||
writeFile(
|
||||
bundlePath,
|
||||
serializeEvidenceBundle(createEvidenceBundle([record])),
|
||||
),
|
||||
]);
|
||||
const connected = await connect();
|
||||
try {
|
||||
const result = await connected.client.callTool({
|
||||
name: "compare_bundles",
|
||||
arguments: {
|
||||
left_bundle_path: recordPath,
|
||||
right_bundle_path: bundlePath,
|
||||
},
|
||||
});
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.structuredContent).toMatchObject({
|
||||
error: {
|
||||
code: "evidence_integrity_mismatch",
|
||||
message: expect.stringContaining(
|
||||
`this JSON is one Evidence record (${record.evidence_id})`,
|
||||
),
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
await connected.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const connect = async () => {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { z } from "zod";
|
||||
import { ArtifactProvider } from "../../../src/artifacts/ArtifactProvider.js";
|
||||
import {
|
||||
FILE_TYPE,
|
||||
buildVersionCommand,
|
||||
LC,
|
||||
dylibCommand,
|
||||
machoImage,
|
||||
@@ -55,6 +56,7 @@ it("traces dylib resolution for an opened app bundle and rejects a changed targe
|
||||
executable,
|
||||
machoImage({
|
||||
commands: [
|
||||
buildVersionCommand(1),
|
||||
rpathCommand("@executable_path/../Frameworks"),
|
||||
dylibCommand(LC.LOAD_DYLIB, "@rpath/libcore.dylib"),
|
||||
],
|
||||
@@ -62,7 +64,10 @@ it("traces dylib resolution for an opened app bundle and rejects a changed targe
|
||||
);
|
||||
await writeFile(
|
||||
join(app, "Contents/Frameworks/libcore.dylib"),
|
||||
machoImage({ fileType: FILE_TYPE.dylib }),
|
||||
machoImage({
|
||||
fileType: FILE_TYPE.dylib,
|
||||
commands: [buildVersionCommand(1)],
|
||||
}),
|
||||
);
|
||||
await withClient(async (client) => {
|
||||
const opened = await client.callTool({
|
||||
@@ -129,12 +134,18 @@ it("traces a standalone Mach-O file whose name ends in .app", async () => {
|
||||
await writeFile(
|
||||
join(directory, "Tool.app"),
|
||||
machoImage({
|
||||
commands: [dylibCommand(LC.LOAD_DYLIB, "@loader_path/libcore.dylib")],
|
||||
commands: [
|
||||
buildVersionCommand(1),
|
||||
dylibCommand(LC.LOAD_DYLIB, "@loader_path/libcore.dylib"),
|
||||
],
|
||||
}),
|
||||
);
|
||||
await writeFile(
|
||||
join(directory, "libcore.dylib"),
|
||||
machoImage({ fileType: FILE_TYPE.dylib }),
|
||||
machoImage({
|
||||
fileType: FILE_TYPE.dylib,
|
||||
commands: [buildVersionCommand(1)],
|
||||
}),
|
||||
);
|
||||
await withClient(async (client) => {
|
||||
const opened = await client.callTool({
|
||||
|
||||
@@ -31,12 +31,15 @@ const providerNames = [
|
||||
"REA deterministic process harness",
|
||||
];
|
||||
|
||||
const captureEvidence = (side: "left" | "right") =>
|
||||
const captureEvidence = (
|
||||
side: "left" | "right",
|
||||
result: Evidence["normalized_result"] = EMPTY_PROCESS_CAPTURE_EXAMPLE,
|
||||
) =>
|
||||
createEvidence(undefined, PROCESS_PROVIDER, {
|
||||
predicateType: "rea.process-capture",
|
||||
operation: "capture_process_scenario",
|
||||
parameters: { side },
|
||||
result: EMPTY_PROCESS_CAPTURE_EXAMPLE,
|
||||
result,
|
||||
confidence: "observed",
|
||||
authority: "controlled-replay",
|
||||
environment: {
|
||||
@@ -335,3 +338,34 @@ it("separately rejects a tampered digest before admission to any consumer or ses
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps withheld ownership unknown through CLI and MCP comparison", async () => {
|
||||
const { client, right } = await connectedComparison();
|
||||
const left = captureEvidence("left", {
|
||||
...EMPTY_PROCESS_CAPTURE_EXAMPLE,
|
||||
cleanup: {
|
||||
...EMPTY_PROCESS_CAPTURE_EXAMPLE.cleanup,
|
||||
unverified_processes: [
|
||||
{ pid: 900, reason: "platform_binary_environment_withheld" },
|
||||
],
|
||||
},
|
||||
residual_unknowns: [
|
||||
{ scope: "process", reason: "Ownership of process 900 was withheld" },
|
||||
],
|
||||
});
|
||||
const response = await client.callTool({
|
||||
name: "compare_process_captures",
|
||||
arguments: { left, right },
|
||||
});
|
||||
expect(response.isError, JSON.stringify(response)).not.toBe(true);
|
||||
const comparison = inlineEvidence(response);
|
||||
expect(comparison.normalized_result).toMatchObject({ status: "unknown" });
|
||||
const root = await createTestTempDirectory("rea-withheld-ownership-");
|
||||
const leftPath = join(root, "left.json");
|
||||
const rightPath = join(root, "right.json");
|
||||
await writeFile(leftPath, JSON.stringify(left));
|
||||
await writeFile(rightPath, JSON.stringify(right));
|
||||
expect(
|
||||
parseEvidence(await compareProcessEvidenceFiles(leftPath, rightPath)),
|
||||
).toEqual(comparison);
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ import { WebNetworkCaptureService } from "../../../src/application/WebNetworkCap
|
||||
import { toolContract } from "../../../src/contracts/toolContracts.js";
|
||||
import { parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import { ok } from "../../../src/domain/result.js";
|
||||
import { webNetworkCaptureSchema } from "../../../src/domain/webNetworkCapture.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
|
||||
@@ -17,7 +18,7 @@ it("publishes valid SDK schemas and retains historical inline Evidence with the
|
||||
format: "har",
|
||||
decoder: { id: "test-capture-port", name: "test port", version: "1" },
|
||||
container: {
|
||||
reported: { creator: "fixture" },
|
||||
reported: { creator: "fixture", ["__proto__"]: { preserved: 7 } },
|
||||
numeric_literals: [],
|
||||
redactions: [],
|
||||
records_pointer: "/log/entries",
|
||||
@@ -72,6 +73,15 @@ it("publishes valid SDK schemas and retains historical inline Evidence with the
|
||||
);
|
||||
const evidence = parseEvidence(parsed.evidence);
|
||||
expect(parsed.result).toEqual(evidence.normalized_result);
|
||||
const capture = webNetworkCaptureSchema.parse(parsed.result);
|
||||
expect(capture.container.reported).toEqual({
|
||||
creator: "fixture",
|
||||
["__proto__"]: { preserved: 7 },
|
||||
});
|
||||
expect(Object.getPrototypeOf(capture.container.reported)).toBe(
|
||||
Object.prototype,
|
||||
);
|
||||
expect(Reflect.get(Object.prototype, "preserved")).toBeUndefined();
|
||||
expect(session.evidenceById(evidence.evidence_id)).toEqual(evidence);
|
||||
const invalid = await client.callTool({
|
||||
name: "inspect_web_network_capture",
|
||||
|
||||
Reference in New Issue
Block a user