Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(domain): keep a decoded Swift alias category beside undecoded aliases (#4085)

Kaoru082282763824dc76
diff --git a/src/domain/symbolAnalysis.test.ts b/src/domain/symbolAnalysis.test.ts
index 2afa88bf2..995b69987 100644
--- a/src/domain/symbolAnalysis.test.ts
+++ b/src/domain/symbolAnalysis.test.ts
@@ -136,4 +136,34 @@ describe("Swift alias ambiguity", () => {
]);
expect(result.categories.other?.items).toEqual([]);
});
+
+ it.each([undefined, "classes"] as const)(
+ "keeps a decoded alias category beside an undecoded Swift alias (filter %s)",
+ (category) => {
+ const result = categorizeSwiftTypes(
+ [{ address: "0x1", name: "main::Service::init" }],
+ category === undefined ? {} : { category },
+ [
+ { address: "0x1", name: "_$s4main7ServiceCMa" },
+ { address: "0x1", name: "_$s4main04PairVMa" },
+ ],
+ );
+ expect(result).toMatchObject({
+ total: 1,
+ categories: {
+ classes: {
+ count: 1,
+ items: [
+ {
+ name: "main::Service::init",
+ mangled_names: ["_$s4main7ServiceCMa", "_$s4main04PairVMa"],
+ },
+ ],
+ },
+ other: { count: 0 },
+ },
+ unclassified: [],
+ });
+ },
+ );
});
diff --git a/src/domain/symbolAnalysis.ts b/src/domain/symbolAnalysis.ts
index 173dd99f9..3f0841df4 100644
--- a/src/domain/symbolAnalysis.ts
+++ b/src/domain/symbolAnalysis.ts
@@ -115,13 +115,13 @@ export const categorizeSwiftTypes = (
![entry.name, ...mangledNames].some((name) => name.includes(pattern))
)
continue;
- // Only decoded names vote. Unresolved aliases remain evidence without
- // erasing category evidence from a name the decoder did recognize.
- const kinds = new Set(
- mangledNames
- .filter((name) => classifySwiftSymbol(name) !== undefined)
- .map((name) => classifySwiftSymbol(name)?.category ?? null),
- );
+ // Only decoded categories vote. A Swift-looking alias whose category is
+ // not decoded remains evidence without erasing a decoded category.
+ const kinds = new Set<SwiftTypeCategory>();
+ for (const name of mangledNames) {
+ const decoded = classifySwiftSymbol(name)?.category;
+ if (decoded !== undefined && decoded !== null) kinds.add(decoded);
+ }
const category = kinds.size === 1 ? ([...kinds][0] ?? null) : null;
const item = {
address: entry.address,
@@ -133,9 +133,7 @@ export const categorizeSwiftTypes = (
unclassified.push({
...item,
reason:
- kinds.size > 1 && !kinds.has(null)
- ? "conflicting_categories"
- : "category_not_decoded",
+ kinds.size > 1 ? "conflicting_categories" : "category_not_decoded",
});
}
const bucket = category ?? "other";