Files
reverse-engineering-anything/src/cli/captureCommands.ts
T
morluto 11c1e45cce fix(cli): record the caller's --join-path spelling in Apple IPS Evidence (#10606)
* fix(cli): record the caller's --join-path spelling in Apple IPS Evidence

* refactor(cli): project CLI-only options for release exposure and IL2CPP from contracts (#10635)

* refactor(cli): project CLI-only options for release exposure and IL2CPP from contracts

The contract command description gains CLI-only options whose effect the handler owns, plus their dependentRequired entries. audit-release-exposure keeps --fail_on (exit status 3) and inspect-il2cpp-metadata keeps --ghidra-seeds/--seed-base; their hand-written options and input spreads are deleted.

* refactor(cli): project GPU, signal and capture inspectors from their contracts (#10643)

The contract command description gains JSON options decoded when the command runs, admitted with the delivery by the contract input, and bare flags that spell a nullable limit's null. inspect-gpu-code-objects, inspect-signal-decoders, decode-signal-recording, inspect-packet-fields and inspect-packet-capture are derived from their contracts; their hand-written options, superRefine blocks and CLI-only option schemas are deleted.
2026-11-15 17:04:45 +08:00

97 lines
3.0 KiB
TypeScript

import type { Logger } from "pino";
import type { PacketCaptureService } from "../application/captures/PacketCaptureService.js";
import { CLI_COMMANDS } from "../cliCommandNames.js";
import { createPacketCaptureService } from "../composition/captures.js";
import { CAPTURE_TOOL_CONTRACTS } from "../contracts/captures/captureToolContracts.js";
import { contractNamed } from "./contractCliDescription.js";
import {
analyzeWithService,
inspectWithService,
registerContractCommand,
} from "./contractCommand.js";
import { PRODUCER_LIMITS_HELP } from "./producerLimitsOption.js";
import type { CliInstance } from "./types.js";
export const registerCaptureCommands = (
cli: CliInstance,
logger: Logger,
environment: Readonly<NodeJS.ProcessEnv>,
service: Pick<
PacketCaptureService,
"inspect" | "inspectFields" | "close"
> = createPacketCaptureService(environment),
): void => {
const close = () => service.close();
registerContractCommand(
cli,
logger,
contractNamed(CAPTURE_TOOL_CONTRACTS, "inspect_packet_fields"),
{
command: CLI_COMMANDS.inspectPacketFields,
description: "Search installed TShark protocol and field definitions",
jsonText: ["producer_limits"],
nullFlags: {
limit: {
key: "all",
description: "Return all remaining matches within resource limits",
},
},
fields: {
producer_limits: { description: PRODUCER_LIMITS_HELP },
limit: {
description: "Maximum matching records to return; defaults to 50",
},
},
},
analyzeWithService(
() => ({
inspect: (input, options) => service.inspectFields(input, options),
close,
}),
"tshark-capture",
),
);
registerContractCommand(
cli,
logger,
contractNamed(CAPTURE_TOOL_CONTRACTS, "inspect_packet_capture"),
{
command: CLI_COMMANDS.inspectPacketCapture,
description:
"Inspect an existing packet capture with caller-supplied TShark",
positionals: ["path"],
callerPaths: ["path"],
jsonText: ["producer_limits"],
nullFlags: {
match_limit: {
key: "all_matches",
description:
"Return all remaining matching frames instead of a bounded page",
},
},
crossFieldRules: "argv",
fields: {
path: { description: "Local packet capture" },
producer_limits: { description: PRODUCER_LIMITS_HELP },
display_filter: { name: "display_filter" },
decode_as: { name: "decode_as" },
packet_limit: { name: "packet_limit" },
two_pass: { name: "two_pass" },
match_offset: { name: "match_offset" },
match_limit: {
name: "match_limit",
description: "Returned matching frames per page; default 50",
},
},
},
inspectWithService(
() => ({
inspect: (input, options) => service.inspect(input, options),
close,
}),
"tshark-capture",
),
);
};