mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
test(apple): author admitted archives and typed binary UID references
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
@@ -49,20 +49,22 @@ cliTest.for(scenarios)(
|
||||
? "<plist><dict><key>CFBundle<![CDATA[Executable]]></key><string>Fixture</string></dict></plist>"
|
||||
: 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"] },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 [
|
||||
|
||||
@@ -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 = `<!--${"x".repeat(1024)}-->`.repeat(11 * 1024);
|
||||
const valid = (name: string, body = "") =>
|
||||
`<?xml version="1.0"?><plist version="1.0"><dict><key>document</key><string>${name}</string>${body}</dict></plist>`;
|
||||
`<?xml version="1.0"?><plist version="1.0"><dict><key>com.apple.ibtool.document.objects</key><dict><key>view</key><dict><key>class</key><string>NSView</string><key>document</key><string>${name}</string>${body}</dict></dict></dict></plist>`;
|
||||
// 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) =>
|
||||
`<?xml version="1.0"?><plist version="1.0"><dict>${"<key>child</key><dict>".repeat(nested)}<key>leaf</key><integer>1</integer>${"</dict>".repeat(nested)}</dict></plist>`;
|
||||
await writeFile(join(resources, "AtLimit.nib"), document(127));
|
||||
await writeFile(join(resources, "BeyondLimit.nib"), document(128));
|
||||
`<?xml version="1.0"?><plist version="1.0"><dict><key>com.apple.ibtool.document.objects</key><dict><key>view</key><dict><key>class</key><string>NSView</string>${"<key>child</key><dict>".repeat(nested)}<key>leaf</key><integer>1</integer>${"</dict>".repeat(nested)}</dict></dict></dict></plist>`;
|
||||
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({
|
||||
|
||||
@@ -38,6 +38,7 @@ const fixture = async (scenario: (typeof scenarios)[number]) => {
|
||||
bytes = Buffer.from(
|
||||
buildBinary({
|
||||
...source,
|
||||
$top: { root: { UID: 1 } },
|
||||
$objects: ["$null", { real: 9007199254740992 }],
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user