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(native): match compound otool keys exactly and badge unknown thread entrypoints (#534)
morlutod40502aa3b9a
diff --git a/src/native/NativeMachoInspection.ts b/src/native/NativeMachoInspection.tsindex 177a11b9d..e82c61ad3 100644--- a/src/native/NativeMachoInspection.ts+++ b/src/native/NativeMachoInspection.ts@@ -106,6 +106,16 @@ const normalizeMacho = (/UUID:\s*([A-Fa-f0-9-]+)/u.exec(byTool("dwarfdump").stdout)?.[1] ??load.uuid;const provenance = captures.map(toInvocation);+ // A thread-state command carries the entrypoint in architecture-specific+ // register state, so an absent decoded offset means unknown, not absent.+ const threadEntrypoint =+ load.entrypoints.length === 0 &&+ load.commands.some(+ (command) =>+ command.kind === "LC_UNIXTHREAD" || command.kind === "LC_THREAD",+ );+ const threadEntrypointLimitation =+ "Thread-state entrypoints (LC_UNIXTHREAD/LC_THREAD) are retained as raw load commands; file offsets are not derived.";const limitations = ["Imports and exports combine dyld_info and nm; stripped or toolchain-hidden symbols may be absent.",...(captures.some(({ tool }) => tool === "vtool")@@ -114,15 +124,7 @@ const normalizeMacho = (]: []),...additionalLimitations,- ...(load.entrypoints.length === 0 &&- load.commands.some(- (command) =>- command.kind === "LC_UNIXTHREAD" || command.kind === "LC_THREAD",- )- ? [- "Thread-state entrypoints (LC_UNIXTHREAD/LC_THREAD) are retained as raw load commands; file offsets are not derived.",- ]- : []),+ ...(threadEntrypoint ? [threadEntrypointLimitation] : []),...(imageBase === null &&/^\s*offset\s+symbol\s*$/mu.test(byTool("dyld_info", 1).stdout)? [@@ -137,7 +139,11 @@ const normalizeMacho = (file_type: load.fileType,flags: load.flags,uuid: uuid ?? null,- entrypoints: covered(load.entrypoints, true),+ entrypoints: covered(+ load.entrypoints,+ !threadEntrypoint,+ threadEntrypoint ? [threadEntrypointLimitation] : [],+ ),architectures: covered(architectures, true),build_metadata: covered(load.builds, true),load_commands: covered(load.commands, true),diff --git a/src/native/parsers/otool.ts b/src/native/parsers/otool.tsindex 8c237040a..9ed20f114 100644--- a/src/native/parsers/otool.ts+++ b/src/native/parsers/otool.ts@@ -188,7 +188,11 @@ const parseFields = (block: string): Record<string, string | number | null> => {const fields: Record<string, string | number | null> = {};for (const rawLine of block.split(/\r?\n/u).slice(1)) {const line = rawLine.trim();- const match = /^(\S+(?:\s+(?:version|stamp))?)\s+(.+)$/u.exec(line);+ // Keys are `token` or a compound `token version`. `time stamp` is the one+ // other real key, and it must be matched as a whole: treating `stamp` as a+ // generic suffix would swallow an install name such as+ // `name stamp plugin.dylib`, hiding the dependency path behind `unknown`.+ const match = /^((?:time stamp)|\S+(?:\s+version)?)\s+(.+)$/u.exec(line);if (match?.[1] === undefined || match[2] === undefined) continue;const value = match[2].trim();fields[match[1]] = numeric(value) ?? value;diff --git a/tests/boundary/providers/native/nativeLoadKinds.golden.test.ts b/tests/boundary/providers/native/nativeLoadKinds.golden.test.tsindex 409d99314..b25cb3de0 100644--- a/tests/boundary/providers/native/nativeLoadKinds.golden.test.ts+++ b/tests/boundary/providers/native/nativeLoadKinds.golden.test.ts@@ -27,6 +27,31 @@ it("retains lazily loaded library dependencies", () => {});});+it("preserves dependency install names that begin with the word stamp", () => {+ const load = parseOtoolLoadCommands(+ [+ "Load command 2",+ " cmd LC_LOAD_DYLIB",+ " name stamp plugin.dylib (offset 24)",+ " time stamp 2 Thu Jan 1 00:00:02 1970",+ " current version 1.0.0",+ "compatibility version 1.0.0",+ "",+ ].join("\n"),+ );+ expect(load.dependencies).toContainEqual({+ path: "stamp plugin.dylib",+ kind: "LC_LOAD_DYLIB",+ current_version: "1.0.0",+ compatibility_version: "1.0.0",+ });+ expect(+ load.commands.find((command) => command.kind === "LC_LOAD_DYLIB")?.fields[+ "time stamp"+ ],+ ).toMatch(/^2 Thu Jan/);+});+it("normalizes legacy version-minimum commands into build metadata", () => {const load = parseOtoolLoadCommands([@@ -77,7 +102,14 @@ it("limits thread-state entrypoints instead of reporting none silently", async (expect(result.ok).toBe(true);if (!result.ok) return;expect(result.value.result).toMatchObject({- entrypoints: { items: [] },+ entrypoints: {+ items: [],+ total: null,+ exhaustive: false,+ limitations: [+ "Thread-state entrypoints (LC_UNIXTHREAD/LC_THREAD) are retained as raw load commands; file offsets are not derived.",+ ],+ },});expect(result.value.limitations).toContain("Thread-state entrypoints (LC_UNIXTHREAD/LC_THREAD) are retained as raw load commands; file offsets are not derived.",