Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(hopper): treat a directory launcher path as missing (#1426)
Fazmin Nizamafdaf9811712
diff --git a/src/application/Doctor.systemHost.test.ts b/src/application/Doctor.systemHost.test.tsindex 7a160eae7..1ac033842 100644--- a/src/application/Doctor.systemHost.test.ts+++ b/src/application/Doctor.systemHost.test.ts@@ -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"],[diff --git a/src/application/Doctor.ts b/src/application/Doctor.tsindex cf6fd2a26..ecf0bcc72 100644--- a/src/application/Doctor.ts+++ b/src/application/Doctor.ts@@ -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}`);diff --git a/src/hopper/HopperProvider.ts b/src/hopper/HopperProvider.tsindex 6c314ddb6..d9c0485f0 100644--- a/src/hopper/HopperProvider.ts+++ b/src/hopper/HopperProvider.ts@@ -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,diff --git a/src/hopper/HopperProviderDiscovery.test.ts b/src/hopper/HopperProviderDiscovery.test.tsindex 65088c5c0..82acf8888 100644--- a/src/hopper/HopperProviderDiscovery.test.ts+++ b/src/hopper/HopperProviderDiscovery.test.ts@@ -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({