fix(artifacts): decode flat keyed-archive NIBs with data and shared references
decode_interface_builder failed on every flat (keyed-archive) NIB that holds plist data or dates. Archived colors keep their components as data, so this covers nearly every AppKit NIB: XLD.app decoded 0 of 64. The decoded Uint8Array and Date values failed JSON validation. They now use the shared plist projection, which keeps them as explicit $plist_type values. Decoding those archives exposed a second failure. The keyed-archive parser inlined every UID reference up to 16 levels for every object, so an archive whose views reference their window, superview, and next key view expanded exponentially. A 9 KB NIB took 3 s, and a 158 KB MainMenu.nib did not finish. A reference now resolves to its string, or to a stub naming the referenced object's archive UID, authored ID, and class. The hierarchy walk visits each object once. The parser also reads XML CF$UID references and treats UID 0 as nil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
faaee693d5
commit
2a4667bb79
@@ -71,6 +71,48 @@ describe("compiled Interface Builder bundle reader", () => {
|
||||
);
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user