Inspect bounded recorded raw HTTP/XML SAZ archives and page retained capture Evidence. Preserve exact stored bytes and provenance, validate ZIP/XML integrity, and require an enforceable decoder memory bound. Verified 356 real recorded sessions against independent byte and metadata oracles, public CLI/MCP parity, retained pages, and related interface checks. Current Fiddler Everywhere GUI and non-Linux producer workflows remain unverified. Co-authored-by: zahhak <1792039+zahhak@users.noreply.github.com> Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com>
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { readFile, writeFile } from "node:fs/promises";
|
|
import { z } from "zod";
|
|
import { readStableArtifact } from "../../artifacts/readStableArtifact.js";
|
|
import { WEB_NETWORK_CAPTURE_LIMITS } from "../../domain/webNetworkCapture.js";
|
|
import { CaptureFormatError } from "./CaptureFormatError.js";
|
|
|
|
const requestSchema = z.strictObject({
|
|
snapshot_path: z.string(),
|
|
reply_path: z.string(),
|
|
sensitive_values: z.array(z.string().min(1)),
|
|
});
|
|
|
|
/** Parse untrusted captures in an owned heap and return one complete bounded reply. */
|
|
const main = async (): Promise<void> => {
|
|
const format = z.enum(["har", "saz"]).parse(process.argv[3]);
|
|
const request = requestSchema.parse(
|
|
JSON.parse(await readFile(process.argv[2] ?? "", "utf8")),
|
|
);
|
|
let reply: unknown;
|
|
try {
|
|
let value;
|
|
if (format === "har") {
|
|
const { decodeHarCapture, decodeHarText } =
|
|
await import("./HarCapture.js");
|
|
const snapshot = await readStableArtifact(
|
|
request.snapshot_path,
|
|
WEB_NETWORK_CAPTURE_LIMITS.inputBytes,
|
|
);
|
|
value = decodeHarCapture(
|
|
decodeHarText(snapshot.bytes),
|
|
request.sensitive_values,
|
|
);
|
|
} else {
|
|
const { decodeSazCapture } = await import("./SazCapture.js");
|
|
value = await decodeSazCapture(
|
|
request.snapshot_path,
|
|
request.sensitive_values,
|
|
);
|
|
}
|
|
reply = { ok: true, value };
|
|
} catch (cause: unknown) {
|
|
reply =
|
|
cause instanceof CaptureFormatError
|
|
? {
|
|
ok: false,
|
|
reason: cause.reason,
|
|
message: cause.message,
|
|
pointer: cause.pointer,
|
|
}
|
|
: {
|
|
ok: false,
|
|
reason: "decoder",
|
|
message: `Capture decoder failed unexpectedly (${cause instanceof Error ? cause.name : "unknown exception"}).`,
|
|
pointer: "",
|
|
};
|
|
}
|
|
let text = JSON.stringify(reply);
|
|
if (Buffer.byteLength(text) > WEB_NETWORK_CAPTURE_LIMITS.outputBytes)
|
|
text = JSON.stringify({
|
|
ok: false,
|
|
reason: "limit",
|
|
message: "Capture reply exceeds the complete-evidence output budget.",
|
|
pointer: "",
|
|
});
|
|
await writeFile(request.reply_path, text, { flag: "wx", mode: 0o600 });
|
|
};
|
|
await main();
|