Files
rea/src/cli/webScriptCommands.ts
T
morluto fbfcad3152 fix(evidence): route web script export and WASM comparison through shared Evidence inputs (#15385)
* fix(evidence): resolve web script and WASM comparison sources through the shared Evidence input owner

export_web_scripts accepts its capture as declared Evidence input: a
complete record, a retained reference, or a retained inspect_analysis_view
summary, which reads its retained parent. compare_wasm_interfaces admits
both sides through resolveEvidenceRequest, so a malformed side is a
bounded evidence_integrity_mismatch and a summary reads its parent. The
summary-to-parent rule lives in the shared resolver as completeProducers.
A catalog test checks that every declared Evidence input resolves a
retained reference through the shared resolver.

Refs #15341

* fix(evidence): retain an inline web script capture before publishing and commit the schema summary
2026-11-30 20:42:45 -05:00

56 lines
2.1 KiB
TypeScript

import type { Logger } from "pino";
import { exportWebScripts } from "../application/WebScriptExportService.js";
import { ArtifactResourceScope } from "../resources/index.js";
import { WEB_SCRIPT_TOOL_CONTRACTS } from "../contracts/webScriptToolContracts.js";
import { WEB_SCRIPT_EXPORT_PROVIDER } from "../domain/investigationProviders.js";
import { contractNamed } from "./contractCliDescription.js";
import { registerContractCommand } from "./contractCommand.js";
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
import type { CliInstance } from "./types.js";
/** Register the local captured-script export CLI workflow. */
export const registerWebScriptCommands = (
cli: CliInstance,
logger: Logger,
): void =>
registerContractCommand(
cli,
logger,
contractNamed(WEB_SCRIPT_TOOL_CONTRACTS, "export_web_scripts"),
{
description:
"Export retained website scripts into an absent directory for static JavaScript analysis",
positionals: ["capture_path", "output_directory"],
callerPaths: ["capture_path", "output_directory"],
omit: {
capture:
"The CLI reads the capture from capture_path, which also accepts a complete Evidence file",
},
fields: {
capture_path: {
description:
"Saved inspect_web_page or capture_browser_scenario JSON, normalized result or complete Evidence; a relative path resolves against the current directory",
},
output_directory: {
description:
"Absent directory for verified scripts and manifest; its parent must exist. A relative path resolves against the current directory",
},
},
},
async (input, { operation, signal }) => {
const resources = new ArtifactResourceScope();
const result = await finishAnalysisCommand(
() => exportWebScripts(input, resources, { signal }),
resources,
WEB_SCRIPT_EXPORT_PROVIDER.id,
operation,
signal,
"Web script export resources",
);
return result.ok
? result.value
: { error: "Script export failed", ...result.error };
},
);