mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
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.
This commit is contained in:
1 parent
d044f44d91
commit
11c1e45cce
11 files changed
+944
-774
No files matched your search
+96
-111
@@ -1,50 +1,94 @@
|
||||
import { localPathStringSchema } from "../domain/localPath.js";
|
||||
import { absoluteCallerPath } from "../filesystem/callerPath.js";
|
||||
import { z } from "incur";
|
||||
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
||||
import { err } from "../domain/result.js";
|
||||
import { createIl2cppMetadataService } from "../composition/il2cpp.js";
|
||||
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
||||
import { logCliCommand } from "../cliLogging.js";
|
||||
import type { Logger } from "pino";
|
||||
import type { CliInstance } from "./types.js";
|
||||
import { withCommandCancellation } from "./commandCancellation.js";
|
||||
|
||||
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
||||
import { createIl2cppMetadataService } from "../composition/il2cpp.js";
|
||||
import { IL2CPP_TOOL_CONTRACTS } from "../contracts/il2cpp/il2cppToolContracts.js";
|
||||
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
||||
import { localPathStringSchema } from "../domain/localPath.js";
|
||||
import { err } from "../domain/result.js";
|
||||
import { absoluteCallerPath } from "../filesystem/callerPath.js";
|
||||
import { contractNamed } from "./contractCliDescription.js";
|
||||
import {
|
||||
analysisEvidenceDeliveryOptions,
|
||||
deliverCliAnalysisEvidence,
|
||||
} from "./analysisEvidenceDelivery.js";
|
||||
deliverWithService,
|
||||
registerContractCommand,
|
||||
} from "./contractCommand.js";
|
||||
import type { CliInstance } from "./types.js";
|
||||
|
||||
/**
|
||||
* Inspection with the CLI-only Ghidra seed output: `--ghidra-seeds` writes
|
||||
* seeds for the linked methods, and `--seed-base` rebases them.
|
||||
*/
|
||||
const il2cppService = (
|
||||
ghidraSeeds: string | undefined,
|
||||
seedBase: string | undefined,
|
||||
) => {
|
||||
const service = createIl2cppMetadataService();
|
||||
return {
|
||||
inspect: (input: unknown, options: { readonly signal: AbortSignal }) => {
|
||||
if (ghidraSeeds !== undefined)
|
||||
return service.inspectWithGhidraSeeds(
|
||||
input,
|
||||
{
|
||||
path: absoluteCallerPath(ghidraSeeds),
|
||||
...(seedBase === undefined ? {} : { base: seedBase }),
|
||||
},
|
||||
options,
|
||||
);
|
||||
if (seedBase !== undefined)
|
||||
return Promise.resolve(
|
||||
err(
|
||||
new AnalysisInputError("inspect_il2cpp_metadata", undefined, [
|
||||
{
|
||||
path: ["seed_base"],
|
||||
reason: "invalid_value",
|
||||
message: "--seed-base requires --ghidra-seeds.",
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
return service.inspect(input, options);
|
||||
},
|
||||
close: () => service.close(),
|
||||
};
|
||||
};
|
||||
|
||||
/** CLI and MCP share inspection; one-shot summaries preserve a complete Evidence file. */
|
||||
export const registerIl2cppCommands = (
|
||||
cli: CliInstance,
|
||||
logger: Logger,
|
||||
): void => {
|
||||
cli.command(CLI_COMMANDS.inspectIl2cppMetadata, {
|
||||
description:
|
||||
"Inventory IL2CPP global-metadata.dat names, owners and string literals, optionally linking method addresses from the native binary",
|
||||
args: z.object({
|
||||
path: localPathStringSchema.describe(
|
||||
"Local global-metadata.dat (version 24, 27, 29, 31 or 39)",
|
||||
),
|
||||
}),
|
||||
options: z
|
||||
.object({
|
||||
...analysisEvidenceDeliveryOptions,
|
||||
binary: localPathStringSchema
|
||||
.optional()
|
||||
.describe(
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
contractNamed(IL2CPP_TOOL_CONTRACTS, "inspect_il2cpp_metadata"),
|
||||
{
|
||||
command: CLI_COMMANDS.inspectIl2cppMetadata,
|
||||
description:
|
||||
"Inventory IL2CPP global-metadata.dat names, owners and string literals, optionally linking method addresses from the native binary",
|
||||
positionals: ["path"],
|
||||
callerPaths: ["path", "binary_path"],
|
||||
evidenceDelivery: true,
|
||||
fields: {
|
||||
path: {
|
||||
description:
|
||||
"Local global-metadata.dat (version 24, 27, 29, 31 or 39)",
|
||||
},
|
||||
binary_path: {
|
||||
name: "binary",
|
||||
description:
|
||||
"Matching native binary (Mach-O GameAssembly.dylib, PE GameAssembly.dll or ELF libil2cpp.so) to link method addresses; read only",
|
||||
),
|
||||
architecture: z
|
||||
.enum(["arm64", "amd64"])
|
||||
.optional()
|
||||
.describe("Slice of a universal Mach-O binary"),
|
||||
genericInstances: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
},
|
||||
binary_architecture: {
|
||||
name: "architecture",
|
||||
description: "Slice of a universal Mach-O binary",
|
||||
},
|
||||
generic_instances: {
|
||||
description:
|
||||
"Also link generic method instances (Type<Args>$$Method<Args>) and include them in --ghidra-seeds; needs --binary",
|
||||
),
|
||||
},
|
||||
},
|
||||
cliOptions: {
|
||||
ghidraSeeds: localPathStringSchema
|
||||
.optional()
|
||||
.describe(
|
||||
@@ -57,79 +101,20 @@ export const registerIl2cppCommands = (
|
||||
.describe(
|
||||
"Address Ghidra loads the binary at; seeds are seed-base + RVA (default: Ghidra's loader default, 0x100000 for an ELF linked at 0, else the link base)",
|
||||
),
|
||||
})
|
||||
.meta({
|
||||
dependentRequired: {
|
||||
architecture: ["binary"],
|
||||
ghidraSeeds: ["binary"],
|
||||
seedBase: ["ghidraSeeds"],
|
||||
},
|
||||
if: {
|
||||
properties: { genericInstances: { const: true } },
|
||||
required: ["genericInstances"],
|
||||
},
|
||||
then: { required: ["binary"] },
|
||||
}),
|
||||
run: ({ args, options }) =>
|
||||
withCommandCancellation((signal) =>
|
||||
logCliCommand(logger, CLI_COMMANDS.inspectIl2cppMetadata, async () => {
|
||||
const service = createIl2cppMetadataService();
|
||||
return deliverCliAnalysisEvidence({
|
||||
callerInputPath: args.path,
|
||||
...(options.binary === undefined
|
||||
? {}
|
||||
: { callerInputPaths: { binary_path: options.binary } }),
|
||||
run: () => {
|
||||
const input = {
|
||||
path: absoluteCallerPath(args.path),
|
||||
detail: "complete" as const,
|
||||
...(options.binary === undefined
|
||||
? {}
|
||||
: { binary_path: absoluteCallerPath(options.binary) }),
|
||||
...(options.architecture === undefined
|
||||
? {}
|
||||
: { binary_architecture: options.architecture }),
|
||||
...(options.genericInstances === true
|
||||
? { generic_instances: true }
|
||||
: {}),
|
||||
};
|
||||
if (options.ghidraSeeds !== undefined)
|
||||
return service.inspectWithGhidraSeeds(
|
||||
input,
|
||||
{
|
||||
path: absoluteCallerPath(options.ghidraSeeds),
|
||||
...(options.seedBase === undefined
|
||||
? {}
|
||||
: { base: options.seedBase }),
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
if (options.seedBase !== undefined)
|
||||
return Promise.resolve(
|
||||
err(
|
||||
new AnalysisInputError(
|
||||
"inspect_il2cpp_metadata",
|
||||
undefined,
|
||||
[
|
||||
{
|
||||
path: ["seed_base"],
|
||||
reason: "invalid_value",
|
||||
message: "--seed-base requires --ghidra-seeds.",
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
return service.inspect(input, { signal });
|
||||
},
|
||||
service,
|
||||
providerId: "il2cpp-metadata",
|
||||
operation: "inspect_il2cpp_metadata",
|
||||
signal,
|
||||
detail: options.detail,
|
||||
evidenceOutput: options.evidence_output,
|
||||
});
|
||||
}),
|
||||
),
|
||||
});
|
||||
},
|
||||
cliOptionDependencies: {
|
||||
ghidraSeeds: ["binary"],
|
||||
seedBase: ["ghidraSeeds"],
|
||||
},
|
||||
},
|
||||
(input, context) => {
|
||||
const { ghidraSeeds, seedBase } = context.cliOptions;
|
||||
// The CLI delivers the summary itself, so the service returns complete
|
||||
// Evidence; the contract's own default would retain a summary instead.
|
||||
return deliverWithService(
|
||||
() => il2cppService(ghidraSeeds, seedBase),
|
||||
"il2cpp-metadata",
|
||||
)({ ...input, detail: "complete" }, context);
|
||||
},
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user