mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
* fix(mcp)!: require absolute local paths for pcap capture and debugger sessions The MCP server's working directory is not the caller's, so sibling local file contracts refuse a relative path. inspect_pcap_capture (path), start_rizin_debug_session (path, inferior_tty) and start_gdb_session (inferior_tty) admitted one and resolved it against the server's directory. They now use absoluteLocalPathStringSchema. The inspect-pcap-capture CLI command declares path as a caller path, so a relative CLI argument is still resolved against the caller's working directory before the contract sees it. debug-with-rizin and debug-with-gdb call their managers directly and are unchanged. BREAKING CHANGE: MCP calls to inspect_pcap_capture, start_rizin_debug_session and start_gdb_session with a relative path or inferior_tty are refused with invalid_request. Pass absolute paths. Fixes #11079 * test(mcp): call the debugger session tools with absolute paths * fix(cli): describe the inspect-pcap-capture path without the MCP absolute requirement The CLI resolves a relative capture path, so its help keeps the caller-path description instead of inheriting the contract's absolute wording. * test(pcap): expect the absolute-path format issue beside the empty-path bound
61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
import type { Logger } from "pino";
|
|
|
|
import { PcapAnalysisService } from "../application/pcap/PcapAnalysisService.js";
|
|
import type { PcapAnalysisPort } from "../application/pcap/PcapAnalysisPort.js";
|
|
import { createPcapAnalysisProvider } from "../composition/pcap.js";
|
|
import { PCAP_TOOL_CONTRACTS } from "../contracts/pcap/pcapToolContracts.js";
|
|
import type { PcapOperation } from "../domain/pcap/pcapAnalysis.js";
|
|
import { contractNamed } from "./contractCliDescription.js";
|
|
import {
|
|
analyzeWithService,
|
|
inspectWithService,
|
|
registerContractCommand,
|
|
type EvidenceInspectionService,
|
|
} from "./contractCommand.js";
|
|
import type { CliInstance } from "./types.js";
|
|
|
|
/** Expose the same explicit pcap requests through one-shot CLI commands. */
|
|
export const registerPcapCommands = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
environment: Readonly<Record<string, string | undefined>>,
|
|
provider: PcapAnalysisPort = createPcapAnalysisProvider(environment),
|
|
): void => {
|
|
const pcap = new PcapAnalysisService(provider);
|
|
// Each command releases the shared provider's tools when it finishes.
|
|
const service =
|
|
(operation: PcapOperation) => (): EvidenceInspectionService => ({
|
|
inspect: (input, options) => pcap.execute(operation, input, options),
|
|
close: () => provider.close(),
|
|
});
|
|
registerContractCommand(
|
|
cli,
|
|
logger,
|
|
contractNamed(PCAP_TOOL_CONTRACTS, "inspect_pcap_client"),
|
|
{
|
|
description:
|
|
"Inspect the caller-selected tshark and capinfos binaries without reading a capture",
|
|
},
|
|
analyzeWithService(service("inspect_pcap_client"), "pcap"),
|
|
);
|
|
registerContractCommand(
|
|
cli,
|
|
logger,
|
|
contractNamed(PCAP_TOOL_CONTRACTS, "inspect_pcap_capture"),
|
|
{
|
|
description:
|
|
"Inspect one pcap/pcapng capture: endpoints, DNS, TLS SNI, and protocol distribution",
|
|
positionals: ["path"],
|
|
callerPaths: ["path"],
|
|
fields: {
|
|
path: { description: "Local pcap or pcapng capture file to inspect" },
|
|
},
|
|
omit: {
|
|
detail:
|
|
"The one-shot command returns complete Evidence; summaries are retained by MCP sessions.",
|
|
},
|
|
},
|
|
inspectWithService(service("inspect_pcap_capture"), "pcap"),
|
|
);
|
|
};
|