refactor(tools): return complete analysis results inline
This commit is contained in:
@@ -131,9 +131,7 @@ describe("application workflow CLI Evidence resolution", () => {
|
||||
]),
|
||||
),
|
||||
);
|
||||
const environment = {
|
||||
REA_EVIDENCE_ROOTS_JSON: JSON.stringify([root]),
|
||||
};
|
||||
const environment = {};
|
||||
|
||||
const traced = await runCli(
|
||||
[
|
||||
@@ -246,23 +244,20 @@ describe("application workflow CLI export Evidence", () => {
|
||||
bundlePath,
|
||||
serializeEvidenceBundle(createEvidenceBundle([left.value, right.value])),
|
||||
);
|
||||
const compared = await runCli(
|
||||
[
|
||||
"compare-javascript-export-shapes",
|
||||
JSON.stringify({
|
||||
left: left.value.evidence_id,
|
||||
right: right.value.evidence_id,
|
||||
left_module_path: "parser.mjs",
|
||||
left_export_name: "default",
|
||||
right_module_path: "parser.mjs",
|
||||
right_export_name: "default",
|
||||
}),
|
||||
"--evidence-bundle",
|
||||
bundlePath,
|
||||
"--json",
|
||||
],
|
||||
{ REA_EVIDENCE_ROOTS_JSON: JSON.stringify([root]) },
|
||||
);
|
||||
const compared = await runCli([
|
||||
"compare-javascript-export-shapes",
|
||||
JSON.stringify({
|
||||
left: left.value.evidence_id,
|
||||
right: right.value.evidence_id,
|
||||
left_module_path: "parser.mjs",
|
||||
left_export_name: "default",
|
||||
right_module_path: "parser.mjs",
|
||||
right_export_name: "default",
|
||||
}),
|
||||
"--evidence-bundle",
|
||||
bundlePath,
|
||||
"--json",
|
||||
]);
|
||||
expect(compared).toMatchObject({
|
||||
operation: "compare_javascript_export_shapes",
|
||||
predicate_type: "rea.javascript-export-shape-comparison",
|
||||
|
||||
@@ -37,25 +37,28 @@ describe("CDP connection", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("returns a typed timeout for an unresponsive CDP command", async () => {
|
||||
it("waits for an unresponsive command until caller cancellation", async () => {
|
||||
const browser = await startFakeCdpBrowser({ hangOnMethod: "Page.enable" });
|
||||
browsers.push(browser);
|
||||
const connection = await CdpConnection.connect(
|
||||
browser.browserWebSocketUrl,
|
||||
"observe_web_session",
|
||||
);
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const pending = connection.send("Page.enable");
|
||||
const controller = new AbortController();
|
||||
const pending = connection.send(
|
||||
"Page.enable",
|
||||
{},
|
||||
undefined,
|
||||
controller.signal,
|
||||
);
|
||||
const assertion = expect(pending).rejects.toMatchObject({
|
||||
_tag: "AnalysisTimeoutError",
|
||||
_tag: "AnalysisCancelledError",
|
||||
operation: "observe_web_session",
|
||||
timeoutMs: 5_000,
|
||||
});
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
controller.abort();
|
||||
await assertion;
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
await connection.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -157,14 +157,12 @@ it("retains active hook lifecycle and IPC evidence without a count ceiling", asy
|
||||
);
|
||||
expect(ipc).toMatchObject({
|
||||
correlation_id: expect.stringMatching(/^capture:\d+:\d+$/u),
|
||||
channel_truncated: true,
|
||||
argument_shapes_truncated: true,
|
||||
direction: "renderer-to-main",
|
||||
sender: "webContents:9",
|
||||
frame: "frame:7",
|
||||
});
|
||||
expect(ipc?.channel).toHaveLength(1_024);
|
||||
expect(ipc?.argument_shapes).toHaveLength(32);
|
||||
expect(ipc?.channel).toBe("x".repeat(2_048));
|
||||
expect(ipc?.argument_shapes).toHaveLength(40);
|
||||
});
|
||||
|
||||
it("preserves fatal process termination after recording uncaught exceptions", async () => {
|
||||
|
||||
@@ -84,7 +84,7 @@ describe("passive V8 Inspector provider", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("captures only bounded metadata with two enable commands", async () => {
|
||||
test("captures complete metadata with two enable commands", async () => {
|
||||
const fixture = await runtimeFixture();
|
||||
const outside = await temporaryFile("secret.js");
|
||||
const fake = await startFakeV8Inspector({
|
||||
@@ -182,6 +182,36 @@ describe("passive V8 Inspector provider", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("complete Inspector script hashes", () => {
|
||||
test("keeps more than one hundred long script hashes distinct", async () => {
|
||||
const fixture = await runtimeFixture();
|
||||
const url = pathToFileURL(fixture.entry).href;
|
||||
const prefix = "h".repeat(512);
|
||||
const scriptHashes = Array.from(
|
||||
{ length: 101 },
|
||||
(_, index) => `${prefix}${String(index)}`,
|
||||
);
|
||||
const fake = await startFakeV8Inspector({
|
||||
targetUrl: url,
|
||||
scriptUrls: scriptHashes.map(() => url),
|
||||
scriptHashes,
|
||||
});
|
||||
try {
|
||||
const result = await new V8InspectorProvider().observe(
|
||||
observeInput(fake.endpoint, fake.targetId, fixture.root, "node"),
|
||||
);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
expect(result.value.scripts.items).toHaveLength(scriptHashes.length);
|
||||
expect(
|
||||
new Set(result.value.scripts.items.map(({ cdp_hash }) => cdp_hash)),
|
||||
).toEqual(new Set(scriptHashes));
|
||||
} finally {
|
||||
await fake.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("undeclared V8 runtime role", () => {
|
||||
test("observes a target without inventing a runtime role", async () => {
|
||||
const fixture = await runtimeFixture();
|
||||
@@ -212,6 +242,32 @@ describe("undeclared V8 runtime role", () => {
|
||||
});
|
||||
|
||||
describe("passive V8 Inspector evidence", () => {
|
||||
test("retains authorized script locations longer than the former byte ceiling", async () => {
|
||||
const fixture = await runtimeFixture();
|
||||
const longUrl = `https://example.test/${"a".repeat(20_000)}`;
|
||||
const fake = await startFakeV8Inspector({
|
||||
targetUrl: longUrl,
|
||||
scriptUrls: [longUrl],
|
||||
});
|
||||
try {
|
||||
const input = {
|
||||
...observeInput(fake.endpoint, fake.targetId, fixture.root, "node"),
|
||||
allowed_origins: ["https://example.test"],
|
||||
};
|
||||
const result = await new V8InspectorProvider().observe(input);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
expect(result.value.scripts.items).toHaveLength(1);
|
||||
expect(result.value.scripts.items[0]?.location).toMatchObject({
|
||||
kind: "url",
|
||||
origin: "https://example.test",
|
||||
sanitized_url: longUrl,
|
||||
});
|
||||
} finally {
|
||||
await fake.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("returns every authorized script beyond the former collection ceiling", async () => {
|
||||
const fixture = await runtimeFixture();
|
||||
const scriptUrls = [
|
||||
|
||||
@@ -27,7 +27,7 @@ it("reads local source maps as part of static artifact analysis", async () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not follow symlinks or exceed the internal text-file safety boundary", async () => {
|
||||
it("does not follow symlinks and analyzes text beyond the former file-size cap", async () => {
|
||||
const root = await fixtureDirectory();
|
||||
const outside = await createTestTempDirectory("rea-javascript-outside-");
|
||||
const outsideFile = join(outside, "secret.js");
|
||||
@@ -36,22 +36,23 @@ it("does not follow symlinks or exceed the internal text-file safety boundary",
|
||||
'fetch("https://outside-secret.invalid/credential");',
|
||||
);
|
||||
await symlink(outsideFile, join(root, "escape.js"));
|
||||
await writeFile(
|
||||
join(root, "oversized.js"),
|
||||
`const oversizedSecret = "${"private-marker-".repeat(600_000)}";`,
|
||||
);
|
||||
const baseline = await reconstructJavaScriptArtifact({ input_path: root });
|
||||
const oversizedSource = `// ${"private-marker-".repeat(600_000)}\nfetch("https://inside.invalid");\n`;
|
||||
await writeFile(join(root, "oversized.js"), oversizedSource);
|
||||
|
||||
const result = await reconstructJavaScriptArtifact({ input_path: root });
|
||||
const encoded = JSON.stringify(result);
|
||||
|
||||
expect(result.statistics.limit_omitted_text_files).toBeGreaterThan(0);
|
||||
expect(result.statistics.text_bytes_read).toBeGreaterThan(8 * 1024 * 1024);
|
||||
expect(result.graph.coverage).toMatchObject({
|
||||
status: "partial",
|
||||
truncated: true,
|
||||
status: "complete",
|
||||
truncated: false,
|
||||
});
|
||||
expect(encoded).not.toContain(outsideFile);
|
||||
expect(encoded).not.toContain("outside-secret.invalid");
|
||||
expect(encoded).not.toContain("private-marker-private-marker");
|
||||
expect(result.statistics.visited_ast_nodes).toBeGreaterThan(
|
||||
baseline.statistics.visited_ast_nodes,
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps malformed JavaScript, package metadata, and source maps as explicit unknowns", async () => {
|
||||
|
||||
@@ -13,7 +13,10 @@ import {
|
||||
import { MANAGED_STATIC_PROVIDER } from "../../../src/application/InvestigationProviders.js";
|
||||
import { createPermissionAuthority } from "../../../src/application/PermissionAuthority.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
import { managedRuntimeCorrelationResultSchema } from "../../../src/domain/managedRuntimeCorrelation.js";
|
||||
import {
|
||||
managedRuntimeCorrelationInputSchema,
|
||||
managedRuntimeCorrelationResultSchema,
|
||||
} from "../../../src/domain/managedRuntimeCorrelation.js";
|
||||
import type { PermissionCeiling } from "../../../src/domain/permissionPolicy.js";
|
||||
import { inspectManagedMembersBytes } from "../../../src/dotnet/ManagedMemberInspector.js";
|
||||
import {
|
||||
@@ -81,6 +84,24 @@ describe("managed runtime correlation planning", () => {
|
||||
const plan = managedRuntimeCorrelationResultSchema.parse(
|
||||
result.value.normalized_result,
|
||||
);
|
||||
expect(
|
||||
managedRuntimeCorrelationInputSchema.safeParse({
|
||||
...inputFor(fixture.evidence, fixture.method),
|
||||
bounds: {
|
||||
timeout_ms: 60_001,
|
||||
max_threads: 257,
|
||||
max_output_bytes: 1_048_577,
|
||||
allow_network: false,
|
||||
allow_ui: false,
|
||||
},
|
||||
}).success,
|
||||
).toBe(true);
|
||||
expect(
|
||||
managedRuntimeCorrelationResultSchema.safeParse({
|
||||
...plan,
|
||||
limitations: Array.from({ length: 1_001 }, () => "x".repeat(4_097)),
|
||||
}).success,
|
||||
).toBe(true);
|
||||
expect(plan).toMatchObject({
|
||||
executed: false,
|
||||
authority_model: {
|
||||
|
||||
@@ -17,6 +17,7 @@ import type {
|
||||
} from "../../../src/application/JavaScriptReplayPlanning.js";
|
||||
import { PermissionAuthority } from "../../../src/application/PermissionAuthority.js";
|
||||
import { createPermissionPolicy } from "../../../src/domain/permissionPolicy.js";
|
||||
import { createRuntimeCharacterizationPlan } from "../../../src/domain/runtimeCharacterization.js";
|
||||
import {
|
||||
nodeCharacterizationPreparationInputSchema,
|
||||
nodeCharacterizationPreparationOutputSchema,
|
||||
@@ -41,6 +42,12 @@ describe("Node runtime characterization", () => {
|
||||
const output = nodeCharacterizationPreparationOutputSchema.parse(
|
||||
prepared.value,
|
||||
);
|
||||
const { plan_sha256: _planSha256, ...planWithoutDigest } = output.plan;
|
||||
const expandedPlan = createRuntimeCharacterizationPlan({
|
||||
...planWithoutDigest,
|
||||
limits: { ...output.plan.limits, max_calls: 10_001 },
|
||||
});
|
||||
expect(expandedPlan.limits.max_calls).toBe(10_001);
|
||||
expect(output).toMatchObject({
|
||||
phase: "preparation",
|
||||
plan: {
|
||||
@@ -92,14 +99,26 @@ describe("Node runtime characterization", () => {
|
||||
expect(await readFile(fixture.path)).toEqual(Buffer.from(fixture.bytes));
|
||||
});
|
||||
|
||||
it("rejects aliases that cannot fit the provider-neutral plan identity", async () => {
|
||||
it("accepts aliases longer than the former identity ceiling", async () => {
|
||||
const input = preparationInput(await createFixture());
|
||||
expect(() =>
|
||||
const alias = "a".repeat(201);
|
||||
expect(
|
||||
nodeCharacterizationPreparationInputSchema.parse({
|
||||
...input,
|
||||
selected_alias: "a".repeat(201),
|
||||
}),
|
||||
).toThrow();
|
||||
selected_alias: alias,
|
||||
replay: {
|
||||
...input.replay,
|
||||
left: {
|
||||
...input.replay.left,
|
||||
entry_alias: alias,
|
||||
modules: input.replay.left.modules.map((module) => ({
|
||||
...module,
|
||||
alias,
|
||||
})),
|
||||
},
|
||||
},
|
||||
}).selected_alias,
|
||||
).toBe(alias);
|
||||
});
|
||||
|
||||
it("maps replay-only alias syntax to a provider-neutral module identity", async () => {
|
||||
|
||||
@@ -22,35 +22,7 @@ describe("runtime identification", () => {
|
||||
it("identifies APK runtime families and exposes missing semantic providers", async () => {
|
||||
const root = await createTestTempDirectory("rea-runtime-");
|
||||
const path = join(root, "Fixture.apk");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add(
|
||||
"AndroidManifest.xml",
|
||||
new Uint8ArrayReader(Uint8Array.from([3, 0, 8, 0, 8, 0, 0, 0])),
|
||||
);
|
||||
await writer.add(
|
||||
"classes.dex",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([...Buffer.from("dex\n035\0"), 0, 0, 0, 0]),
|
||||
),
|
||||
);
|
||||
await writer.add(
|
||||
"assets/Fixture.class",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([0xca, 0xfe, 0xba, 0xbe, 0, 0, 0, 61]),
|
||||
),
|
||||
);
|
||||
await writer.add(
|
||||
"assets/module.wasm",
|
||||
new Uint8ArrayReader(Uint8Array.from([0, 0x61, 0x73, 0x6d, 1, 0, 0, 0])),
|
||||
);
|
||||
await writer.add("assets/main.js", new TextReader("bridge.call();"));
|
||||
await writer.add(
|
||||
"lib/arm64-v8a/libfixture.so",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([0x7f, 0x45, 0x4c, 0x46, 2, 1, 1, 0]),
|
||||
),
|
||||
);
|
||||
await writeFile(path, await writer.close());
|
||||
await writeApkRuntimeFixture(path);
|
||||
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
@@ -101,6 +73,28 @@ describe("runtime identification", () => {
|
||||
}),
|
||||
]),
|
||||
);
|
||||
const widened = runtimeIdentificationResultSchema.parse({
|
||||
...first,
|
||||
root_format: "x".repeat(101),
|
||||
source_evidence_ids: Array.from(
|
||||
{ length: 101 },
|
||||
() => inventory.evidence_id,
|
||||
),
|
||||
limitations: Array.from({ length: 101 }, () => "x".repeat(4_097)),
|
||||
runtimes: first.runtimes.map((runtime) => ({
|
||||
...runtime,
|
||||
...(runtime.provider_id === null
|
||||
? { reason: "x".repeat(1_001) }
|
||||
: { provider_id: `provider-${"x".repeat(200)}` }),
|
||||
observations: runtime.observations.map((observation) => ({
|
||||
...observation,
|
||||
path: "x".repeat(4_097),
|
||||
format: "x".repeat(101),
|
||||
})),
|
||||
})),
|
||||
});
|
||||
expect(widened.limitations).toHaveLength(101);
|
||||
expect(widened.runtimes[0]?.observations[0]?.path).toHaveLength(4_097);
|
||||
const available = first.runtimes.find(
|
||||
({ inspection }) => inspection === "available",
|
||||
);
|
||||
@@ -165,3 +159,33 @@ describe("runtime identification", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const writeApkRuntimeFixture = async (path: string): Promise<void> => {
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add(
|
||||
"AndroidManifest.xml",
|
||||
new Uint8ArrayReader(Uint8Array.from([3, 0, 8, 0, 8, 0, 0, 0])),
|
||||
);
|
||||
await writer.add(
|
||||
"classes.dex",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([...Buffer.from("dex\n035\0"), 0, 0, 0, 0]),
|
||||
),
|
||||
);
|
||||
await writer.add(
|
||||
"assets/Fixture.class",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([0xca, 0xfe, 0xba, 0xbe, 0, 0, 0, 61]),
|
||||
),
|
||||
);
|
||||
await writer.add(
|
||||
"assets/module.wasm",
|
||||
new Uint8ArrayReader(Uint8Array.from([0, 0x61, 0x73, 0x6d, 1, 0, 0, 0])),
|
||||
);
|
||||
await writer.add("assets/main.js", new TextReader("bridge.call();"));
|
||||
await writer.add(
|
||||
"lib/arm64-v8a/libfixture.so",
|
||||
new Uint8ArrayReader(Uint8Array.from([0x7f, 0x45, 0x4c, 0x46, 2, 1, 1, 0])),
|
||||
);
|
||||
await writeFile(path, await writer.close());
|
||||
};
|
||||
|
||||
@@ -272,7 +272,6 @@ const connectBrowser = async (browser: FakeCdpBrowser) => {
|
||||
permissionAuthority: authority.value,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
browserObservationEnabled: true,
|
||||
}),
|
||||
|
||||
@@ -176,7 +176,6 @@ describe("browser scenario MCP tool", () => {
|
||||
permissionAuthority: authority.value,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
browserObservationEnabled: true,
|
||||
browserScenarioEnabled: true,
|
||||
@@ -208,7 +207,6 @@ describe("browser scenario MCP tool", () => {
|
||||
],
|
||||
},
|
||||
capture: { after_each_step: [], at_end: ["url"], events: [] },
|
||||
limits: { max_duration_ms: 60_000 },
|
||||
});
|
||||
|
||||
const captured = await client.callTool({
|
||||
|
||||
@@ -36,7 +36,7 @@ const sourceEvidence = (label: string) =>
|
||||
);
|
||||
|
||||
describe("bundle comparison MCP integration", () => {
|
||||
it("reads two approved bounded bundle files and records a compact result", async () => {
|
||||
it("reads caller-selected bundle files and records a compact result", async () => {
|
||||
const root = await createTestTempDirectory("rea-bundle-mcp-");
|
||||
roots.push(root);
|
||||
const leftPath = join(root, "left.json");
|
||||
@@ -53,7 +53,7 @@ describe("bundle comparison MCP integration", () => {
|
||||
serializeEvidenceBundle(createEvidenceBundle([rightRecord])),
|
||||
),
|
||||
]);
|
||||
const connected = await connect(root);
|
||||
const connected = await connect();
|
||||
try {
|
||||
const result = await connected.client.callTool({
|
||||
name: "compare_bundles",
|
||||
@@ -78,7 +78,7 @@ describe("bundle comparison MCP integration", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects a bundle path outside the approved root", async () => {
|
||||
it("reads a bundle path outside any configured roots", async () => {
|
||||
const root = await createTestTempDirectory("rea-bundle-root-");
|
||||
const outside = await createTestTempDirectory("rea-bundle-outside-");
|
||||
roots.push(root, outside);
|
||||
@@ -89,7 +89,7 @@ describe("bundle comparison MCP integration", () => {
|
||||
writeFile(leftPath, encoded),
|
||||
writeFile(rightPath, encoded),
|
||||
]);
|
||||
const connected = await connect(root);
|
||||
const connected = await connect();
|
||||
try {
|
||||
const result = await connected.client.callTool({
|
||||
name: "compare_bundles",
|
||||
@@ -98,36 +98,9 @@ describe("bundle comparison MCP integration", () => {
|
||||
right_bundle_path: rightPath,
|
||||
},
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
isError: true,
|
||||
structuredContent: { error: { code: "outside_approved_root" } },
|
||||
});
|
||||
} finally {
|
||||
await connected.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects an oversized approved bundle", async () => {
|
||||
const root = await createTestTempDirectory("rea-bundle-size-");
|
||||
roots.push(root);
|
||||
const leftPath = join(root, "left.json");
|
||||
const rightPath = join(root, "right.json");
|
||||
await Promise.all([
|
||||
writeFile(leftPath, " ".repeat(2_000)),
|
||||
writeFile(rightPath, serializeEvidenceBundle(createEvidenceBundle([]))),
|
||||
]);
|
||||
const connected = await connect(root, 1_024);
|
||||
try {
|
||||
const result = await connected.client.callTool({
|
||||
name: "compare_bundles",
|
||||
arguments: {
|
||||
left_bundle_path: leftPath,
|
||||
right_bundle_path: rightPath,
|
||||
},
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
isError: true,
|
||||
structuredContent: { error: { code: "truncated" } },
|
||||
expect(result.isError).not.toBe(true);
|
||||
expect(result.structuredContent).toMatchObject({
|
||||
result: { status: "unchanged" },
|
||||
});
|
||||
} finally {
|
||||
await connected.close();
|
||||
@@ -135,21 +108,13 @@ describe("bundle comparison MCP integration", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const connect = async (root: string, maxBytes = 1024 * 1024) => {
|
||||
const connect = async () => {
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
const server = createServer(session, session, {
|
||||
evidenceFilePolicy: {
|
||||
roots: [root],
|
||||
maxBytes,
|
||||
maxDepth: 68,
|
||||
maxStringLength: 1024 * 1024,
|
||||
maxNodes: 100_000,
|
||||
},
|
||||
});
|
||||
const server = createServer(session, session);
|
||||
const client = new Client({ name: "bundle-comparison-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
|
||||
@@ -71,7 +71,6 @@ it("exposes root-confined Electron discovery and inspection as Evidence", async
|
||||
permissionAuthority: authority.value,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 1,
|
||||
electronObservationEnabled: true,
|
||||
}),
|
||||
@@ -222,7 +221,6 @@ it("exposes active Electron scenarios through the separately granted MCP boundar
|
||||
permissionAuthority: authority.value,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
electronAutomationEnabled: true,
|
||||
}),
|
||||
@@ -297,7 +295,6 @@ it("exposes the target-free static JavaScript application workflow", async () =>
|
||||
permissionAuthority: authority.value,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 1,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
} from "../../../src/domain/jsonValue.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
import type { EvidenceFilePolicy } from "../../../src/domain/evidenceBundle.js";
|
||||
import type { PermissionAuthority } from "../../../src/application/PermissionAuthority.js";
|
||||
|
||||
it("aggregates comparison Evidence and records an approved runtime gap", async () => {
|
||||
@@ -287,25 +286,17 @@ it("cannot omit a session-owned active unknown from reconstruction input", async
|
||||
}
|
||||
});
|
||||
|
||||
const connected = async (
|
||||
evidenceFilePolicy?: EvidenceFilePolicy,
|
||||
investigationInputRoots: readonly string[] = evidenceFilePolicy?.roots ?? [],
|
||||
permissionAuthority?: PermissionAuthority,
|
||||
) => {
|
||||
const connected = async (permissionAuthority?: PermissionAuthority) => {
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
const server = createServer(session, session, {
|
||||
...(evidenceFilePolicy === undefined
|
||||
? {}
|
||||
: {
|
||||
evidenceFilePolicy,
|
||||
investigationInputRoots,
|
||||
}),
|
||||
...(permissionAuthority === undefined ? {} : { permissionAuthority }),
|
||||
});
|
||||
const server = createServer(
|
||||
session,
|
||||
session,
|
||||
permissionAuthority === undefined ? {} : { permissionAuthority },
|
||||
);
|
||||
const client = new Client({ name: "investigation-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
|
||||
@@ -9,7 +9,11 @@ import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { loadConfiguredPermissionAuthority } from "../../../src/application/PermissionConfiguration.js";
|
||||
import { observeJavaScriptRuntime } from "../../../src/application/JavaScriptRuntimeObservationService.js";
|
||||
import { V8InspectorProvider } from "../../../src/browser/V8InspectorProvider.js";
|
||||
import { observeJavaScriptRuntimeInputSchema } from "../../../src/domain/javascriptRuntimeObservation.js";
|
||||
import {
|
||||
javascriptRuntimeObservationSchema,
|
||||
javascriptRuntimeTargetListSchema,
|
||||
observeJavaScriptRuntimeInputSchema,
|
||||
} from "../../../src/domain/javascriptRuntimeObservation.js";
|
||||
import { parseConfig } from "../../../src/config.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
@@ -29,43 +33,89 @@ describe("JavaScript runtime observation MCP tools", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("accepts long caller windows and complete observation metadata", () => {
|
||||
const repeated = (count: number): string[] =>
|
||||
Array.from({ length: count }, (_, index) => `item-${index}`);
|
||||
const scope = {
|
||||
inspector_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_file_roots: ["/tmp/rea-runtime"],
|
||||
allowed_origins: [],
|
||||
};
|
||||
expect(
|
||||
observeJavaScriptRuntimeInputSchema.parse({
|
||||
...scope,
|
||||
target_id: "target",
|
||||
observation_ms: 2_147_483_648,
|
||||
}).observation_ms,
|
||||
).toBe(2_147_483_648);
|
||||
expect(
|
||||
javascriptRuntimeTargetListSchema.parse({
|
||||
runtime: {
|
||||
product: "Node.js",
|
||||
protocol_version: "1.0",
|
||||
v8_version: null,
|
||||
},
|
||||
targets: [],
|
||||
excluded: {
|
||||
outside_file_roots: 0,
|
||||
outside_origins: 0,
|
||||
unsupported_location: 0,
|
||||
unconnectable: 0,
|
||||
},
|
||||
limitations: repeated(101),
|
||||
}).limitations,
|
||||
).toHaveLength(101);
|
||||
|
||||
const unknowns = repeated(101);
|
||||
const limitations = repeated(101);
|
||||
expect(
|
||||
javascriptRuntimeObservationSchema.parse({
|
||||
runtime: {
|
||||
product: "Node.js",
|
||||
protocol_version: "1.0",
|
||||
v8_version: null,
|
||||
},
|
||||
target: {
|
||||
target_id: "target",
|
||||
protocol_type: "node",
|
||||
attached: false,
|
||||
location: { kind: "file", file_path: "/tmp/rea-runtime/main.js" },
|
||||
runtime_kind: "node",
|
||||
runtime_kind_authority: "caller-declared-unverified",
|
||||
},
|
||||
capture: {
|
||||
observation_ms: 10_001,
|
||||
events_observed: 0,
|
||||
events_retained: 0,
|
||||
events_dropped: 0,
|
||||
metadata_bytes_retained: 0,
|
||||
truncated: false,
|
||||
truncation_reasons: repeated(21),
|
||||
},
|
||||
scripts: {
|
||||
items: [],
|
||||
observed_total: 0,
|
||||
excluded: {
|
||||
outside_file_roots: 0,
|
||||
outside_origins: 0,
|
||||
unsupported_location: 0,
|
||||
invalid_protocol_value: 0,
|
||||
},
|
||||
},
|
||||
execution_contexts: [],
|
||||
directly_observed: repeated(21),
|
||||
unavailable_without_instrumentation: repeated(21),
|
||||
unknowns,
|
||||
limitations,
|
||||
}),
|
||||
).toMatchObject({ unknowns, limitations });
|
||||
});
|
||||
|
||||
test("lists and observes one target as retained Evidence", async () => {
|
||||
const root = await createTestTempDirectory("rea-v8-mcp-");
|
||||
temporary.push(root);
|
||||
const entry = join(root, "entry.js");
|
||||
await writeFile(entry, "export const value = 1;\n");
|
||||
const inspector = await startFakeV8Inspector({
|
||||
targetUrl: pathToFileURL(entry).href,
|
||||
});
|
||||
resources.push(inspector);
|
||||
const config = parseConfig({
|
||||
REA_V8_INSPECTOR_OBSERVE_ENABLED: "true",
|
||||
REA_V8_INSPECTOR_ENDPOINTS_JSON: JSON.stringify([inspector.endpoint]),
|
||||
REA_V8_INSPECTOR_FILE_ROOTS_JSON: JSON.stringify([root]),
|
||||
});
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
const server = createServer(session, session, {
|
||||
javascriptRuntimeObservation: new V8InspectorProvider(),
|
||||
permissionAuthority: authority.value,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
v8InspectorObservationEnabled: true,
|
||||
}),
|
||||
});
|
||||
const client = new Client({ name: "v8-mcp-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
resources.push(client, server, session);
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
const { entry, inspector, authority, client, session } =
|
||||
await createObservationClient(root, resources);
|
||||
|
||||
const listed = await client.callTool({
|
||||
name: "list_javascript_runtime_targets",
|
||||
@@ -115,23 +165,70 @@ describe("JavaScript runtime observation MCP tools", () => {
|
||||
"Runtime.enable",
|
||||
"Debugger.enable",
|
||||
]);
|
||||
const direct = await observeJavaScriptRuntime(
|
||||
new V8InspectorProvider(),
|
||||
authority.value,
|
||||
observeJavaScriptRuntimeInputSchema.parse({
|
||||
inspector_endpoint: inspector.endpoint,
|
||||
allowed_file_roots: [root],
|
||||
allowed_origins: [],
|
||||
target_id: inspector.targetId,
|
||||
runtime_kind: "node",
|
||||
observation_ms: 10,
|
||||
}),
|
||||
);
|
||||
const direct = await observeDirectly(root, inspector, authority);
|
||||
expect(direct.ok).toBe(true);
|
||||
if (direct.ok) expect(evidenceId).toBe(direct.value.evidence_id);
|
||||
});
|
||||
});
|
||||
|
||||
const createObservationClient = async (
|
||||
root: string,
|
||||
resources: Array<{ close(): Promise<unknown> }>,
|
||||
) => {
|
||||
const entry = join(root, "entry.js");
|
||||
await writeFile(entry, "export const value = 1;\n");
|
||||
const inspector = await startFakeV8Inspector({
|
||||
targetUrl: pathToFileURL(entry).href,
|
||||
});
|
||||
resources.push(inspector);
|
||||
const config = parseConfig({
|
||||
REA_V8_INSPECTOR_OBSERVE_ENABLED: "true",
|
||||
REA_V8_INSPECTOR_ENDPOINTS_JSON: JSON.stringify([inspector.endpoint]),
|
||||
REA_V8_INSPECTOR_FILE_ROOTS_JSON: JSON.stringify([root]),
|
||||
});
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
const server = createServer(session, session, {
|
||||
javascriptRuntimeObservation: new V8InspectorProvider(),
|
||||
permissionAuthority: authority.value,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
investigationInputRoots: 0,
|
||||
v8InspectorObservationEnabled: true,
|
||||
}),
|
||||
});
|
||||
const client = new Client({ name: "v8-mcp-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
resources.push(client, server, session);
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
return { entry, inspector, authority: authority.value, client, session };
|
||||
};
|
||||
|
||||
const observeDirectly = (
|
||||
root: string,
|
||||
inspector: Awaited<ReturnType<typeof startFakeV8Inspector>>,
|
||||
authority: Parameters<typeof observeJavaScriptRuntime>[1],
|
||||
) =>
|
||||
observeJavaScriptRuntime(
|
||||
new V8InspectorProvider(),
|
||||
authority,
|
||||
observeJavaScriptRuntimeInputSchema.parse({
|
||||
inspector_endpoint: inspector.endpoint,
|
||||
allowed_file_roots: [root],
|
||||
allowed_origins: [],
|
||||
target_id: inspector.targetId,
|
||||
runtime_kind: "node",
|
||||
observation_ms: 10,
|
||||
}),
|
||||
);
|
||||
|
||||
const evidenceIdFrom = (value: unknown): string => {
|
||||
if (typeof value !== "object" || value === null)
|
||||
throw new TypeError("Missing structured result");
|
||||
|
||||
@@ -62,7 +62,6 @@ it("opens a managed PE and executes the managed static provider through MCP", as
|
||||
}),
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
browserObservationEnabled: false,
|
||||
electronObservationEnabled: false,
|
||||
|
||||
@@ -132,7 +132,6 @@ describe("server and catalog identity", () => {
|
||||
it("reports composed, host, and target-specific availability truthfully", () => {
|
||||
const policy = {
|
||||
processCaptureEnabled: true,
|
||||
evidenceFileRoots: 1,
|
||||
investigationInputRoots: 1,
|
||||
};
|
||||
const composed = buildCapabilityInventory(
|
||||
|
||||
@@ -43,17 +43,8 @@ export const createSessionMcpHarness = async (
|
||||
resolveAnalysisProfile: () =>
|
||||
Promise.resolve(ok({ profile: SNAPSHOT_PROFILE, compatibility: {} })),
|
||||
});
|
||||
const filePolicy = {
|
||||
roots: [root],
|
||||
maxBytes: 1024 * 1024,
|
||||
maxDepth: 68,
|
||||
maxStringLength: 1024,
|
||||
maxNodes: 10_000,
|
||||
};
|
||||
const server = createServer(session, session, {
|
||||
logger: silentLogger,
|
||||
evidenceFilePolicy: filePolicy,
|
||||
analysisSnapshotFilePolicy: filePolicy,
|
||||
});
|
||||
const mcp = new Client({ name: "session-test", version: "1.0.0" });
|
||||
const [clientTransport, serverTransport] =
|
||||
|
||||
@@ -43,6 +43,30 @@ describe("runtime executable diagnostics", () => {
|
||||
expect(pathNodes.every(({ healthy }) => healthy)).toBe(true);
|
||||
});
|
||||
|
||||
it("reports every PATH candidate beyond the former per-tool cap", async () => {
|
||||
const directories = await Promise.all(
|
||||
Array.from({ length: 17 }, () => temporaryRoot()),
|
||||
);
|
||||
await Promise.all(
|
||||
directories.map((directory) =>
|
||||
symlink(process.execPath, join(directory, "node")),
|
||||
),
|
||||
);
|
||||
|
||||
const inventory = await inspectRuntimeExecutables({
|
||||
platform: process.platform,
|
||||
path: directories.join(delimiter),
|
||||
launcherNode: process.execPath,
|
||||
});
|
||||
|
||||
expect(
|
||||
inventory.candidates.filter(
|
||||
({ tool, path_index: pathIndex }) =>
|
||||
tool === "node" && pathIndex !== null,
|
||||
),
|
||||
).toHaveLength(17);
|
||||
});
|
||||
|
||||
it("distinguishes a healthy primary runtime from a broken shadowed candidate", async () => {
|
||||
const healthy = await temporaryRoot();
|
||||
const broken = await temporaryRoot();
|
||||
|
||||
@@ -239,6 +239,31 @@ describe("Hopper bridge search", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("returns regex matches without imposing a path-count limit", async () => {
|
||||
await expect(
|
||||
probe({
|
||||
action: "search",
|
||||
items: [
|
||||
["0x1000", "REA_GHIDRA_INVENTORY_ENTRY"],
|
||||
["0x2000", "unrelated"],
|
||||
["0x3000", "REA_GHIDRA_LEAF_VALUE"],
|
||||
],
|
||||
params: {
|
||||
pattern: "^REA_GHIDRA_(?:INVENTORY_ENTRY|LEAF_VALUE)$",
|
||||
mode: "regex",
|
||||
case_sensitive: true,
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
action: "search",
|
||||
ok: true,
|
||||
result: [
|
||||
{ address: "0x1000", value: "REA_GHIDRA_INVENTORY_ENTRY" },
|
||||
{ address: "0x3000", value: "REA_GHIDRA_LEAF_VALUE" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("returns the complete value for a long literal match", async () => {
|
||||
const value = `${"x".repeat(4_096)}needle`;
|
||||
await expect(
|
||||
|
||||
@@ -78,7 +78,7 @@ const authority = (exportRoot?: string): PermissionAuthority => {
|
||||
? []
|
||||
: [
|
||||
{
|
||||
capability: "evidence_write" as const,
|
||||
capability: "process_capture" as const,
|
||||
roots: [exportRoot],
|
||||
executables: [],
|
||||
environment_names: [],
|
||||
@@ -99,7 +99,7 @@ const authority = (exportRoot?: string): PermissionAuthority => {
|
||||
},
|
||||
...exportCeiling.map((item) => ({
|
||||
...item,
|
||||
grant_id: "administrator:evidence_write",
|
||||
grant_id: "administrator:process_capture",
|
||||
lifetime: "administrator" as const,
|
||||
operation_identity: null,
|
||||
expires_at: null,
|
||||
@@ -193,6 +193,29 @@ describe("controlled JavaScript replay planning", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts caller replay budgets above former tool-side ceilings", () => {
|
||||
expect(
|
||||
controlledReplayInputSchema.safeParse({
|
||||
...input("plan"),
|
||||
generator: { preset: "parser-boundaries", seed: 1, count: 65 },
|
||||
limits: {
|
||||
wall_time_ms: 60_000,
|
||||
memory_bytes: 1024 * 1024 * 1024,
|
||||
tasks: 64,
|
||||
cpu_quota_percent: 200,
|
||||
tmpfs_bytes: 128 * 1024 * 1024,
|
||||
module_bytes: 32 * 1024 * 1024,
|
||||
input_bytes: 2 * 1024 * 1024,
|
||||
protocol_bytes: 128 * 1024 * 1024,
|
||||
output_bytes: 8 * 1024 * 1024,
|
||||
stderr_bytes: 512 * 1024,
|
||||
result_depth: 128,
|
||||
result_nodes: 200_000,
|
||||
},
|
||||
}).success,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects oversized aggregate cases before probing or reading", async () => {
|
||||
const probe = vi.fn(host.probe);
|
||||
const readSource = vi.fn(host.readSource);
|
||||
|
||||
@@ -84,6 +84,12 @@ describe("Android application projection", () => {
|
||||
expect.objectContaining({ basis: "react-native-convention" }),
|
||||
]);
|
||||
expect(JSON.stringify(left)).not.toContain("opaque signing");
|
||||
expect(
|
||||
androidApplicationProjectionResultSchema.safeParse({
|
||||
...left,
|
||||
limitations: Array.from({ length: 101 }, () => "x".repeat(4_097)),
|
||||
}).success,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-APK inventory Evidence", async () => {
|
||||
|
||||
@@ -14,7 +14,73 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { projectAppleApplicationEvidence } from "../../../src/application/AppleApplicationService.js";
|
||||
import { runProviderAnalysis } from "../../../src/application/DirectAnalysis.js";
|
||||
import { appleApplicationProjectionResultSchema } from "../../../src/domain/appleApplication.js";
|
||||
import { parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js";
|
||||
|
||||
async function createCompleteAppleProjection() {
|
||||
const root = await createTestTempDirectory("rea-apple-complete-");
|
||||
const path = join(root, "Complete.ipa");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
for (let index = 0; index < 1_001; index++) {
|
||||
const name = String(index).padStart(4, "0");
|
||||
await writer.add(
|
||||
`Payload/Complete.app/Frameworks/F${name}.framework/Info.plist`,
|
||||
new TextReader("<plist><dict/></plist>"),
|
||||
);
|
||||
}
|
||||
for (let index = 0; index < 101; index++) {
|
||||
const name = String(index).padStart(3, "0");
|
||||
await writer.add(
|
||||
`Payload/Complete.app/script-${name}.js`,
|
||||
new TextReader("bridge.call();"),
|
||||
);
|
||||
await writer.add(
|
||||
`Payload/Complete.app/Frameworks/Native${name}.dylib`,
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([0xcf, 0xfa, 0xed, 0xfe, 0x0c, 0, 0, 1]),
|
||||
),
|
||||
);
|
||||
}
|
||||
await writeFile(path, await writer.close());
|
||||
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
);
|
||||
const subject = inventory.subject;
|
||||
expect(subject).not.toBeNull();
|
||||
if (subject === null)
|
||||
throw new TypeError("Missing fixture inventory subject");
|
||||
const inventoryPages = Array.from({ length: 101 }, (_, index) =>
|
||||
createEvidence(
|
||||
{
|
||||
path: subject.local_path,
|
||||
sha256: subject.digest.sha256,
|
||||
format: subject.format,
|
||||
...(subject.architecture === null
|
||||
? {}
|
||||
: { architecture: subject.architecture }),
|
||||
},
|
||||
inventory.provider,
|
||||
{
|
||||
predicateType: inventory.predicate_type,
|
||||
operation: inventory.operation,
|
||||
parameters: {
|
||||
...inventory.parameters,
|
||||
projection_test_page: index,
|
||||
},
|
||||
result: inventory.normalized_result,
|
||||
},
|
||||
),
|
||||
);
|
||||
const result = projectAppleApplicationEvidence({
|
||||
inventory_evidence: inventoryPages,
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) throw new TypeError("Could not project fixture inventory");
|
||||
return appleApplicationProjectionResultSchema.parse(
|
||||
result.value.normalized_result,
|
||||
);
|
||||
}
|
||||
|
||||
describe("Apple application projection", () => {
|
||||
it("projects deterministic IPA components and bridge hypotheses from exact inventory Evidence", async () => {
|
||||
@@ -53,11 +119,9 @@ describe("Apple application projection", () => {
|
||||
);
|
||||
const first = projectAppleApplicationEvidence({
|
||||
inventory_evidence: [inventory],
|
||||
limits: { max_components: 100 },
|
||||
});
|
||||
const second = projectAppleApplicationEvidence({
|
||||
inventory_evidence: [inventory],
|
||||
limits: { max_components: 100 },
|
||||
});
|
||||
expect(first.ok).toBe(true);
|
||||
expect(second.ok).toBe(true);
|
||||
@@ -75,7 +139,6 @@ describe("Apple application projection", () => {
|
||||
coverage: {
|
||||
status: "complete-within-inventory",
|
||||
inventory_complete: true,
|
||||
omitted_components: 0,
|
||||
},
|
||||
});
|
||||
expect(left.components.bundle_metadata).toHaveLength(1);
|
||||
@@ -99,7 +162,7 @@ describe("Apple application projection", () => {
|
||||
expect(JSON.stringify(left)).not.toContain("opaque signing bytes");
|
||||
});
|
||||
|
||||
it("rejects non-IPA Evidence and reports projection truncation", async () => {
|
||||
it("rejects non-IPA Evidence", async () => {
|
||||
const root = await createTestTempDirectory("rea-apple-invalid-");
|
||||
const path = join(root, "fixture.zip");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
@@ -116,6 +179,28 @@ describe("Apple application projection", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("returns every component, inventory page, and bridge hypothesis", async () => {
|
||||
const projection = await createCompleteAppleProjection();
|
||||
expect(projection.components.frameworks).toHaveLength(1_001);
|
||||
expect(projection.components.bundle_metadata).toHaveLength(1_001);
|
||||
expect(projection.components.javascript).toHaveLength(101);
|
||||
expect(projection.components.native_libraries).toHaveLength(101);
|
||||
expect(projection.source_evidence_ids).toHaveLength(101);
|
||||
expect(projection.bridge_candidates).toHaveLength(10_201);
|
||||
expect(projection.coverage).toEqual({
|
||||
status: "complete-within-inventory",
|
||||
inventory_complete: true,
|
||||
});
|
||||
expect(projection).not.toHaveProperty("omitted_components");
|
||||
expect(projection).not.toHaveProperty("omitted_bridge_candidates");
|
||||
expect(
|
||||
appleApplicationProjectionResultSchema.parse({
|
||||
...projection,
|
||||
limitations: Array.from({ length: 101 }, (_, index) => `fact ${index}`),
|
||||
}).limitations,
|
||||
).toHaveLength(101);
|
||||
});
|
||||
|
||||
it("infers an application root when the IPA omits directory entries", async () => {
|
||||
const root = await createTestTempDirectory("rea-apple-root-");
|
||||
const path = join(root, "Fixture.ipa");
|
||||
|
||||
@@ -29,7 +29,8 @@ it("reconstructs package, Electron roles, Webpack/Rspack modules, and cross-laye
|
||||
expect(result.statistics).toMatchObject({
|
||||
modules: 4,
|
||||
parse_failures: 0,
|
||||
omitted_text_files: 0,
|
||||
relevant_files: expect.any(Number),
|
||||
text_bytes_read: expect.any(Number),
|
||||
});
|
||||
expect(graph.nodes.map(({ kind }) => kind)).toEqual(
|
||||
expect.arrayContaining([
|
||||
|
||||
@@ -29,17 +29,9 @@ describe("analysis error projection contract", () => {
|
||||
).map(
|
||||
(reason) => new ArtifactOperationError("inventory_artifact", reason),
|
||||
),
|
||||
...(
|
||||
[
|
||||
"disabled",
|
||||
"outside-root",
|
||||
"not-file",
|
||||
"too-large",
|
||||
"exists",
|
||||
"invalid-json",
|
||||
"io",
|
||||
] as const
|
||||
).map((reason) => new EvidenceFileError("read", reason)),
|
||||
...(["not-file", "exists", "invalid-json", "io"] as const).map(
|
||||
(reason) => new EvidenceFileError("read", reason),
|
||||
),
|
||||
...(
|
||||
[
|
||||
"disabled",
|
||||
|
||||
@@ -168,6 +168,90 @@ describe("conformance package parsing", () => {
|
||||
});
|
||||
|
||||
describe("conformance package construction", () => {
|
||||
it("accepts packages with more than 100 scenarios and steps", () => {
|
||||
const scenarioTemplate = validPackageInput.scenarios[0];
|
||||
const replayTemplate = validPackageInput.replay_plans[0];
|
||||
if (scenarioTemplate === undefined || replayTemplate === undefined)
|
||||
throw new Error("Conformance package fixture is incomplete");
|
||||
const scenarios = Array.from({ length: 101 }, (_, index) => {
|
||||
const scenarioId = `scenario-${index}`;
|
||||
return {
|
||||
...scenarioTemplate,
|
||||
scenario_id: scenarioId,
|
||||
name: scenarioId,
|
||||
description: scenarioId,
|
||||
fixture_path: `tests/conformance/${scenarioId}`,
|
||||
expected_exit_code: 0,
|
||||
expected_patterns: [],
|
||||
};
|
||||
});
|
||||
const scenarioIds = scenarios.map(({ scenario_id }) => scenario_id);
|
||||
const packageWithManyScenarios = createConformancePackage({
|
||||
...validPackageInput,
|
||||
scenarios,
|
||||
replay_plans: scenarioIds.map((scenario_id) => ({
|
||||
...replayTemplate,
|
||||
scenario_id,
|
||||
environment: {},
|
||||
steps: Array.from({ length: 101 }, (_, index) => ({
|
||||
step_id: `step-${index}`,
|
||||
action: "inspect",
|
||||
arguments: [],
|
||||
timeout_ms: 1,
|
||||
})),
|
||||
})),
|
||||
expected_evidence: scenarioIds.map((scenario_id) => ({
|
||||
scenario_id,
|
||||
bundle: null,
|
||||
required_dimensions: [],
|
||||
envelopes: Array.from({ length: 101 }, (_, index) => ({
|
||||
evidence_id: `ev_${String(index).padStart(64, "0")}`,
|
||||
subject: null,
|
||||
provider: { id: "fixture", name: "Fixture", version: null },
|
||||
predicate_type: "observation",
|
||||
operation: "inspect",
|
||||
parameters: {},
|
||||
raw_result: null,
|
||||
normalized_result: null,
|
||||
confidence: "observed" as const,
|
||||
authority: "shipped-artifact" as const,
|
||||
environment: null,
|
||||
limitations: [],
|
||||
locations: [],
|
||||
evidence_links: [],
|
||||
})),
|
||||
})),
|
||||
verifier_contracts: scenarioIds.map((scenario_id) => ({
|
||||
scenario_id,
|
||||
timing_tolerance_ms: 0,
|
||||
dimensions: Array.from({ length: 51 }, (_, index) => ({
|
||||
name: `dimension-${index}`,
|
||||
required: true,
|
||||
comparison: "exact" as const,
|
||||
})),
|
||||
})),
|
||||
shim_plans: scenarioIds.map((scenario_id) => ({
|
||||
scenario_id,
|
||||
shims: Array.from({ length: 51 }, (_, index) => ({
|
||||
shim_id: `shim-${index}`,
|
||||
kind: "filesystem" as const,
|
||||
target: `/tmp/${index}`,
|
||||
policy: "observe" as const,
|
||||
})),
|
||||
})),
|
||||
});
|
||||
|
||||
expect(packageWithManyScenarios.scenarios).toHaveLength(101);
|
||||
expect(packageWithManyScenarios.replay_plans[0]?.steps).toHaveLength(101);
|
||||
expect(
|
||||
packageWithManyScenarios.expected_evidence[0]?.envelopes,
|
||||
).toHaveLength(101);
|
||||
expect(
|
||||
packageWithManyScenarios.verifier_contracts[0]?.dimensions,
|
||||
).toHaveLength(51);
|
||||
expect(packageWithManyScenarios.shim_plans[0]?.shims).toHaveLength(51);
|
||||
});
|
||||
|
||||
it("derives a deterministic identifier from parsed contents", () => {
|
||||
const same = createConformancePackage(validPackageInput);
|
||||
const changed = createConformancePackage({
|
||||
|
||||
@@ -9,7 +9,7 @@ describe("Codex agent release evaluation", () => {
|
||||
type: "mcp_tool_call",
|
||||
server: "rea",
|
||||
tool: "analyze_javascript_application",
|
||||
arguments: { input_path: "/tmp/app", approved: true },
|
||||
arguments: { input_path: "/tmp/app" },
|
||||
};
|
||||
const metrics = evaluateCodexEvents(
|
||||
[
|
||||
@@ -150,7 +150,7 @@ describe("Codex agent completion evaluation", () => {
|
||||
type: "mcp_tool_call",
|
||||
server: "rea",
|
||||
tool: "analyze_javascript_application",
|
||||
arguments: { input_path: "/tmp/app.asar", approved: true },
|
||||
arguments: { input_path: "/tmp/app.asar" },
|
||||
result: { structured_content: { error: { code: "denied" } } },
|
||||
error: null,
|
||||
status: "failed",
|
||||
|
||||
Vendored
+1
-14
@@ -1,4 +1,4 @@
|
||||
"""Execute REA's bridge regex helpers without starting a Hopper socket."""
|
||||
"""Exercise REA's bridge inventory search without starting a Hopper socket."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
@@ -15,19 +15,6 @@ def _load_bridge(path):
|
||||
def _probe(namespace, payload):
|
||||
action = payload["action"]
|
||||
try:
|
||||
if action == "match":
|
||||
flags = (
|
||||
0
|
||||
if payload.get("case_sensitive", False)
|
||||
else namespace["re"].IGNORECASE
|
||||
)
|
||||
expression = namespace["re"].compile(payload["pattern"], flags)
|
||||
matched = expression.search(payload["value"]) is not None
|
||||
return {
|
||||
"action": action,
|
||||
"ok": True,
|
||||
"matched": matched,
|
||||
}
|
||||
if action == "search":
|
||||
inventory = tuple(tuple(item) for item in payload["items"])
|
||||
namespace["_search_inventory"] = lambda _document, _kind: inventory
|
||||
|
||||
Vendored
+2
-1
@@ -12,6 +12,7 @@ interface FakeV8InspectorOptions {
|
||||
readonly targetUrl: string;
|
||||
readonly targetType?: "node" | "page";
|
||||
readonly scriptUrls?: readonly string[];
|
||||
readonly scriptHashes?: readonly string[];
|
||||
readonly additionalTargetUrl?: string;
|
||||
readonly additionalTargetCount?: number;
|
||||
readonly closeOnMethod?: string;
|
||||
@@ -126,7 +127,7 @@ export const startFakeV8Inspector = async (
|
||||
scriptId: String(index + 1),
|
||||
url,
|
||||
executionContextId: 1,
|
||||
hash: `hash-${String(index)}`,
|
||||
hash: options.scriptHashes?.[index] ?? `hash-${String(index)}`,
|
||||
length: 100 + index,
|
||||
isModule: index % 2 === 0,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user