mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 19:51:20 -05:00
cb4e5cfbff
* refactor(analysis): centralize resource budgets and recovery facts * feat(analysis): expose ASAR and Ghidra runtime admission controls * feat(artifacts): expose reader admission and preserve limited recognition * feat(javascript): expose recoverable semantic precision budgets * feat(web): add recoverable source-map budgets and compact retained views * feat(web): make historical capture decoding budgets recoverable * fix(desktop): enforce selected view policies across capture and export * feat(runtime): make Frida and LLDB retention budgets selectable * feat(native): expose diagnostic budgets and preserve exhaustion causes * feat(managed): expose recoverable snapshot and representation budgets * feat(metadata): make Go and Rust inspection budgets recoverable * feat(wasm): expose representation and producer admissions * feat(evm): expose per-call worker resource budgets * feat(android): make resource and string-pool omissions recoverable * feat(producers): expose command and recorded-capture budgets * docs(analysis): record recovery contracts and integrated validation * fix(docs): link calibration oracle from published verification pages * fix(docs): restore desktop task anchors and receipt links * test(analysis): align fixtures with selectable budget contracts * fix(analysis): remove source-location projector dependency cycle * test(analysis): refresh budget recovery and verifier regressions * test(analysis): preserve format and publication recovery expectations * test(windows): align conformance with owned runtime admission * fix(desktop): preserve selected alias kinds in exported state * test(analysis): align provider fixtures with recoverable budgets * test(desktop): validate emitted alias metadata structurally * fix(ghidra): classify bounded Windows endpoint refusals * test(cli): assert selectable artifact admission recovery * fix(cli): preserve capture provenance in environment builds
152 lines
6.2 KiB
TypeScript
152 lines
6.2 KiB
TypeScript
import { z } from "incur";
|
|
import {
|
|
WEB_NETWORK_CAPTURE_FORMATS,
|
|
inspectWebNetworkCaptureInputSchema,
|
|
} from "../domain/webNetworkCapture.js";
|
|
import { createWebNetworkCaptureService } from "../composition/webNetworkCaptures.js";
|
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
import { logCliCommand } from "../cliLogging.js";
|
|
import type { Logger } from "pino";
|
|
import type { CliInstance } from "./types.js";
|
|
import { cliDecimalField, cliIntegerArgument } from "./options.js";
|
|
import { withCommandCancellation } from "./commandCancellation.js";
|
|
import {
|
|
analysisEvidenceDeliveryOptions,
|
|
deliverCliAnalysisEvidence,
|
|
} from "./analysisEvidenceDelivery.js";
|
|
import { localPathStringSchema } from "../domain/localPath.js";
|
|
import { absoluteCallerPath } from "../filesystem/callerPath.js";
|
|
import { explicitSensitiveValueOptions } from "./explicitSensitiveArguments.js";
|
|
|
|
/** Expose offline historical capture inspection with the same selection contract as MCP. */
|
|
export const registerWebNetworkCaptureCommands = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
): void => {
|
|
cli.command(CLI_COMMANDS.inspectWebNetworkCapture, {
|
|
description:
|
|
"Inspect retained HAR, native mitmproxy, Fiddler SAZ or aioquic qlog records without fetching recorded URLs",
|
|
args: z.object({
|
|
capturePath: localPathStringSchema.describe("Local capture path"),
|
|
format: z
|
|
.enum(WEB_NETWORK_CAPTURE_FORMATS)
|
|
.describe("Producer capture format"),
|
|
}),
|
|
options: z.object({
|
|
...analysisEvidenceDeliveryOptions,
|
|
protobufFraming: z
|
|
.enum(["auto", "raw", "grpc", "grpc-web", "grpc-web-text"])
|
|
.optional()
|
|
.describe("Override framing for selected retained binary bodies"),
|
|
protobufBodyPointer: z
|
|
.array(z.string())
|
|
.optional()
|
|
.describe("Exact body pointers; repeat to select several"),
|
|
protobufSchema: localPathStringSchema
|
|
.optional()
|
|
.describe("Local compiled FileDescriptorSet path"),
|
|
protobufMessage: z
|
|
.string()
|
|
.optional()
|
|
.describe("Fully qualified message type in the descriptor set"),
|
|
record: z
|
|
.array(cliIntegerArgument(0))
|
|
.optional()
|
|
.describe("Zero-based producer ordinals; repeat to select several"),
|
|
...explicitSensitiveValueOptions,
|
|
maxInputBytes: cliDecimalField(
|
|
inspectWebNetworkCaptureInputSchema.shape.max_input_bytes,
|
|
),
|
|
maxReplyBytes: cliDecimalField(
|
|
inspectWebNetworkCaptureInputSchema.shape.max_reply_bytes,
|
|
),
|
|
maxNestingDepth: cliDecimalField(
|
|
inspectWebNetworkCaptureInputSchema.shape.max_nesting_depth,
|
|
),
|
|
// Decimal tokens only: numeric coercion would read "0x1" as 1 ms.
|
|
captureTimeoutMs: cliDecimalField(
|
|
inspectWebNetworkCaptureInputSchema.shape.capture_timeout_ms,
|
|
),
|
|
}),
|
|
run: ({ args, options }) =>
|
|
withCommandCancellation((signal) =>
|
|
logCliCommand(
|
|
logger,
|
|
CLI_COMMANDS.inspectWebNetworkCapture,
|
|
async () => {
|
|
const service = createWebNetworkCaptureService(environment);
|
|
return deliverCliAnalysisEvidence({
|
|
run: () =>
|
|
service.inspect(
|
|
{
|
|
capture_path: absoluteCallerPath(args.capturePath),
|
|
format: args.format,
|
|
sensitive_values: options.sensitiveValue,
|
|
...(options.maxInputBytes === undefined
|
|
? {}
|
|
: { max_input_bytes: options.maxInputBytes }),
|
|
...(options.maxReplyBytes === undefined
|
|
? {}
|
|
: { max_reply_bytes: options.maxReplyBytes }),
|
|
...(options.maxNestingDepth === undefined
|
|
? {}
|
|
: { max_nesting_depth: options.maxNestingDepth }),
|
|
...([
|
|
options.protobufFraming,
|
|
options.protobufBodyPointer,
|
|
options.protobufSchema,
|
|
options.protobufMessage,
|
|
].every((value) => value === undefined)
|
|
? {}
|
|
: {
|
|
protobuf: {
|
|
framing: options.protobufFraming ?? "auto",
|
|
...(options.protobufBodyPointer === undefined
|
|
? {}
|
|
: { body_pointers: options.protobufBodyPointer }),
|
|
...(options.protobufSchema === undefined &&
|
|
options.protobufMessage === undefined
|
|
? {}
|
|
: {
|
|
schema: {
|
|
descriptor_set_path:
|
|
options.protobufSchema === undefined
|
|
? undefined
|
|
: absoluteCallerPath(
|
|
options.protobufSchema,
|
|
),
|
|
message_type: options.protobufMessage,
|
|
},
|
|
}),
|
|
},
|
|
}),
|
|
...(options.record === undefined
|
|
? {}
|
|
: { record_ordinals: options.record }),
|
|
...(options.captureTimeoutMs === undefined
|
|
? {}
|
|
: { capture_timeout_ms: options.captureTimeoutMs }),
|
|
},
|
|
{ signal },
|
|
{
|
|
capture: args.capturePath,
|
|
...(options.protobufSchema === undefined
|
|
? {}
|
|
: { descriptor: options.protobufSchema }),
|
|
},
|
|
),
|
|
service,
|
|
providerId: "web-network-capture",
|
|
operation: "inspect_web_network_capture",
|
|
signal,
|
|
detail: options.detail,
|
|
evidenceOutput: options.evidence_output,
|
|
sensitiveValues: options.sensitiveValue ?? [],
|
|
});
|
|
},
|
|
),
|
|
),
|
|
});
|
|
};
|