Files
reverse-engineering-anything/src/composition/reverseEngineering.ts
T
gensokyo-devandClaude Opus 5.5 6ce708cfde fix(rizin): report shell refusals instead of complete empty results
Rizin exits 0 when its shell refuses a statement, so execute_rizin_command
reported completion_status complete with exit code 0 and an empty stdout
that read as a genuine empty result.

Rizin 0.6 through 0.9.1 log exactly four refusal lines from
librz/core/cmd/cmd.c: an unknown command, a wrong argument count, an
invalid statement (RZ_CMD_STATUS_INVALID, which also stops the remaining
statements) and a parse error. The Rizin command profile now classifies a
completed process's stderr against those lines; the shared one-shot
service reports completion_status "rejected" and a limitation that names
the refusal and says stdout holds only earlier statements' output. Other
ERROR lines come from commands that ran and stay diagnostics.

Fixes #10364

Co-Authored-By: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 04:42:35 +01:00

62 lines
2.2 KiB
TypeScript

import type { ReverseEngineeringServiceRuntimeOptions } from "../application/reverse/ReverseEngineeringService.js";
import type { ReverseEngineeringCommandPort } from "../application/reverse/ReverseEngineeringCommandPort.js";
import { ReverseEngineeringService } from "../application/reverse/ReverseEngineeringService.js";
import { objdumpCommand } from "../objdump/ObjdumpCommand.js";
import { OBJDUMP_PROVIDER_IDENTITY } from "../objdump/ObjdumpProviderIdentity.js";
import {
rizinCommand,
rizinCommandLimitations,
rizinCommandRejection,
} from "../rizin/RizinCommand.js";
import { RIZIN_PROVIDER_IDENTITY } from "../rizin/RizinProviderIdentity.js";
import { resolveWindowsProviderExecutable } from "./resolveWindowsProviderExecutable.js";
export const createReverseEngineeringCommandPort = (
environment: Readonly<NodeJS.ProcessEnv>,
platform: NodeJS.Platform = process.platform,
): ReverseEngineeringCommandPort => ({
objdump: (input) => ({
executable: providerExecutable(
environment.REA_OBJDUMP_COMMAND ?? "objdump",
environment,
platform,
),
arguments: objdumpCommand(input),
identity: OBJDUMP_PROVIDER_IDENTITY,
environmentOverrides: { DEBUGINFOD_URLS: "" },
}),
rizin: (input) => ({
executable: providerExecutable(
environment.REA_RIZIN_COMMAND ?? "rizin",
environment,
platform,
),
arguments: rizinCommand(input),
limitations: rizinCommandLimitations(input),
rejection: rizinCommandRejection,
identity: RIZIN_PROVIDER_IDENTITY,
}),
});
const providerExecutable = (
executable: string,
environment: Readonly<NodeJS.ProcessEnv>,
platform: NodeJS.Platform,
): string =>
platform === "win32"
? resolveWindowsProviderExecutable(executable, environment)
: executable;
/** Compose BYO reverse-engineering commands without acquiring tools at import time. */
export const createReverseEngineeringService = (
environment: Readonly<NodeJS.ProcessEnv> = process.env,
options: ReverseEngineeringServiceRuntimeOptions = {},
): ReverseEngineeringService => {
const environmentSnapshot = { ...environment };
return new ReverseEngineeringService({
...options,
environment: environmentSnapshot,
commands: createReverseEngineeringCommandPort(environmentSnapshot),
});
};