Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(native): retain spaced symbols in dyld inventory (#669)

Rudy Mizrahi Celeklifa02df9ad3bc
diff --git a/src/native/parsers/dyldInfo.ts b/src/native/parsers/dyldInfo.ts
index 8db9b832a..d981cef9d 100644
--- a/src/native/parsers/dyldInfo.ts
+++ b/src/native/parsers/dyldInfo.ts
@@ -17,7 +17,7 @@ export const parseDyldSymbols = (
const line = rawLine.trim();
if (mode === "imports") {
const imported =
- /^(?:0x[\da-f]+\s+)?(\S+)(?:\s+\[([^\]]+)\])?\s+\(from (.+)\)$/iu.exec(
+ /^(?:0x[\da-f]+\s+)?(.+?)(?:\s+\[([^\]]+)\])?\s+\(from (.+)\)$/iu.exec(
line,
);
if (imported?.[1] !== undefined)
@@ -32,7 +32,7 @@ export const parseDyldSymbols = (
];
return [];
}
- const reexport = /^\[re-export\]\s+(\S+)(?:\s+\(from (.+)\))?$/u.exec(line);
+ const reexport = /^\[re-export\]\s+(.+?)(?:\s+\(from (.+)\))?$/u.exec(line);
if (reexport?.[1] !== undefined)
return [
{
@@ -43,7 +43,7 @@ export const parseDyldSymbols = (
source: reexport[2] ?? null,
},
];
- const exported = /^(0x[\da-f]+)\s+(\S+)(?:\s+\[([^\]]+)\])?$/iu.exec(line);
+ const exported = /^(0x[\da-f]+)\s+(.+?)(?:\s+\[([^\]]+)\])?$/iu.exec(line);
if (exported?.[1] === undefined || exported[2] === undefined) return [];
const absolute = /\babsolute\b/u.test(exported[3] ?? "");
const address =
diff --git a/tests/boundary/providers/native/nativeInventory.golden.test.ts b/tests/boundary/providers/native/nativeInventory.golden.test.ts
index 91448c9fe..e8671f710 100644
--- a/tests/boundary/providers/native/nativeInventory.golden.test.ts
+++ b/tests/boundary/providers/native/nativeInventory.golden.test.ts
@@ -115,3 +115,54 @@ it("retains native inventory facts from captured Apple tool output", async () =>
source: null,
});
});
+
+it("retains symbol names containing spaces in dyld inventory rows", () => {
+ expect(
+ parseDyldSymbols(" 0x0000 _entry with space (from fixture)", "imports"),
+ ).toEqual([
+ {
+ name: "_entry with space",
+ address: null,
+ weak: null,
+ reexport: null,
+ source: "fixture",
+ },
+ ]);
+ expect(
+ parseDyldSymbols(
+ " offset symbol\n 0x00000348 _entry with space",
+ "exports",
+ "0x0",
+ ),
+ ).toEqual([
+ {
+ name: "_entry with space",
+ address: "0x348",
+ weak: null,
+ reexport: false,
+ source: null,
+ },
+ ]);
+ expect(
+ parseDyldSymbols("[re-export] _entry with space (from fixture)", "exports"),
+ ).toEqual([
+ {
+ name: "_entry with space",
+ address: null,
+ weak: null,
+ reexport: true,
+ source: "fixture",
+ },
+ ]);
+ expect(
+ parseDyldSymbols("0x123 _weak with space [weak-def]", "exports"),
+ ).toEqual([
+ {
+ name: "_weak with space",
+ address: "0x123",
+ weak: true,
+ reexport: false,
+ source: null,
+ },
+ ]);
+});