Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(managed): verify Mach-O ABI-prefixed exports exactly (#3974)

Hahaa9095875fce66693
diff --git a/src/domain/managed/managedNativeVerificationMatch.ts b/src/domain/managed/managedNativeVerificationMatch.ts
index 49cb0cdf3..ef7c81747 100644
--- a/src/domain/managed/managedNativeVerificationMatch.ts
+++ b/src/domain/managed/managedNativeVerificationMatch.ts
@@ -100,11 +100,13 @@ export const collectNativeSymbols = (
return { symbols, accepted, unsupported };
};
-const sameSymbolName = (expected: string, native: NativeSymbol): boolean =>
- expected ===
- (native.source === "macho-export" && native.name.startsWith("_")
+const normalizedSymbolName = (native: NativeSymbol): string =>
+ native.source === "macho-export" && native.name.startsWith("_")
? native.name.slice(1)
- : native.name);
+ : native.name;
+
+const sameSymbolName = (expected: string, native: NativeSymbol): boolean =>
+ expected === normalizedSymbolName(native);
const normalizeModule = (value: string): string =>
basename(value)
@@ -203,7 +205,7 @@ const matchPinvoke = (
managed.import_scope_name.trim().length > 0;
const exact = candidates.find(
(symbol) =>
- managed.import_name === symbol.name &&
+ managed.import_name === normalizedSymbolName(symbol) &&
moduleCompatible(managed.import_scope_name, symbol),
);
const decorated = candidates.find((symbol) =>
diff --git a/tests/conformance/providers/managed/managedNativeVerification.test.ts b/tests/conformance/providers/managed/managedNativeVerification.test.ts
index 6427853bf..b15c720fd 100644
--- a/tests/conformance/providers/managed/managedNativeVerification.test.ts
+++ b/tests/conformance/providers/managed/managedNativeVerification.test.ts
@@ -162,6 +162,20 @@ it("verifies a P/Invoke declaration against native export Evidence", () => {
});
});
+it("treats a Mach-O ABI-prefixed export as an exact declared import", () => {
+ const result = verifyManagedNativeBoundaries({
+ ...exampleInput(),
+ native_observations: [nativeEvidenceWithExports(["_open_native"])],
+ });
+
+ expect(result.summary).toMatchObject({ verified: 1, inferred: 0 });
+ expect(result.pinvoke_imports[0]).toMatchObject({
+ status: "verified",
+ basis: "exact-export-name",
+ matched_native: { name: "_open_native" },
+ });
+});
+
it("reports module mismatch as a contradiction within supplied Evidence", () => {
const input = exampleInput();
const native = input.native_observations[0];