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(windows): align path handling across Hopper, Electron, and ADB (#5235)
Reynold Hub1ff86832c63
diff --git a/src/adb/AdbDeviceOutput.test.ts b/src/adb/AdbDeviceOutput.test.tsindex cd56b7bcf..d2a32a855 100644--- a/src/adb/AdbDeviceOutput.test.ts+++ b/src/adb/AdbDeviceOutput.test.ts@@ -343,6 +343,7 @@ describe("parsePmPathOutput", () => {const devicePath = "/data/app/My App/résumé:final\\draft*.apk";const { paths, rejectedPaths, unparsedLines } = parsePmPathOutput(`package:${devicePath}\r\n`,+ "linux",);expect(paths).toEqual([{diff --git a/src/adb/AdbDeviceOutput.ts b/src/adb/AdbDeviceOutput.tsindex ec7be399c..0ac231d99 100644--- a/src/adb/AdbDeviceOutput.ts+++ b/src/adb/AdbDeviceOutput.ts@@ -246,6 +246,7 @@ export interface AdbPackagePathEntry {*/export const parsePmPathOutput = (stdout: string,+ platform: NodeJS.Platform = process.platform,): {paths: readonly AdbPackagePathEntry[];rejectedPaths: readonly {@@ -268,7 +269,7 @@ export const parsePmPathOutput = (continue;}const devicePath = match[1]!;- const validated = adbHostFileName(devicePath);+ const validated = adbHostFileName(devicePath, platform);if (!validated.ok) {rejectedPaths.push({device_path: devicePath,diff --git a/src/adb/AdbHostFileName.test.ts b/src/adb/AdbHostFileName.test.tsindex 973fcafbb..945fa8528 100644--- a/src/adb/AdbHostFileName.test.ts+++ b/src/adb/AdbHostFileName.test.ts@@ -19,7 +19,10 @@ describe("adbHostFileName", () => {["/data/local/tmp/a*b.txt", "a*b.txt"],["/data/local/tmp/re\u007fport", "re\u007fport"],])("accepts the POSIX device path %s", (devicePath, fileName) => {- expect(adbHostFileName(devicePath)).toEqual({ ok: true, fileName });+ expect(adbHostFileName(devicePath, "linux")).toEqual({+ ok: true,+ fileName,+ });});it.each([diff --git a/src/application/LinuxHopper.ts b/src/application/LinuxHopper.tsindex 3eef31531..c2175f8c2 100644--- a/src/application/LinuxHopper.ts+++ b/src/application/LinuxHopper.ts@@ -355,7 +355,12 @@ export const installLinuxHopper = async (const archiveDownload = await host.download(release.filename, options);if (!archiveDownload.ok) return { status: "failed", reason: "download" };temporary = await host.createTemporaryDirectory();- const archive = join(temporary, `hopper.${distribution.packageFamily}`);+ // Linux package paths stay POSIX even when this host is exercised from+ // a non-Linux test process.+ const archive = posix.join(+ temporary,+ `hopper.${distribution.packageFamily}`,+ );await host.writeArchive(archive, archiveDownload.bytes);const verified = await host.verifyArchive(distribution.packageFamily,@@ -452,7 +457,7 @@ export const installLinuxHopper = async (/** Canonical launcher path for a legacy user-local Linux Hopper installation. */export const linuxHopperLauncherPath = (home: string): string =>- join(home, ".local/share/rea/hopper/bin/Hopper");+ posix.join(home, ".local/share/rea/hopper/bin/Hopper");/** REA's managed Linux install path, preferred when no explicit launcher is set. */export const REA_MANAGED_LINUX_HOPPER_LAUNCHER = "/opt/hopper/bin/Hopper";diff --git a/src/application/MacHopper.ts b/src/application/MacHopper.tsindex ef13af419..20bd348d8 100644--- a/src/application/MacHopper.ts+++ b/src/application/MacHopper.ts@@ -10,7 +10,7 @@ import {writeFile,} from "node:fs/promises";import { tmpdir } from "node:os";-import { dirname, join } from "node:path";+import { join, posix } from "node:path";import { promisify } from "node:util";import { z } from "zod";@@ -160,8 +160,8 @@ export const installMacHopper = async (return { status: "failed", reason: "destination_exists" };installStage = "mount";temporary = await host.createTemporaryDirectory();- const packagePath = join(temporary, "hopper.dmg");- const mountPath = join(temporary, "mounted");+ const packagePath = posix.join(temporary, "hopper.dmg");+ const mountPath = posix.join(temporary, "mounted");await host.createMountDirectory(mountPath);await host.writePackage(packagePath, archive.bytes);if (!(await host.mount(packagePath, mountPath)))@@ -191,7 +191,7 @@ export const installMacHopper = async (: { cleanupFailure: installation.cleanupFailure }),};bundleCleanupFailure = installation.cleanupFailure;- const launcherPath = join(destination, "Contents/MacOS/hopper");+ const launcherPath = posix.join(destination, "Contents/MacOS/hopper");let openFailure: string | undefined;try {await host.openApplication(destination);@@ -215,7 +215,7 @@ export const installMacHopper = async (let cleanupFailure: string | undefined;if (temporary !== undefined) {const temporaryPath = temporary;- const mountPath = join(temporary, "mounted");+ const mountPath = posix.join(temporary, "mounted");const cleanup = async (): Promise<void> => {if (mounted) {await host.unmount(mountPath);@@ -251,9 +251,11 @@ export const installMacHopperBundle = async (operations: MacHopperBundleInstallOperations,retainCleanup: (cleanup: () => Promise<void>) => void,): Promise<MacHopperBundleInstallResult> => {- const stagingRoot = await operations.createStagingRoot(dirname(destination));- const stagedBundle = join(stagingRoot, "new.app");- const previousBundle = join(stagingRoot, "previous.app");+ const stagingRoot = await operations.createStagingRoot(+ posix.dirname(destination),+ );+ const stagedBundle = posix.join(stagingRoot, "new.app");+ const previousBundle = posix.join(stagingRoot, "previous.app");let originalBackedUp = false;let newCommitted = false;let failureReason: "copy" | "launcher_missing" = "copy";@@ -262,7 +264,7 @@ export const installMacHopperBundle = async (await operations.copyBundle(source, stagedBundle);failureReason = "launcher_missing";await operations.requireLauncher(- join(stagedBundle, "Contents/MacOS/hopper"),+ posix.join(stagedBundle, "Contents/MacOS/hopper"),);failureReason = "copy";if (replaceExisting) {@@ -369,7 +371,7 @@ export const systemMacHopperInstallHost = (const app = entries.find((entry) => entry.isDirectory() && /^Hopper.*\.app$/iu.test(entry.name),);- return app === undefined ? undefined : join(mountPath, app.name);+ return app === undefined ? undefined : posix.join(mountPath, app.name);},async validBundle(appPath) {if (@@ -412,7 +414,7 @@ export const systemMacHopperInstallHost = ({async createStagingRoot(parent) {await mkdir(parent, { recursive: true });- return mkdtemp(join(parent, ".rea-hopper-stage-"));+ return mkdtemp(posix.join(parent, ".rea-hopper-stage-"));},copyBundle: async (bundle, staged) => {await execFileAsync("ditto", [bundle, staged], {diff --git a/src/application/MacHopperPaths.test.ts b/src/application/MacHopperPaths.test.tsindex f650971db..6cab55309 100644--- a/src/application/MacHopperPaths.test.ts+++ b/src/application/MacHopperPaths.test.ts@@ -1,6 +1,6 @@import { mkdtemp, mkdir, rm } from "node:fs/promises";import { tmpdir } from "node:os";-import { join } from "node:path";+import { join, posix, relative } from "node:path";import { describe, expect, it } from "vitest";import {@@ -42,12 +42,25 @@ describe("macOS Hopper launcher paths", () => {});it("finds renamed user bundles through the runtime filesystem scan", async () => {- const temporary = await mkdtemp(join(tmpdir(), "rea-hopper-paths-"));+ // Keep native ownership for all I/O, including UNC temporary directories.+ // On Windows, a checkout-relative home models POSIX separators without+ // discarding the drive/share or normalizing a UNC prefix through posix.join.+ const root =+ process.platform === "win32" ? join(process.cwd(), "build") : tmpdir();+ await mkdir(root, { recursive: true });+ const temporary = await mkdtemp(join(root, "rea-hopper-paths-"));+ const home =+ process.platform === "win32"+ ? relative(process.cwd(), temporary).replaceAll("\\", "/")+ : temporary;const appDirectory = join(temporary, "Applications", "Hopper Preview.app");try {await mkdir(appDirectory, { recursive: true });- expect([...macHopperLauncherCandidates(temporary)]).toContain(- join(appDirectory, "Contents/MacOS/hopper"),+ expect([...macHopperLauncherCandidates(home)]).toContain(+ posix.join(+ home,+ "Applications/Hopper Preview.app/Contents/MacOS/hopper",+ ),);} finally {await rm(temporary, { recursive: true, force: true });diff --git a/src/application/MacHopperPaths.ts b/src/application/MacHopperPaths.tsindex 5ffa6ffd8..b65712f0a 100644--- a/src/application/MacHopperPaths.ts+++ b/src/application/MacHopperPaths.ts@@ -1,18 +1,18 @@import { readdirSync } from "node:fs";-import { join } from "node:path";+import { posix } from "node:path";export const MAC_HOPPER_APPLICATION_DIRECTORY = "/Applications";export const MAC_HOPPER_APPLICATION_NAME = "Hopper Disassembler.app";export const MAC_HOPPER_USER_APPLICATIONS_DIRECTORY = "Applications";-export const MAC_HOPPER_SYSTEM_LAUNCHER = join(+export const MAC_HOPPER_SYSTEM_LAUNCHER = posix.join(MAC_HOPPER_APPLICATION_DIRECTORY,MAC_HOPPER_APPLICATION_NAME,"Contents/MacOS/hopper",);export const macHopperUserApplicationPath = (homeDirectory: string): string =>- join(+ posix.join(homeDirectory,MAC_HOPPER_USER_APPLICATIONS_DIRECTORY,MAC_HOPPER_APPLICATION_NAME,@@ -22,14 +22,17 @@ export const macHopperApplicationRoots = (homeDirectory: string,): readonly string[] => [MAC_HOPPER_APPLICATION_DIRECTORY,- join(homeDirectory, MAC_HOPPER_USER_APPLICATIONS_DIRECTORY),+ posix.join(homeDirectory, MAC_HOPPER_USER_APPLICATIONS_DIRECTORY),];export const macHopperCanonicalLauncherCandidates = (homeDirectory: string,): readonly string[] => [MAC_HOPPER_SYSTEM_LAUNCHER,- join(macHopperUserApplicationPath(homeDirectory), "Contents/MacOS/hopper"),+ posix.join(+ macHopperUserApplicationPath(homeDirectory),+ "Contents/MacOS/hopper",+ ),];/** Build deterministic candidates from the discovered app bundle names. */@@ -46,7 +49,7 @@ export const macHopperRenamedLauncherCandidates = (MAC_HOPPER_APPLICATION_NAME.toLocaleLowerCase("en-US"),).sort()- .map((name) => join(root, name, "Contents/MacOS/hopper")),+ .map((name) => posix.join(root, name, "Contents/MacOS/hopper")),);const localBundleNames = (root: string): readonly string[] => {diff --git a/src/application/Setup.planning.test.ts b/src/application/Setup.planning.test.tsindex abef189bd..7992f3cbb 100644--- a/src/application/Setup.planning.test.ts+++ b/src/application/Setup.planning.test.ts@@ -1,3 +1,5 @@+import { join } from "node:path";+import { describe, expect, it } from "vitest";import { runSetup } from "./Setup.js";@@ -148,7 +150,9 @@ describe("skill plan destinations", () => {result.plannedActions.filter(({ kind }) => kind === "install_skill").map(({ target }) => target),- ).toEqual(["/fixture/home/.claude/skills/reverse-engineer-anything"]);+ ).toEqual([+ join("/fixture/home", ".claude", "skills", "reverse-engineer-anything"),+ ]);});it("plans both shared and personal skill roots for mixed clients", async () => {@@ -168,8 +172,8 @@ describe("skill plan destinations", () => {.filter(({ kind }) => kind === "install_skill").map(({ target }) => target),).toEqual([- "/fixture/home/.agents/skills/reverse-engineer-anything",- "/fixture/home/.claude/skills/reverse-engineer-anything",+ join("/fixture/home", ".agents", "skills", "reverse-engineer-anything"),+ join("/fixture/home", ".claude", "skills", "reverse-engineer-anything"),]);});});diff --git a/src/artifacts/inventory/ArtifactOccurrenceIdentity.test.ts b/src/artifacts/inventory/ArtifactOccurrenceIdentity.test.tsindex ef4df19b0..1878eabc8 100644--- a/src/artifacts/inventory/ArtifactOccurrenceIdentity.test.ts+++ b/src/artifacts/inventory/ArtifactOccurrenceIdentity.test.ts@@ -159,27 +159,30 @@ describe("content identity and occurrence facts", () => {).toHaveLength(1);});- it("reports only an occurrence permission change for identical content", async () => {- const root = await createTestTempDirectory("rea-permission-identity-");- const path = join(root, "payload.bin");- await writeFile(path, "same content\n", { mode: 0o600 });- const before = await inventoryArtifact(root);- await chmod(path, 0o700);- const after = await inventoryArtifact(root);- expect(before.nodes).toEqual(after.nodes);- expect(before.manifest.root_artifact_id).toBe(- after.manifest.root_artifact_id,- );- const oldFile = before.occurrences.find(- (item) => item.logical_path === "payload.bin",- );- const newFile = after.occurrences.find(- (item) => item.logical_path === "payload.bin",- );- expect(oldFile?.artifact_id).toBe(newFile?.artifact_id);- expect(oldFile?.executable).toBe(false);- expect(newFile?.executable).toBe(true);- });+ it.skipIf(process.platform === "win32")(+ "reports only an occurrence permission change for identical content",+ async () => {+ const root = await createTestTempDirectory("rea-permission-identity-");+ const path = join(root, "payload.bin");+ await writeFile(path, "same content\n", { mode: 0o600 });+ const before = await inventoryArtifact(root);+ await chmod(path, 0o700);+ const after = await inventoryArtifact(root);+ expect(before.nodes).toEqual(after.nodes);+ expect(before.manifest.root_artifact_id).toBe(+ after.manifest.root_artifact_id,+ );+ const oldFile = before.occurrences.find(+ (item) => item.logical_path === "payload.bin",+ );+ const newFile = after.occurrences.find(+ (item) => item.logical_path === "payload.bin",+ );+ expect(oldFile?.artifact_id).toBe(newFile?.artifact_id);+ expect(oldFile?.executable).toBe(false);+ expect(newFile?.executable).toBe(true);+ },+ );});describe("directly selected executable formats", () => {@@ -228,7 +231,7 @@ describe("directly selected executable formats", () => {sha256: expect.stringMatching(/^[a-f0-9]{64}$/u),artifact_kind: "executable",artifact_format: "mach-o",- executable: mode === 0o755,+ executable: process.platform === "win32" ? false : mode === 0o755,});expect(embedded).toEqual(direct);},diff --git a/src/electron/ElectronFusePath.ts b/src/electron/ElectronFusePath.tsindex 08aac8842..013d92fb3 100644--- a/src/electron/ElectronFusePath.ts+++ b/src/electron/ElectronFusePath.ts@@ -219,9 +219,7 @@ const resolveInside = async (: target;if (relativeTarget === null) return { kind: "escapes" };if (absoluteTarget) resolved.length = 0;- pending.unshift(- ...relativeTarget.split("/").filter((part) => part !== ""),- );+ pending.unshift(...symlinkTargetSegments(relativeTarget));continue;}if (metadata.isDirectory()) {@@ -361,3 +359,9 @@ const isMissing = (cause: unknown): boolean =>cause instanceof Error &&"code" in cause &&["ENOENT", "ENOTDIR"].includes(String(cause.code));++/** Split a relative link target using the local filesystem's separator rules. */+const symlinkTargetSegments = (target: string): readonly string[] =>+ target+ .split(process.platform === "win32" ? /[\\/]/u : "/")+ .filter((part) => part !== "");diff --git a/src/electron/ElectronFuseProvider.test.ts b/src/electron/ElectronFuseProvider.test.tsindex dbc116b11..77cb6f3c2 100644--- a/src/electron/ElectronFuseProvider.test.ts+++ b/src/electron/ElectronFuseProvider.test.ts@@ -25,6 +25,9 @@ import { readElectronFuseImage } from "./ElectronFuseReader.js";const provider = new ElectronFuseProvider();+const symlinkDirectory = (target: string, path: string): Promise<void> =>+ symlink(target, path, process.platform === "win32" ? "dir" : undefined);+const inspect = async (path: string) => {const result = await provider.inspect({ path });if (!result.ok) throw result.error;@@ -265,7 +268,7 @@ describe("Electron fuse path and container admission", () => {await mkdir(join(versions, "A"), { recursive: true });const binary = join(versions, "A", "Electron Framework");await writeFile(binary, image.bytes);- await symlink("A", join(versions, "Current"));+ await symlinkDirectory("A", join(versions, "Current"));await symlink("Versions/Current/Electron Framework",join(versions, "..", "Electron Framework"),@@ -471,6 +474,40 @@ describe("direct Electron Framework binary selection", () => {});});+ it.runIf(process.platform === "win32")(+ "walks a backslash-separated Windows link target before accepting a file",+ async () => {+ const { app, framework } = await frameworkFixture(+ "rea-electron-fuses-nested-escape-backslash-",+ );+ const versions = join(framework, "Versions");+ await mkdir(join(app, "Contents", "Other", "subdir"), {+ recursive: true,+ });+ await writeFile(+ join(app, "Contents", "Other", "subdir", "Electron Framework"),+ elfFuseImage([ELECTRON_FUSE_STATE_BYTES.enabled]).bytes,+ );+ await symlinkDirectory("../../../Other", join(versions, "nested"));+ await symlinkDirectory("nested\\subdir", join(versions, "Current"));++ const result = await provider.inspect({+ path: join(versions, "Current", "Electron Framework"),+ });+ expect(result.ok).toBe(false);+ if (result.ok) return;+ expect(result.error).toMatchObject({+ _tag: "AnalysisInputError",+ issues: [+ expect.objectContaining({+ path: ["path"],+ message: expect.stringContaining("escapes"),+ }),+ ],+ });+ },+ );+it("rejects a framework directory that is a symlink outside the bundle", async () => {const root = await createTestTempDirectory("rea-electron-fuses-framework-link-",@@ -771,7 +808,7 @@ it("follows the active framework binary while an inactive A version remains", asthinFuseImage([state]).bytes,);}- await symlink("B", join(framework, "Versions", "Current"));+ await symlinkDirectory("B", join(framework, "Versions", "Current"));await symlink("Versions/Current/Electron Framework",join(framework, "Electron Framework"),diff --git a/src/ghidra/GhidraLanguageOverride.test.ts b/src/ghidra/GhidraLanguageOverride.test.tsindex bb9b071f4..5ac8a1a73 100644--- a/src/ghidra/GhidraLanguageOverride.test.ts+++ b/src/ghidra/GhidraLanguageOverride.test.ts@@ -1,6 +1,6 @@import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";-import { join } from "node:path";+import { join, parse, relative } from "node:path";import { afterAll, beforeAll, describe, expect, it } from "vitest";import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";import { parseConfig } from "../config/parseConfig.js";@@ -79,14 +79,25 @@ const legacyMips: BinaryTarget = {};let installDir = "";+let ownedInstallDir = "";beforeAll(async () => {- installDir = await mkdtemp(join(tmpdir(), "rea-ghidra-languages-"));+ const root =+ process.platform === "win32" ? join(process.cwd(), "build") : tmpdir();+ await mkdir(root, { recursive: true });+ ownedInstallDir = await mkdtemp(join(root, "rea-ghidra-languages-"));+ // The simulated Linux host needs a POSIX absolute path. Keep the owned+ // native path for cleanup and derive the simulated path on the same drive.+ installDir =+ process.platform === "win32"+ ? `/${relative(parse(ownedInstallDir).root, ownedInstallDir).replaceAll("\\", "/")}`+ : ownedInstallDir;const languages = join(installDir, "Ghidra/Processors/x86/data/languages");await mkdir(languages, { recursive: true });await writeFile(join(languages, "x86.ldefs"), X86_LDEFS);});afterAll(async () => {- await rm(installDir, { recursive: true, force: true });+ if (ownedInstallDir !== "")+ await rm(ownedInstallDir, { recursive: true, force: true });});const provider = (environment: Record<string, string>) => {diff --git a/src/ghidra/GhidraPowerPcProfile.test.ts b/src/ghidra/GhidraPowerPcProfile.test.tsindex a830f4aee..72fb0ac54 100644--- a/src/ghidra/GhidraPowerPcProfile.test.ts+++ b/src/ghidra/GhidraPowerPcProfile.test.ts@@ -1,7 +1,7 @@-import { mkdir, writeFile } from "node:fs/promises";-import { join } from "node:path";-import { describe, expect, it } from "vitest";-import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";+import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join, parse, relative } from "node:path";+import { describe, expect, it, onTestFinished } from "vitest";import { parseConfig } from "../config/parseConfig.js";import type {BinaryTarget,@@ -76,7 +76,19 @@ describe("bounded Ghidra PowerPC admission", () => {});it("lets a configured language replace the lane default", async () => {- const installDir = await createTestTempDirectory("rea-ghidra-ppc-");+ const root =+ process.platform === "win32" ? join(process.cwd(), "build") : tmpdir();+ await mkdir(root, { recursive: true });+ const ownedInstallDir = await mkdtemp(join(root, "rea-ghidra-ppc-"));+ onTestFinished(async () => {+ await rm(ownedInstallDir, { recursive: true, force: true });+ });+ // The simulated Linux host needs a POSIX absolute path. Keep the owned+ // native path for cleanup and derive the simulated path on the same drive.+ const installDir =+ process.platform === "win32"+ ? `/${relative(parse(ownedInstallDir).root, ownedInstallDir).replaceAll("\\", "/")}`+ : ownedInstallDir;const languages = join(installDir,"Ghidra/Processors/PowerPC/data/languages",diff --git a/src/ghidra/GhidraSnapshotCache.test.ts b/src/ghidra/GhidraSnapshotCache.test.tsindex 134a9f214..f77eade89 100644--- a/src/ghidra/GhidraSnapshotCache.test.ts+++ b/src/ghidra/GhidraSnapshotCache.test.ts@@ -4,6 +4,7 @@ import { describe, expect, it } from "vitest";import { createTestBinarySession } from "../../tests/fixtures/binarySession.js";import { parseConfig } from "../config/parseConfig.js";+import type { AnalysisOperation } from "../application/AnalysisProvider.js";import type { BinaryTarget } from "../domain/binaryTargetTypes.js";import { functionDossierSchema } from "../domain/hopperValues.js";import { createAnalysisProfile } from "../domain/analysisProfile.js";@@ -167,6 +168,35 @@ const open = async (session: ReturnType<typeof fixture>["session"]) => {expect((await session.openResolvedTarget(preview.value)).ok).toBe(true);};+/**+ * Windows must admit the native source with a live operation before it may+ * replay an imported query. Use a different query so the imported entry is+ * still the one under test.+ */+const admitWindowsNativeSource = async (+ replay: ReturnType<typeof fixture>,+ operation: AnalysisOperation,+): Promise<AnalysisOperation | undefined> => {+ if (process.platform !== "win32") return undefined;+ const admission =+ operation === "read_binary_inventory_summary"+ ? {+ operation: "analyze_function" as const,+ parameters: { procedure: "0xlive" },+ }+ : {+ operation: "read_binary_inventory_summary" as const,+ parameters: {},+ };+ const admitted = await replay.session.execute(+ admission.operation,+ admission.parameters,+ );+ if (!admitted.ok) throw admitted.error;+ expect(replay.calls).toEqual([admission.operation]);+ return admission.operation;+};+describe("Ghidra relationship coverage replay", () => {it("retains degraded Evidence without replaying transient failures after recovery or import", async () => {const initial = fixture();@@ -242,11 +272,19 @@ describe("Ghidra relationship coverage replay", () => {const snapshot = initial.session.exportAnalysisSnapshot();if (!snapshot.ok) throw snapshot.error;await initial.session.close();- const replay = fixture();+ const liveCoverage: RelationshipCoverage = {+ status: "unknown",+ reason: "live fixture must not be replayed",+ };+ const replay = fixture("12.1.4", liveCoverage);expect(replay.session.importAnalysisSnapshot(snapshot.value).ok).toBe(true,);await open(replay.session);+ const admittedOperation = await admitWindowsNativeSource(+ replay,+ "analyze_function",+ );const execution = await replay.session.execute("analyze_function",parameters,@@ -255,7 +293,14 @@ describe("Ghidra relationship coverage replay", () => {expect(execution.value.relationshipCoverage ?? undefined).toEqual(coverage,);- expect(replay.calls).toEqual([]);+ expect(execution.value.limitations).toEqual(+ expect.arrayContaining([+ expect.stringContaining("local REA analysis snapshot"),+ ]),+ );+ expect(replay.calls).toEqual(+ admittedOperation === undefined ? [] : [admittedOperation],+ );await replay.session.close();},);@@ -376,11 +421,25 @@ describe("Ghidra snapshot cache", () => {true,);await open(replay.session);+ const admittedOperation = await admitWindowsNativeSource(+ replay,+ operation,+ );const imported = await replay.session.execute(operation, parameters);+ expect(imported).toMatchObject({+ ok: true,+ value: {+ limitations: expect.arrayContaining([+ expect.stringContaining("local REA analysis snapshot"),+ ]),+ },+ });expect(imported.ok && imported.value.result).toEqual(first.ok && first.value.result,);- expect(replay.calls).toEqual([]);+ expect(replay.calls).toEqual(+ admittedOperation === undefined ? [] : [admittedOperation],+ );await replay.session.close();const changed = fixture("12.1.5");diff --git a/src/hopper/HopperProviderDiscovery.test.ts b/src/hopper/HopperProviderDiscovery.test.tsindex 5df7eacad..7180d5b11 100644--- a/src/hopper/HopperProviderDiscovery.test.ts+++ b/src/hopper/HopperProviderDiscovery.test.ts@@ -8,42 +8,59 @@ 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,- },- });+ it.skipIf(process.platform === "win32")(+ "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,- },- });- });+ 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.skipIf(process.platform === "win32")(+ "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.runIf(process.platform === "win32")(+ "reports Hopper integration as unsupported on Windows",+ () => {+ expect(provider(process.execPath).inspectAvailability()).toMatchObject({+ status: "unavailable",+ code: "unsupported_host",+ diagnostics: { platform: "win32" },+ });+ },+ );it("separates target kind, format, and architecture support", () => {const hopper = provider(process.execPath, "linux");diff --git a/src/hopper/HopperTargetLease.test.ts b/src/hopper/HopperTargetLease.test.tsindex 1408edaa2..3170d09d6 100644--- a/src/hopper/HopperTargetLease.test.ts+++ b/src/hopper/HopperTargetLease.test.ts@@ -32,6 +32,8 @@ afterEach(async () => {);});+const describePosix = describe.skipIf(process.platform === "win32");+describe.skipIf(process.platform === "win32")("Hopper lease directory admission",() => {@@ -110,7 +112,7 @@ describe.skipIf(process.platform === "win32")(},);-describe("Hopper target leases", () => {+describePosix("Hopper target leases", () => {it("reports the owning REA session for a duplicate target and profile", async () => {const directory = await temporaryDirectory();const targetPath = await temporaryTarget();@@ -220,7 +222,7 @@ describe("Hopper target leases", () => {);});-describe("Linux Hopper application leases", () => {+describePosix("Linux Hopper application leases", () => {it("reserves the shared application until its owner releases it", async () => {const directory = await temporaryDirectory();const first = await acquireLinuxHopperApplicationLease({@@ -272,7 +274,10 @@ describe("Linux Hopper application leases", () => {await once(server, "listening");try {await expect(- acquireLinuxHopperApplicationLease({ directory, runId: "new-owner" }),+ acquireLinuxHopperApplicationLease({+ directory,+ runId: "new-owner",+ }),).rejects.toMatchObject({_tag: "HopperStartError",userMessage: expect.stringContaining("left unchanged"),@@ -342,29 +347,32 @@ describe("Linux Hopper application leases", () => {});});-it("leaves a stale socket unchanged while another process reserves its recovery", async () => {- const directory = await temporaryDirectory();- const socketPath = await releasedApplicationSocket(directory);- await leaveStaleSocket(socketPath);- const recoveryPath = `${socketPath}.recovery`;- await mkdir(recoveryPath, { mode: 0o700 });- const stale = await lstat(socketPath);- await expect(- acquireLinuxHopperApplicationLease({ directory, runId: "competing" }),- ).rejects.toMatchObject({- _tag: "HopperStartError",- userMessage: expect.stringContaining(recoveryPath),- });- expect((await lstat(socketPath)).ino).toBe(stale.ino);- await rmdir(recoveryPath);- const recovered = await acquireLinuxHopperApplicationLease({- directory,- runId: "after-recovery",- });- expect(recovered.acquired).toBe(true);- if (recovered.acquired) await recovered.lease.release();- expect(await readdir(directory)).toEqual([]);-});+it.skipIf(process.platform === "win32")(+ "leaves a stale socket unchanged while another process reserves its recovery",+ async () => {+ const directory = await temporaryDirectory();+ const socketPath = await releasedApplicationSocket(directory);+ await leaveStaleSocket(socketPath);+ const recoveryPath = `${socketPath}.recovery`;+ await mkdir(recoveryPath, { mode: 0o700 });+ const stale = await lstat(socketPath);+ await expect(+ acquireLinuxHopperApplicationLease({ directory, runId: "competing" }),+ ).rejects.toMatchObject({+ _tag: "HopperStartError",+ userMessage: expect.stringContaining(recoveryPath),+ });+ expect((await lstat(socketPath)).ino).toBe(stale.ino);+ await rmdir(recoveryPath);+ const recovered = await acquireLinuxHopperApplicationLease({+ directory,+ runId: "after-recovery",+ });+ expect(recovered.acquired).toBe(true);+ if (recovered.acquired) await recovered.lease.release();+ expect(await readdir(directory)).toEqual([]);+ },+);const leaveStaleSocket = async (socketPath: string): Promise<void> => {await promisify(execFile)(process.execPath, [diff --git a/src/wasm/WabtArtifactProvider.test.ts b/src/wasm/WabtArtifactProvider.test.tsindex 546ce0844..54f7f9751 100644--- a/src/wasm/WabtArtifactProvider.test.ts+++ b/src/wasm/WabtArtifactProvider.test.ts@@ -1,6 +1,6 @@import { createHash } from "node:crypto";import { access, chmod, readFile, realpath, writeFile } from "node:fs/promises";-import { join } from "node:path";+import { join, resolve } from "node:path";import { expect, it, onTestFinished, vi } from "vitest";import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";import { WabtArtifactProvider } from "./WabtArtifactProvider.js";@@ -13,6 +13,23 @@ import { projectAnalysisError } from "../domain/analysisErrorProjection.js";import { WABT_LIMITS } from "./WabtRelease.js";import { wabtFailure } from "./WabtFailures.js";+const nodeHostEnvironment = (+ environment: NodeJS.ProcessEnv | undefined,+): NodeJS.ProcessEnv => ({+ ...environment,+ // Node's Windows CSPRNG initialization requires SystemRoot; the captured+ // provider environment intentionally omits unrelated host variables.+ ...(process.env.SystemRoot === undefined+ ? {}+ : { SystemRoot: process.env.SystemRoot }),+});++function samePath(left: string, right: string): boolean {+ return process.platform === "win32"+ ? resolve(left).toLowerCase() === resolve(right).toLowerCase()+ : left === right;+}+const fileCloseFailure = vi.hoisted(() => ({selectedPath: "",attempts: 0,@@ -26,7 +43,8 @@ vi.mock("node:fs/promises", async (importOriginal) => {...fs,open: async (...args: Parameters<typeof fs.open>) => {const handle = await fs.open(...args);- if (String(args[0]) !== fileCloseFailure.selectedPath) return handle;+ if (!samePath(String(args[0]), fileCloseFailure.selectedPath))+ return handle;const close = handle.close.bind(handle);const failure = fileCloseFailure.failRead;if (failure !== undefined) {@@ -222,7 +240,14 @@ const assertModeOutcome = (elseexpect(result).toMatchObject({ok: false,- error: { _tag: failureTags[mode] },+ error: {+ _tag:+ process.platform === "win32" &&+ (mode === "snapshot-close-failure" ||+ mode === "snapshot-read-failure-late-abort")+ ? "ProviderAdapterError"+ : failureTags[mode],+ },});if (mode === "invalid" || mode === "invalid-close")expect(result).toMatchObject({@@ -310,6 +335,7 @@ it.each([const selected = input.command === join(root, tool + suffix);return spawnOwnedProviderProcess({...input,+ hostEnvironment: nodeHostEnvironment(input.hostEnvironment),command: process.execPath,arguments: ["-e",@@ -354,9 +380,11 @@ it("retries a retained input descriptor before admitting the next WABT operationconst path = join(root, "selected.wasm");await writeFile(path, Buffer.alloc(76, 1));for (const tool of ["wasm-validate", "wasm-objdump", "wasm2wat"])- await writeFile(join(root, tool), "source-owned executable seam", {- mode: 0o700,- });+ await writeFile(+ join(root, tool + (process.platform === "win32" ? ".exe" : "")),+ "source-owned executable seam",+ { mode: 0o700 },+ );const dump = await readFile(new URL("../../tests/fixtures/wasm/objdump.txt", import.meta.url),"utf8",@@ -374,6 +402,7 @@ it("retries a retained input descriptor before admitting the next WABT operation: "";const launched = await spawnOwnedProviderProcess({...input,+ hostEnvironment: nodeHostEnvironment(input.hostEnvironment),command: process.execPath,arguments: ["-e",@@ -560,6 +589,7 @@ const launchWabtOutcome = async (: `process.stdout.write(${JSON.stringify(stdout)}); process.stderr.write(${JSON.stringify(stderr)}); process.exit(${invalid ? 1 : 0});`;const launched = await spawnOwnedProviderProcess({...input,+ hostEnvironment: nodeHostEnvironment(input.hostEnvironment),command: process.execPath,arguments: ["-e", script],expectedCommand: null,@@ -581,6 +611,7 @@ it("enforces a selected command deadline and completes a corrected retry after cfirst = false;return spawnOwnedProviderProcess({...input,+ hostEnvironment: nodeHostEnvironment(input.hostEnvironment),command: process.execPath,arguments: ["-e",@@ -646,6 +677,55 @@ const glueSourcesForOutcome = (mode: OutcomeMode) => {: [];};+const assertSnapshotCleanupOutcome = async (+ mode: OutcomeMode,+ result: Awaited<ReturnType<WabtArtifactProvider["inspect"]>>,+ provider: WabtArtifactProvider,+ runtimePath: string,+): Promise<void> => {+ if (+ mode !== "snapshot-close-failure" &&+ mode !== "snapshot-read-failure-late-abort"+ )+ return;+ try {+ expect(result).toMatchObject({+ error: {+ cleanupIncomplete: true,+ cleanupResources:+ process.platform === "win32"+ ? expect.arrayContaining([join(runtimePath, "module.wasm")])+ : [join(runtimePath, "module.wasm")],+ },+ });+ } finally {+ fileCloseFailure.failFirst = false;+ fileCloseFailure.failRead = undefined;+ await provider.close();+ fileCloseFailure.selectedPath = "";+ }+ expect(result).toMatchObject({+ error: { cleanupIncomplete: false, cleanupResources: [] },+ });+ if (!result.ok && mode === "snapshot-read-failure-late-abort") {+ if (process.platform === "win32")+ expect(result.error).toMatchObject({+ diagnostics: {+ primary_error: {+ details: {+ reason: expect.stringContaining("Authored snapshot read failure"),+ },+ },+ },+ });+ else+ expect(result.error).toMatchObject({+ _tag: "AnalysisOutputError",+ reason: expect.stringContaining("Authored snapshot read failure"),+ });+ }+};+const runOwnedArtifactOutcome = async (mode: OutcomeMode,cancellationReason: unknown = "authored finalization cancellation",@@ -755,32 +835,7 @@ const runOwnedArtifactOutcome = async (result,() => cleanupAttempts,);- if (- mode === "snapshot-close-failure" ||- mode === "snapshot-read-failure-late-abort"- ) {- try {- expect(result).toMatchObject({- error: {- cleanupIncomplete: true,- cleanupResources: [join(runtimePath, "module.wasm")],- },- });- } finally {- fileCloseFailure.failFirst = false;- fileCloseFailure.failRead = undefined;- await provider.close();- fileCloseFailure.selectedPath = "";- }- expect(result).toMatchObject({- error: { cleanupIncomplete: false, cleanupResources: [] },- });- if (!result.ok && mode === "snapshot-read-failure-late-abort")- expect(result.error).toMatchObject({- _tag: "AnalysisOutputError",- reason: expect.stringContaining("Authored snapshot read failure"),- });- }+ await assertSnapshotCleanupOutcome(mode, result, provider, runtimePath);await expect(access(runtimePath)).rejects.toMatchObject({ code: "ENOENT" });expect(await readFile(path)).toEqual(bytes);if (acquiredPid !== undefined) {@@ -856,6 +911,7 @@ it("reports WABT output beyond the budget as a resource constraint with a bounde: "";return spawnOwnedProviderProcess({...input,+ hostEnvironment: nodeHostEnvironment(input.hostEnvironment),command: process.execPath,arguments: ["-e", script],expectedCommand: null,@@ -920,6 +976,7 @@ it("does not attribute wasm-objdump output to a wasm2wat launch failure", async: "";return spawnOwnedProviderProcess({...input,+ hostEnvironment: nodeHostEnvironment(input.hostEnvironment),command: process.execPath,arguments: ["-e", script],expectedCommand: null,diff --git a/tests/composition/reverseEngineering.test.ts b/tests/composition/reverseEngineering.test.tsindex f703d3d91..e54c6b758 100644--- a/tests/composition/reverseEngineering.test.ts+++ b/tests/composition/reverseEngineering.test.ts@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";import type { Stats } from "node:fs";import { mkdtemp, rm, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";-import { isAbsolute, join, relative } from "node:path";+import { isAbsolute, join, relative, resolve } from "node:path";import { PassThrough } from "node:stream";import { describe, expect, it } from "vitest";@@ -56,7 +56,7 @@ describe("reverse engineering command services", () => {if (!result.ok) return;expect(calls).toEqual([{- command: "/tools/objdump",+ command: resolve("/tools/objdump"),args: ["-W", "-WK", path],env: expect.objectContaining({ DEBUGINFOD_URLS: "" }),},@@ -266,7 +266,7 @@ it("uses one selected environment snapshot for provider selection and execution"expect(result.ok).toBe(true);expect(calls).toEqual([{- command: "/selected/rizin",+ command: resolve("/selected/rizin"),env: {REA_RIZIN_COMMAND: "/selected/rizin",PATH: "/selected/bin",@@ -389,7 +389,7 @@ describe("Rizin command service", () => {);expect(calls).toEqual([{- command: "/tools/rizin",+ command: resolve("/tools/rizin"),args: ["-N", "-q", "-e", "scr.color=0", "-c", command, lookupPath],},]);@@ -412,7 +412,7 @@ describe("Rizin command service", () => {expect(result.value.parameters).toMatchObject({path: callerPath,command,- provider_executable: "/tools/rizin",+ provider_executable: resolve("/tools/rizin"),});expect(result.value.parameters.command_arguments).toEqual(calls[0]?.args);expect(result.value.provider.id).toBe("rizin");