`HOPPER_LAUNCHER_PATH` availability was decided by an `X_OK` access check alone, which a searchable directory also passes. Pointing it at the `Hopper Disassembler.app` bundle instead of its launcher made `rea providers` report Hopper as available and `rea doctor` report it healthy, while analysis then failed with an unrelated `version_unresolved` rejection. Require a regular file in both the provider availability probe and the doctor executable probe, matching the Ghidra launcher check. A directory now reports `executable_missing`, and doctor reports `config_drift` with its existing HOPPER_LAUNCHER_PATH remediation. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
import { dirname } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { parseConfig } from "../config/parseConfig.js";
|
|
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
|
|
import { silentLogger } from "../logger.js";
|
|
import { HopperProvider } from "./HopperProvider.js";
|
|
|
|
describe("Hopper provider discovery", () => {
|
|
it("reports bounded launcher availability without starting Hopper", () => {
|
|
const available = provider(process.execPath).inspectAvailability();
|
|
expect(available).toEqual({
|
|
status: "available",
|
|
code: null,
|
|
reason: null,
|
|
diagnostics: {
|
|
launcher_path: process.execPath,
|
|
platform: process.platform,
|
|
},
|
|
});
|
|
|
|
const missingPath = "/missing/rea-hopper-launcher";
|
|
expect(provider(missingPath).inspectAvailability()).toEqual({
|
|
status: "unavailable",
|
|
code: "executable_missing",
|
|
reason: `Hopper launcher is missing or not executable: ${missingPath}`,
|
|
diagnostics: {
|
|
launcher_path: missingPath,
|
|
platform: process.platform,
|
|
},
|
|
});
|
|
});
|
|
|
|
it("reports a directory launcher path as missing", () => {
|
|
const directory = dirname(process.execPath);
|
|
expect(provider(directory).inspectAvailability()).toEqual({
|
|
status: "unavailable",
|
|
code: "executable_missing",
|
|
reason: `Hopper launcher is missing or not executable: ${directory}`,
|
|
diagnostics: {
|
|
launcher_path: directory,
|
|
platform: process.platform,
|
|
},
|
|
});
|
|
});
|
|
|
|
it("separates target kind, format, and architecture support", () => {
|
|
const hopper = provider(process.execPath);
|
|
expect(hopper.inspectTargetSupport(databaseTarget())).toMatchObject({
|
|
status: "supported",
|
|
});
|
|
expect(
|
|
hopper.inspectTargetSupport(executableTarget("elf", "x86_64")),
|
|
).toMatchObject({ status: "supported" });
|
|
expect(hopper.inspectTargetSupport(artifactTarget())).toMatchObject({
|
|
status: "unsupported",
|
|
code: "target_kind_unsupported",
|
|
diagnostics: { target_kind: "archive", target_format: "asar" },
|
|
});
|
|
});
|
|
});
|
|
|
|
const provider = (launcherPath: string): HopperProvider => {
|
|
const config = parseConfig({ HOPPER_LAUNCHER_PATH: launcherPath });
|
|
if (!config.ok) throw config.error;
|
|
return new HopperProvider(config.value, silentLogger, {});
|
|
};
|
|
|
|
const databaseTarget = (): BinaryTarget => ({
|
|
path: "/tmp/fixture.hop",
|
|
sha256: "a".repeat(64),
|
|
kind: "database",
|
|
format: "analysis-database",
|
|
});
|
|
|
|
const executableTarget = (
|
|
format: "mach-o" | "elf" | "pe",
|
|
architecture: "x86" | "x86_64" | "arm" | "arm64",
|
|
): BinaryTarget =>
|
|
format === "pe"
|
|
? {
|
|
path: "/tmp/fixture",
|
|
sha256: "b".repeat(64),
|
|
kind: "executable",
|
|
format,
|
|
architecture,
|
|
availableArchitectures: [architecture],
|
|
executableRole: "application",
|
|
managed: false,
|
|
}
|
|
: {
|
|
path: "/tmp/fixture",
|
|
sha256: "b".repeat(64),
|
|
kind: "executable",
|
|
format,
|
|
architecture,
|
|
availableArchitectures: [architecture],
|
|
};
|
|
|
|
const artifactTarget = (): BinaryTarget => ({
|
|
path: "/tmp/app.asar",
|
|
sha256: "c".repeat(64),
|
|
kind: "archive",
|
|
format: "asar",
|
|
});
|