Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
test: share native keyed archive integer fixture generation
morluto847a1a3f25f6
diff --git a/tests/boundary/filesystem/keyedArchiveNativeIntegers.test.ts b/tests/boundary/filesystem/keyedArchiveNativeIntegers.test.tsindex 9ba2583e7..4508c05fa 100644--- a/tests/boundary/filesystem/keyedArchiveNativeIntegers.test.ts+++ b/tests/boundary/filesystem/keyedArchiveNativeIntegers.test.ts@@ -1,14 +1,36 @@-import { describe, it, expect } from "vitest";+import { describe, expect } from "vitest";import { inspectBundleKeyedArchive } from "../../../src/artifacts/apple/KeyedArchiveReader.js";import { keyedArchiveResultSchema } from "../../../src/domain/apple/keyedArchive.js";import { parseEvidence } from "../../../src/domain/evidence.js";import {keyedArchiveIntegerFormats,keyedArchiveIntegerCases,- keyedArchiveIntegerFixture,+ keyedArchiveIntegerFixtures,expectKeyedArchiveIntegerCase,+ type KeyedArchiveIntegerFixtures,} from "../../fixtures/keyedArchiveIntegers.js";import { cliTest } from "../../support/cli/cliFixture.js";+import {+ createTestWorkspace,+ removeTestWorkspace,+} from "../../support/workspace/workspaceFixture.js";++const archiveTest = cliTest.extend<{+ $worker: { keyedArchiveIntegerArchives: KeyedArchiveIntegerFixtures };+}>({+ keyedArchiveIntegerArchives: [+ // oxlint-disable-next-line no-empty-pattern -- Vitest parses fixture dependencies from object destructuring.+ async ({}, use) => {+ const workspace = await createTestWorkspace("rea-keyed-integers-");+ try {+ await use(await keyedArchiveIntegerFixtures(workspace.root));+ } finally {+ await removeTestWorkspace(workspace.root);+ }+ },+ { scope: "worker" },+ ],+});const cases = keyedArchiveIntegerFormats.flatMap((format) =>keyedArchiveIntegerCases.map((selectedCase) => ({ format, selectedCase })),@@ -17,10 +39,10 @@ const cases = keyedArchiveIntegerFormats.flatMap((format) =>describe.skipIf(process.platform !== "darwin")("Foundation archive integer precision",() => {- it.each(cases)(+ archiveTest.for(cases)("filesystem preserves $format $selectedCase numeric meaning",- async ({ format, selectedCase }) => {- const fixture = await keyedArchiveIntegerFixture(format);+ async ({ format, selectedCase }, { keyedArchiveIntegerArchives }) => {+ const fixture = keyedArchiveIntegerArchives[format];const result = await inspectBundleKeyedArchive({bundlePath: fixture.root,targetSha256: fixture.digest,@@ -34,10 +56,13 @@ describe.skipIf(process.platform !== "darwin")();},);- cliTest.for(cases)(+ archiveTest.for(cases)("built CLI preserves $format $selectedCase numeric meaning",- async ({ format, selectedCase }, { cli }) => {- const fixture = await keyedArchiveIntegerFixture(format);+ async (+ { format, selectedCase },+ { cli, keyedArchiveIntegerArchives },+ ) => {+ const fixture = keyedArchiveIntegerArchives[format];const output = await cli.run({arguments: ["inspect-keyed-archive", fixture.archivePath, "--json"],environment: {diff --git a/tests/fixtures/keyedArchiveIntegers.ts b/tests/fixtures/keyedArchiveIntegers.tsindex 239319ad0..11f543751 100644--- a/tests/fixtures/keyedArchiveIntegers.ts+++ b/tests/fixtures/keyedArchiveIntegers.ts@@ -7,7 +7,6 @@ import { promisify } from "node:util";import { expect } from "vitest";import { z } from "zod";import { keyedArchiveResultSchema } from "../../src/domain/apple/keyedArchive.js";-import { createTestTempDirectory } from "./temporaryDirectory.js";const rowSchema = z.object({container: z.enum(["roots", "objects"]),@@ -25,11 +24,22 @@ const archiveSchema = z.object({const oracleSchema = z.object({ xml: archiveSchema, binary: archiveSchema });export const keyedArchiveIntegerFormats = ["xml", "binary"] as const;export const keyedArchiveIntegerCases = ["controls", "unsafe"] as const;-type Format = (typeof keyedArchiveIntegerFormats)[number];type Case = (typeof keyedArchiveIntegerCases)[number];type Row = z.infer<typeof rowSchema>;-export const keyedArchiveIntegerFixture = async (format: Format) => {- const root = await createTestTempDirectory("rea-keyed-integers-");+type SelectedFixture = {+ readonly root: string;+ readonly selected: z.infer<typeof archiveSchema>;+ readonly archivePath: string;+ readonly digest: string;+};+export interface KeyedArchiveIntegerFixtures {+ readonly xml: SelectedFixture;+ readonly binary: SelectedFixture;+}++export const keyedArchiveIntegerFixtures = async (+ root: string,+): Promise<KeyedArchiveIntegerFixtures> => {await promisify(execFile)("/usr/bin/xcrun",[@@ -76,12 +86,19 @@ export const keyedArchiveIntegerFixture = async (format: Format) => {),).toBe(true);}- const selected = oracle[format];- const archivePath = join(root, selected.filename);- const bytes = await readFile(archivePath);- const digest = createHash("sha256").update(bytes).digest("hex");- expect(digest).toBe(selected.sha256);- return { root, selected, archivePath, digest };+ const selectedFixture = async (+ selected: z.infer<typeof archiveSchema>,+ ): Promise<SelectedFixture> => {+ const archivePath = join(root, selected.filename);+ const bytes = await readFile(archivePath);+ const digest = createHash("sha256").update(bytes).digest("hex");+ expect(digest).toBe(selected.sha256);+ return { root, selected, archivePath, digest };+ };+ return {+ xml: await selectedFixture(oracle.xml),+ binary: await selectedFixture(oracle.binary),+ };};const at = (value: unknown, path: Row["path"]): unknown => {for (const key of path) {