Skip to content

armgit / rea

Public Imported from GitHub
0

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

chore: merge main and preserve plist and AppKit regressions

morluto071cfd1bb6a7
diff --cc tests/boundary/filesystem/interfaceBuilderBundle.test.ts
index 5b8db634c,a68503b3a..0885aeea4
--- a/tests/boundary/filesystem/interfaceBuilderBundle.test.ts
+++ b/tests/boundary/filesystem/interfaceBuilderBundle.test.ts
@@@ -71,62 -72,98 +72,142 @@@ describe("compiled Interface Builder bu
);
});
+ it("projects compiled AppKit actions from the control to their target", async () => {
+ const root = await createTestTempDirectory("rea-ib-test-");
+ const bundle = join(root, "Example.app");
+ const resources = join(bundle, "Contents", "Resources");
+ await mkdir(resources, { recursive: true });
+ // NSNibControlConnector archives the sending control as NSSource and its
+ // target as NSDestination; a nil target is the first responder.
+ await writeFile(
+ join(resources, "Panel.nib"),
+ encodeNibArchiveFixture({
+ classes: [
+ "NSNibExternalObjectPlaceholder",
+ "NSButton",
+ "NSNibControlConnector",
+ "NSString",
+ "NSMenuItem",
+ ],
+ objects: [
+ { classIndex: 0, values: {} },
+ { classIndex: 1, values: {} },
+ {
+ classIndex: 2,
+ values: {
+ NSSource: { ref: 1 },
+ NSDestination: { ref: 0 },
+ NSLabel: { ref: 3 },
+ },
+ },
+ { classIndex: 3, values: { "NS.bytes": "doOK:" } },
+ { classIndex: 4, values: {} },
+ {
+ classIndex: 2,
+ values: {
+ NSSource: { ref: 4 },
+ NSDestination: null,
+ NSLabel: { ref: 6 },
+ },
+ },
+ { classIndex: 3, values: { "NS.bytes": "arrangeInFront:" } },
+ ],
+ }),
+ );
+
+ const analysis = await analyzeInterfaceBuilderBundle({
+ bundlePath: bundle,
+ targetSha256: "e".repeat(64),
+ });
+ const byId = new Map(analysis.graph.nodes.map((node) => [node.id, node]));
+ const routes = analysis.graph.nodes
+ .filter(({ kind }) => kind === "action")
+ .map((action) => ({
+ action: action.name,
+ from: analysis.graph.edges
+ .filter(
+ ({ relation, to }) =>
+ relation === "target_action" && to === action.id,
+ )
+ .map(({ from }) => byId.get(from)?.name),
+ to: analysis.graph.edges
+ .filter(
+ ({ relation, from, to }) =>
+ relation === "target_action" &&
+ from === action.id &&
+ (to === null || byId.get(to)?.kind !== "objc_selector"),
+ )
+ .map(({ to }) => (to === null ? null : byId.get(to)?.name)),
+ }))
+ .sort((left, right) => left.action.localeCompare(right.action));
+ expect(routes).toEqual([
+ { action: "arrangeInFront:", from: ["NSMenuItem"], to: [null] },
+ {
+ action: "doOK:",
+ from: ["NSButton"],
+ to: ["NSNibExternalObjectPlaceholder"],
+ },
+ ]);
+ });
+
+ it("honors cancellation during directory traversal", async () => {
+ const root = await createTestTempDirectory("rea-ib-test-");
+ const controller = new AbortController();
+ controller.abort();
+ await expect(
+ analyzeInterfaceBuilderBundle({
+ bundlePath: root,
+ targetSha256: "c".repeat(64),
+ signal: controller.signal,
+ }),
+ ).rejects.toMatchObject({ reason: "cancelled" });
+ });
+ });
+
++describe("flat Interface Builder plist values", () => {
+ it("decodes flat nib archives that hold data and date values", async () => {
+ const root = await createTestTempDirectory("rea-ib-test-");
+ const bundle = join(root, "Example.app");
+ const resources = join(bundle, "Contents", "Resources", "English.lproj");
+ await mkdir(resources, { recursive: true });
+ await writeFile(
+ join(resources, "Binary.nib"),
+ buildBinary({
+ $archiver: "NSKeyedArchiver",
+ $version: 100000,
+ $objects: [
+ "$null",
+ { $class: { UID: 2 }, title: "Build", NSColor: { UID: 3 } },
+ { $classname: "NSButton", $classes: ["NSButton", "NSObject"] },
+ { $class: { UID: 4 }, NSWhite: Buffer.from("0.5\0", "ascii") },
+ { $classname: "NSColor", $classes: ["NSColor", "NSObject"] },
+ ],
+ $top: { root: { UID: 1 } },
+ }),
+ );
+ await writeFile(
+ join(resources, "Xml.nib"),
+ '<?xml version="1.0"?><plist version="1.0"><dict><key>$archiver</key><string>NSKeyedArchiver</string><key>$objects</key><array><string>$null</string><dict><key>NSWhite</key><data>MC41AA==</data><key>NSDate</key><date>2026-10-07T00:00:00Z</date></dict></array><key>$top</key><dict/></dict></plist>',
+ );
+
+ const analysis = await analyzeInterfaceBuilderBundle({
+ bundlePath: bundle,
+ targetSha256: "d".repeat(64),
+ });
+
+ expect(
+ analysis.documents.map(({ relative_path }) => relative_path).sort(),
+ ).toEqual([
+ "Contents/Resources/English.lproj/Binary.nib",
+ "Contents/Resources/English.lproj/Xml.nib",
+ ]);
+ expect(analysis.graph.coverage).toContainEqual(
+ expect.objectContaining({ facet: "archive_decode", status: "complete" }),
+ );
+ expect(analysis.graph.nodes.map(({ name }) => name)).toContain("Build");
+ });
-
- it("honors cancellation during directory traversal", async () => {
- const root = await createTestTempDirectory("rea-ib-test-");
- const controller = new AbortController();
- controller.abort();
- await expect(
- analyzeInterfaceBuilderBundle({
- bundlePath: root,
- targetSha256: "c".repeat(64),
- signal: controller.signal,
- }),
- ).rejects.toMatchObject({ reason: "cancelled" });
- });
+});
+
describe("bounded Interface Builder archive decoding", () => {
it("counts malformed archives against the document limit", async () => {
const root = await createTestTempDirectory("rea-ib-test-");