mirror of
https://github.com/morluto/rea.git
synced 2026-11-10 08:47:00 +00:00
* fix(ci): retire unused internal analysis declarations * test: use an admitted app bundle for provider routing (cherry picked from commit00aa17f12a) * test: keep bundle routing coverage outside oversized group (cherry picked from commit8658353b0d) * fix(ci): align regression fixtures with current admission contracts * test: bind extraction close fixtures to their ZIP digest (cherry picked from commit626d0250db) * test(cli): match typed analysis outcomes in function detail fixture * test(ghidra): preserve empty Java property separator framing * test(electron): retain unknown IPC ownership for native module gaps * fix(electron): share source-scoped call path identity * test(captures): assert safe source identity on SAZ refusal * test(apple): match root occurrence kind to inventory manifest * fix(examples): align directory root occurrence identity * test(electron): align equivalent fixture assertions with upstream * test(process): assert retained capture root identity * test(windows): declare the PE fixture optional header * test(ci): refresh owned registration and verifier fixtures * test(setup): use owned registrations for refresh fixtures * test(process): control unavailable ownership in CLI cleanup fixture * test(process): guard controlled compiler output arguments * test(setup): align equivalent entrypoint guards with upstream * test(process): release the cleanup target through an owned gate * test(ci): align semantic identities and owned fixture facts * test(pcap): retain the upstream DNS wire fixture branch * test(pcap): use the canonical wire ownership fixture * test(pcap): assert exact DNS wire query labels * test(ci): preserve admission and ownership fixture prerequisites * test(ci): align authenticated fixture and cleanup boundaries * test(windows): align native artifact fixtures with upstream * test(android): request complete evidence for inline MCP contracts * test: avoid pinning diagnostic wording * test: verify cleanup diagnostics at their source * test: strengthen evidence and cleanup checks * test: avoid pinning registration guidance --------- Co-authored-by: Plastic-time <Plastic-time@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
117 lines
3.9 KiB
TypeScript
117 lines
3.9 KiB
TypeScript
import { chmod, mkdir, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { expect, it } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
import {
|
|
expandToolAvailability,
|
|
sessionProvider,
|
|
} from "../../../src/contracts/toolOutputSchemaPrimitives.js";
|
|
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { createApplicationMcpHarness } from "../../fixtures/applicationMcpHarness.js";
|
|
|
|
// The server enables default packet tools only on Linux, where they can run.
|
|
const linux = process.platform === "linux";
|
|
|
|
const packetCaptureAvailability = async (
|
|
environment: Readonly<Record<string, string | undefined>>,
|
|
name = "inspect_packet_capture",
|
|
): Promise<Record<string, unknown> | undefined> => {
|
|
const session = createTestBinarySession(() => {
|
|
throw new Error("binary analysis must not start during status discovery");
|
|
});
|
|
const { client } = await createApplicationMcpHarness({
|
|
session,
|
|
serverOptions: {
|
|
environment: { ...environment, REA_MCP_OUTPUT_SCHEMA_PROFILE: "off" },
|
|
},
|
|
clientIdentity: { name: "packet-capture-availability", version: "1" },
|
|
});
|
|
const response = await client.callTool({
|
|
name: "binary_session",
|
|
arguments: {},
|
|
});
|
|
if (response.isError === true) throw new Error("binary_session failed");
|
|
const parsed = z
|
|
.object({ result: sessionProvider })
|
|
.parse(response.structuredContent).result;
|
|
return expandToolAvailability(parsed.tool_availability).find(
|
|
(tool) => tool.name === name,
|
|
);
|
|
};
|
|
|
|
const executableTshark = async (prefix: string): Promise<string> => {
|
|
const directory = await createTestTempDirectory(prefix);
|
|
await mkdir(join(directory, "bin"));
|
|
const tshark = join(directory, "bin", "tshark");
|
|
await writeFile(tshark, "");
|
|
await chmod(tshark, 0o700);
|
|
return join(directory, "bin");
|
|
};
|
|
|
|
it.runIf(linux)(
|
|
"reports packet tools available for a PATH-only TShark install",
|
|
async () => {
|
|
const bin = await executableTshark("rea-packet-path-only-");
|
|
expect(await packetCaptureAvailability({ PATH: bin })).toMatchObject({
|
|
available: true,
|
|
reason: "available",
|
|
});
|
|
},
|
|
);
|
|
|
|
it.runIf(linux)(
|
|
"reports packet tools available for an absolute REA_TSHARK_COMMAND",
|
|
async () => {
|
|
const bin = await executableTshark("rea-packet-absolute-");
|
|
expect(
|
|
await packetCaptureAvailability({
|
|
PATH: "",
|
|
REA_TSHARK_COMMAND: join(bin, "tshark"),
|
|
}),
|
|
).toMatchObject({ available: true, reason: "available" });
|
|
},
|
|
);
|
|
|
|
it.runIf(linux)(
|
|
"reports packet tools missing for a relative REA_TSHARK_COMMAND even when PATH holds TShark",
|
|
async () => {
|
|
const bin = await executableTshark("rea-packet-relative-");
|
|
expect(
|
|
await packetCaptureAvailability({
|
|
PATH: bin,
|
|
REA_TSHARK_COMMAND: "bin/tshark",
|
|
}),
|
|
).toMatchObject({ available: false, reason: "provider_missing" });
|
|
},
|
|
);
|
|
|
|
it("reports packet tools unavailable when no absolute PATH entry holds TShark", async () => {
|
|
// Off Linux the host, not the missing tool, keeps packet tools unavailable.
|
|
expect(
|
|
await packetCaptureAvailability({ PATH: "relative-entry" }),
|
|
).toMatchObject({
|
|
available: false,
|
|
reason: linux ? "provider_missing" : "unsupported_host",
|
|
});
|
|
});
|
|
|
|
it("advertises pcap capture host support separately from the always available client probe", async () => {
|
|
expect(
|
|
await packetCaptureAvailability({}, "inspect_pcap_client"),
|
|
).toMatchObject({ available: true, reason: "available" });
|
|
expect(
|
|
await packetCaptureAvailability({}, "inspect_pcap_capture"),
|
|
).toMatchObject(
|
|
process.platform === "linux" || process.platform === "win32"
|
|
? { available: true, reason: "available" }
|
|
: {
|
|
available: false,
|
|
reason: "unsupported_host",
|
|
remediation: expect.stringContaining("native memory bound"),
|
|
},
|
|
);
|
|
});
|