Files
reverse-engineering-anything/src/cli/releaseExposureCommands.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

72 lines
2.4 KiB
TypeScript

import { z } from "incur";
import type { Logger } from "pino";
import { CLI_COMMANDS } from "../cliCommandNames.js";
import { createReleaseExposureService } from "../composition/releaseExposure.js";
import { RELEASE_EXPOSURE_TOOL_CONTRACTS } from "../contracts/releaseExposureToolContracts.js";
import {
exposureMeetsFailOn,
releaseExposureReportSchema,
} from "../domain/releaseExposure.js";
import { contractNamed } from "./contractCliDescription.js";
import {
inspectWithService,
registerContractCommand,
} from "./contractCommand.js";
import type { CliInstance } from "./types.js";
/** Report what static analysis recovers from one shipped artifact. */
export const registerReleaseExposureCommands = (
cli: CliInstance,
logger: Logger,
environment: Readonly<Record<string, string | undefined>>,
): void => {
const inspect = inspectWithService(
() => createReleaseExposureService(environment),
"rea-release-exposure",
);
registerContractCommand(
cli,
logger,
contractNamed(RELEASE_EXPOSURE_TOOL_CONTRACTS, "audit_release_exposure"),
{
command: CLI_COMMANDS.auditReleaseExposure,
description:
"Report what static analysis of a shipped artifact recovers. Reads the selected path. When the selection is a file, the parent directory is listed for sibling .pdb, .dSYM, .debug, and .map debug companions.",
positionals: ["path"],
callerPaths: ["path"],
fields: {
path: {
description:
"Shipped .app bundle, install directory, ASAR, or executable",
},
},
cliOptions: {
fail_on: z
.enum(["high", "medium", "low"])
.optional()
.describe(
"Completed audit exits 3 when an exposed check meets this severity. Unknown and unassessed checks do not.",
),
},
},
async (input, context) => {
const projected = await inspect(input, context);
const failOn = context.cliOptions.fail_on;
if (
failOn !== undefined &&
projected !== null &&
typeof projected === "object" &&
"normalized_result" in projected
) {
const report = releaseExposureReportSchema.safeParse(
projected.normalized_result,
);
if (report.success && exposureMeetsFailOn(report.data, failOn))
process.exitCode = 3;
}
return projected;
},
);
};