mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 13:41:17 -05:00
fbfcad3152
* 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
56 lines
2.1 KiB
TypeScript
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 };
|
|
},
|
|
);
|