fix(hopper): treat a directory launcher path as missing (#1426)
`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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
944981d8d5
commit
afdaf98117
@@ -1,5 +1,5 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
@@ -46,6 +46,18 @@ it("threads the selected host and environment into system diagnostics", async ()
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not report a directory as an available executable", async () => {
|
||||
const host = systemDoctorHost({
|
||||
platform: "darwin",
|
||||
architecture: "arm64",
|
||||
environment: {},
|
||||
execFileOutput: () => Promise.reject(new Error("unexpected command")),
|
||||
});
|
||||
|
||||
await expect(host.executable(dirname(process.execPath))).resolves.toBe(false);
|
||||
await expect(host.executable(process.execPath)).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ default: { appdir: "/Applications" } }, "/Applications"],
|
||||
[
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { constants } from "node:fs";
|
||||
import { access, readdir } from "node:fs/promises";
|
||||
import { access, readdir, stat } from "node:fs/promises";
|
||||
import { homeDirectoryFromEnvironment } from "../config/homeDirectory.js";
|
||||
import { join } from "node:path";
|
||||
|
||||
@@ -472,6 +472,7 @@ const executableAvailable = async (
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
await access(path, constants.X_OK);
|
||||
if (!(await stat(path)).isFile()) return false;
|
||||
if (platform !== "linux") return true;
|
||||
const linked = await run("ldd", [path], options);
|
||||
return linuxSharedLibrariesAvailable(`${linked.stdout}\n${linked.stderr}`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { accessSync, constants } from "node:fs";
|
||||
import { accessSync, constants, statSync } from "node:fs";
|
||||
|
||||
import { createAnalysisExecution } from "../application/AnalysisProvider.js";
|
||||
import type {
|
||||
@@ -75,6 +75,9 @@ export class HopperProvider implements AnalysisProviderCandidate {
|
||||
};
|
||||
try {
|
||||
accessSync(this.config.hopperLauncherPath, constants.X_OK);
|
||||
// A searchable directory, such as an .app bundle, also passes X_OK.
|
||||
if (!statSync(this.config.hopperLauncherPath).isFile())
|
||||
throw new TypeError("Hopper launcher is not a regular file");
|
||||
return {
|
||||
status: "available",
|
||||
code: null,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { dirname } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseConfig } from "../config/parseConfig.js";
|
||||
@@ -30,6 +32,19 @@ describe("Hopper provider discovery", () => {
|
||||
});
|
||||
});
|
||||
|
||||
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({
|
||||
|
||||
Reference in New Issue
Block a user