From 662e79330f72c2c924e60b7dea920122acc9bf08 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 24 Oct 2026 07:38:15 +0800 Subject: [PATCH] test(apple): author admitted archives and typed binary UID references --- .../interfaceBuilderHierarchyLimits.test.ts | 2 +- .../interfaceBuilderPlistNumbers.test.ts | 10 +++++---- .../keyedArchiveScalarKinds.test.ts | 22 +++++++++++-------- .../cli/keyedArchivePrototypeKeyCli.test.ts | 2 +- .../filesystem/interfaceBuilderBundle.test.ts | 20 ++++++++--------- .../keyedArchiveIntegerAmbiguity.test.ts | 1 + 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/tests/acceptance/applications/interfaceBuilderHierarchyLimits.test.ts b/tests/acceptance/applications/interfaceBuilderHierarchyLimits.test.ts index f3416938a0..c4dfb6ff0c 100644 --- a/tests/acceptance/applications/interfaceBuilderHierarchyLimits.test.ts +++ b/tests/acceptance/applications/interfaceBuilderHierarchyLimits.test.ts @@ -167,7 +167,7 @@ cliTest.for(cases)( expect(report.graph.coverage).toContainEqual({ facet: `connections:Contents/Resources/${document}`, status: "partial", - reason: "connection_limit_reached", + reason: "object_limit_reached", examined: 1, omitted: testCase.omittedConnections, }); diff --git a/tests/acceptance/applications/interfaceBuilderPlistNumbers.test.ts b/tests/acceptance/applications/interfaceBuilderPlistNumbers.test.ts index be23ba2488..93378509d8 100644 --- a/tests/acceptance/applications/interfaceBuilderPlistNumbers.test.ts +++ b/tests/acceptance/applications/interfaceBuilderPlistNumbers.test.ts @@ -49,20 +49,22 @@ cliTest.for(scenarios)( ? "CFBundleFixture" : build({ CFBundleExecutable: "Fixture" }), ); + const uid = (value: number) => + scenario === "binary" ? { UID: value } : { CF$UID: value }; const source = { $archiver: "NSKeyedArchiver", $version: 100000, - $top: { root: { CF$UID: 1 } }, + $top: { root: uid(1) }, $objects: [ "$null", { - $class: { CF$UID: 3 }, + $class: uid(3), large: scenario === "binary" ? 9007199254740992 : "__INTEGER__", safe: 42, - children: [{ CF$UID: 2 }], + children: [uid(2)], ...(scenario.includes("collision") ? { other: "__OTHER__" } : {}), }, - { $class: { CF$UID: 3 }, label: "Child" }, + { $class: uid(3), label: "Child" }, { $classname: "UIView", $classes: ["UIView", "NSObject"] }, ], }; diff --git a/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts b/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts index d2b3eb5d4f..7d9322d523 100644 --- a/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts +++ b/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts @@ -15,10 +15,12 @@ cliTest.for(["xml", "binary"] as const)( "distinguishes serialized scalar objects from lookalike dictionaries in a %s keyed archive", async (format, { cli }) => { const root = await createTestTempDirectory("rea-keyed-scalar-kinds-"); + const uid = (value: number) => + format === "binary" ? { UID: value } : { CF$UID: value }; const archive = { $archiver: "NSKeyedArchiver", $version: 100000, - $top: { root: { CF$UID: 12 }, data: { CF$UID: 1 } }, + $top: { root: uid(12), data: uid(1) }, $objects: [ "$null", Buffer.from("deadbeef", "hex"), @@ -31,8 +33,8 @@ cliTest.for(["xml", "binary"] as const)( { $plist_type: "data", base64: "3q2+7w==" }, { $plist_type: "date", iso8601: "2001-01-01T00:00:00.000Z" }, { $plist_type: "real", value: 0 }, - [{ CF$UID: 1 }], - { $class: { CF$UID: 13 }, payload: { CF$UID: 1 } }, + [uid(1)], + { $class: uid(13), payload: uid(1) }, { $classname: "ScalarHolder", $classes: ["ScalarHolder", "NSObject"] }, ], }; @@ -160,13 +162,15 @@ cliTest.for(["xml", "binary"] as const)( "keeps a negative-zero real distinct from positive zero in a %s keyed archive", async (format, { cli }) => { const root = await createTestTempDirectory("rea-keyed-signed-zero-"); + const uid = (value: number) => + format === "binary" ? { UID: value } : { CF$UID: value }; const archive = { $archiver: "NSKeyedArchiver", $version: 100000, $top: { - negative: { CF$UID: 1 }, - positive: { CF$UID: 2 }, - control: { CF$UID: 3 }, + negative: uid(1), + positive: uid(2), + control: uid(3), }, $objects: ["$null", 1.5, 0.25, 1.25], }; @@ -294,9 +298,9 @@ cliTest("preserves binary IEEE non-finite scalar identity", async ({ cli }) => { $archiver: "NSKeyedArchiver", $version: 100000, $top: { - positive: { CF$UID: 1 }, - negative: { CF$UID: 2 }, - nan: { CF$UID: 3 }, + positive: { UID: 1 }, + negative: { UID: 2 }, + nan: { UID: 3 }, }, $objects: [ "$null", diff --git a/tests/boundary/cli/keyedArchivePrototypeKeyCli.test.ts b/tests/boundary/cli/keyedArchivePrototypeKeyCli.test.ts index 1b76a91542..d730ee2326 100644 --- a/tests/boundary/cli/keyedArchivePrototypeKeyCli.test.ts +++ b/tests/boundary/cli/keyedArchivePrototypeKeyCli.test.ts @@ -62,7 +62,7 @@ cliTest( $archiver: "NSKeyedArchiver", $version: 100000, $objects: ["$null", { userID: 42 }], - $top: { main: { CF$UID: 1 } }, + $top: { main: { UID: 1 } }, }), ); for (const [name, bytes] of [ diff --git a/tests/boundary/filesystem/interfaceBuilderBundle.test.ts b/tests/boundary/filesystem/interfaceBuilderBundle.test.ts index efd40318de..76e25fb894 100644 --- a/tests/boundary/filesystem/interfaceBuilderBundle.test.ts +++ b/tests/boundary/filesystem/interfaceBuilderBundle.test.ts @@ -765,10 +765,10 @@ describe("bounded Interface Builder archive decoding", () => { : [ { classIndex: 2, - values: { - first: { ref: viewId + 2 }, - second: { ref: viewId + 2 }, - }, + values: [ + ["NS.objects", { ref: viewId + 2 }], + ["NS.objects", { ref: viewId + 2 }], + ] as const, }, ]), ]; @@ -1391,7 +1391,7 @@ describe("aggregate Interface Builder archive retention budget", () => { await mkdir(resources, { recursive: true }); const padding = ``.repeat(11 * 1024); const valid = (name: string, body = "") => - `document${name}${body}`; + `com.apple.ibtool.document.objectsviewclassNSViewdocument${name}${body}`; // XML data expands to a Uint8Array and then to a base64 JSON projection; // this first valid document exercises expansion beyond the source bytes. const expandedData = Buffer.alloc(1024 * 1024, 7).toString("base64"); @@ -1434,12 +1434,12 @@ describe("Interface Builder XML plist depth", () => { const bundle = join(root, "Example.app"); const resources = join(bundle, "Contents", "Resources"); await mkdir(resources, { recursive: true }); - // The root dict is value depth 0, so the leaf sits at `nested + 1`. The - // plist envelope and keys add XML elements but not value depth. + // Root, object table and object occupy depths 0, 1 and 2. The leaf + // sits at nested + 3; plist envelopes and keys add no value depth. const document = (nested: number) => - `${"child".repeat(nested)}leaf1${"".repeat(nested)}`; - await writeFile(join(resources, "AtLimit.nib"), document(127)); - await writeFile(join(resources, "BeyondLimit.nib"), document(128)); + `com.apple.ibtool.document.objectsviewclassNSView${"child".repeat(nested)}leaf1${"".repeat(nested)}`; + await writeFile(join(resources, "AtLimit.nib"), document(125)); + await writeFile(join(resources, "BeyondLimit.nib"), document(126)); const release = vi.spyOn(InterfaceBuilderDecodeBudget.prototype, "release"); const result = await analyzeInterfaceBuilderBundle({ diff --git a/tests/boundary/filesystem/keyedArchiveIntegerAmbiguity.test.ts b/tests/boundary/filesystem/keyedArchiveIntegerAmbiguity.test.ts index e82971926b..0dece0c63c 100644 --- a/tests/boundary/filesystem/keyedArchiveIntegerAmbiguity.test.ts +++ b/tests/boundary/filesystem/keyedArchiveIntegerAmbiguity.test.ts @@ -38,6 +38,7 @@ const fixture = async (scenario: (typeof scenarios)[number]) => { bytes = Buffer.from( buildBinary({ ...source, + $top: { root: { UID: 1 } }, $objects: ["$null", { real: 9007199254740992 }], }), );