Merge branch 'feat/dylib-resolution' into feat/dyld-shared-cache
Carry #952's Apple ownership into the cache work: the cache reader and fixture move to src/artifacts/apple/, the cache facts, platforms and resolution schema to src/domain/apple/, the cache service to src/application/apple/, and the lane to scripts/verify/apple/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,9 +10,9 @@ import {
|
||||
dylibCommand,
|
||||
machoImage,
|
||||
rpathCommand,
|
||||
} from "../../../src/artifacts/MachoImage.fixture.js";
|
||||
import { dyldCacheFixture } from "../../../src/artifacts/DyldSharedCache.fixture.js";
|
||||
import { dylibResolutionResultSchema } from "../../../src/domain/dylibResolution.js";
|
||||
} from "../../../src/artifacts/apple/MachoImage.fixture.js";
|
||||
import { dyldCacheFixture } from "../../../src/artifacts/apple/DyldSharedCache.fixture.js";
|
||||
import { dylibResolutionResultSchema } from "../../../src/domain/apple/dylibResolution.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
dyldCacheFixture,
|
||||
type CacheFixture,
|
||||
} from "../../../src/artifacts/DyldSharedCache.fixture.js";
|
||||
} from "../../../src/artifacts/apple/DyldSharedCache.fixture.js";
|
||||
import {
|
||||
FILE_TYPE,
|
||||
LC,
|
||||
dylibCommand,
|
||||
dylibUseCommand,
|
||||
machoImage,
|
||||
} from "../../../src/artifacts/MachoImage.fixture.js";
|
||||
} from "../../../src/artifacts/apple/MachoImage.fixture.js";
|
||||
import {
|
||||
inspectDyldSharedCache,
|
||||
inspectDyldSharedCacheEvidence,
|
||||
} from "../../../src/application/DyldSharedCacheService.js";
|
||||
import { dyldSharedCacheResultSchema } from "../../../src/domain/dyldSharedCache.js";
|
||||
} from "../../../src/application/apple/DyldSharedCacheService.js";
|
||||
import { dyldSharedCacheResultSchema } from "../../../src/domain/apple/dyldSharedCache.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
const dylib = (installName: string, dependencies: readonly Uint8Array[] = []) =>
|
||||
|
||||
@@ -7,8 +7,8 @@ import { promisify } from "node:util";
|
||||
import { buildBinary } from "plist";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { analyzeInterfaceBuilderBundle } from "../../../src/application/InterfaceBuilderAnalysis.js";
|
||||
import { encodeNibArchiveFixture } from "../../../src/artifacts/NibArchive.fixture.js";
|
||||
import { analyzeInterfaceBuilderBundle } from "../../../src/artifacts/apple/InterfaceBuilderAnalysis.js";
|
||||
import { encodeNibArchiveFixture } from "../../../src/artifacts/apple/NibArchive.fixture.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
const compile = promisify(execFile);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { decodeKeyedArchiveBytes } from "../../../src/artifacts/KeyedArchiveReader.js";
|
||||
import { decodeKeyedArchiveBytes } from "../../../src/artifacts/apple/KeyedArchiveReader.js";
|
||||
import {
|
||||
parseAppleAssetCatalogRecords,
|
||||
projectAppleAssetCatalogPage,
|
||||
} from "../../../src/domain/appleAssetCatalog.js";
|
||||
} from "../../../src/domain/apple/appleAssetCatalog.js";
|
||||
|
||||
const golden = (path: string) =>
|
||||
new URL(`../../fixtures/golden/${path}`, import.meta.url);
|
||||
|
||||
@@ -6,8 +6,8 @@ import { promisify } from "node:util";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { decodeNibArchive } from "../../../src/artifacts/NibArchive.js";
|
||||
import { analyzeInterfaceBuilderBundle } from "../../../src/application/InterfaceBuilderAnalysis.js";
|
||||
import { decodeNibArchive } from "../../../src/artifacts/apple/NibArchive.js";
|
||||
import { analyzeInterfaceBuilderBundle } from "../../../src/artifacts/apple/InterfaceBuilderAnalysis.js";
|
||||
|
||||
const compile = promisify(execFile);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
import { parseConfig } from "../../../src/config.js";
|
||||
import { createBinarySession } from "../../../src/application/runtime.js";
|
||||
import { keyedArchiveResultSchema } from "../../../src/domain/keyedArchive.js";
|
||||
import { keyedArchiveResultSchema } from "../../../src/domain/apple/keyedArchive.js";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
|
||||
@@ -5,14 +5,14 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { dyldCacheFixture } from "../../../src/artifacts/DyldSharedCache.fixture.js";
|
||||
import { dyldCacheFixture } from "../../../src/artifacts/apple/DyldSharedCache.fixture.js";
|
||||
import {
|
||||
FILE_TYPE,
|
||||
LC,
|
||||
dylibCommand,
|
||||
machoImage,
|
||||
} from "../../../src/artifacts/MachoImage.fixture.js";
|
||||
import { dyldSharedCacheResultSchema } from "../../../src/domain/dyldSharedCache.js";
|
||||
} from "../../../src/artifacts/apple/MachoImage.fixture.js";
|
||||
import { dyldSharedCacheResultSchema } from "../../../src/domain/apple/dyldSharedCache.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { chmod, mkdir, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
dylibCommand,
|
||||
machoImage,
|
||||
rpathCommand,
|
||||
} from "../../../src/artifacts/MachoImage.fixture.js";
|
||||
import { dylibResolutionResultSchema } from "../../../src/domain/dylibResolution.js";
|
||||
} from "../../../src/artifacts/apple/MachoImage.fixture.js";
|
||||
import { dylibResolutionResultSchema } from "../../../src/domain/apple/dylibResolution.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
@@ -159,3 +159,37 @@ it("traces a standalone Mach-O file whose name ends in .app", async () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it.skipIf(process.getuid?.() === 0)(
|
||||
"keeps a permission denied while canonicalizing the opened bundle",
|
||||
async () => {
|
||||
const parent = await createTestTempDirectory("rea-dylib-mcp-revoked-");
|
||||
const app = join(parent, "Revoked.app");
|
||||
await mkdir(join(app, "Contents/MacOS"), { recursive: true });
|
||||
await writeFile(
|
||||
join(app, "Contents/Info.plist"),
|
||||
"<plist><dict><key>CFBundleExecutable</key><string>App</string></dict></plist>",
|
||||
);
|
||||
await writeFile(join(app, "Contents/MacOS/App"), machoImage({}));
|
||||
await withClient(async (client) => {
|
||||
const opened = await client.callTool({
|
||||
name: "open_binary",
|
||||
arguments: { path: app },
|
||||
});
|
||||
expect(opened.isError, JSON.stringify(opened)).not.toBe(true);
|
||||
await chmod(parent, 0o000);
|
||||
try {
|
||||
const called = await client.callTool({
|
||||
name: "trace_dylib_resolution",
|
||||
arguments: {},
|
||||
});
|
||||
expect(called.isError).toBe(true);
|
||||
expect(JSON.stringify(called.structuredContent)).toMatch(
|
||||
/Permission denied \(EACCES\)/u,
|
||||
);
|
||||
} finally {
|
||||
await chmod(parent, 0o755);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { join } from "node:path";
|
||||
import { buildBinary, parse } from "plist";
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { inspectBundleKeyedArchive } from "../../../../src/artifacts/KeyedArchiveReader.js";
|
||||
import { inspectBundleKeyedArchive } from "../../../../src/artifacts/apple/KeyedArchiveReader.js";
|
||||
import { nativeFixture } from "../../../fixtures/nativeCommands.js";
|
||||
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import {
|
||||
requireSuccessfulProjection,
|
||||
} from "../../support/applicationSessionFixture.js";
|
||||
|
||||
import { projectAppleApplicationEvidence } from "../../../src/application/AppleApplicationService.js";
|
||||
import { projectAppleApplicationEvidence } from "../../../src/application/apple/AppleApplicationService.js";
|
||||
import { runProviderAnalysis } from "../../../src/application/DirectAnalysis.js";
|
||||
import { appleApplicationProjectionResultSchema } from "../../../src/domain/appleApplication.js";
|
||||
import { appleApplicationProjectionResultSchema } from "../../../src/domain/apple/appleApplication.js";
|
||||
import { parseEvidence } from "../../../src/domain/evidence.js";
|
||||
|
||||
// Real ZIP entries cross the former component and bridge-candidate limits.
|
||||
|
||||
@@ -272,3 +272,22 @@ describe("test lane import boundaries", () => {
|
||||
if (!allowed) expect(result.stdout).toContain("no-restricted-imports");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Apple artifact producer ownership", () => {
|
||||
it.each([
|
||||
["../../application/Workflow.js", false],
|
||||
["../../composition/android.js", false],
|
||||
["../../cli.js", false],
|
||||
["../../domain/apple/plistValue.js", true],
|
||||
["../DirectoryArtifactReader.js", true],
|
||||
])("checks the producer dependency %s", (dependency, allowed) => {
|
||||
const violations = inspectModuleBoundaries(
|
||||
"src/artifacts/apple/probe.ts",
|
||||
`import type { Value } from ${JSON.stringify(dependency)};`,
|
||||
process.cwd(),
|
||||
);
|
||||
|
||||
expect(violations.length === 0).toBe(allowed);
|
||||
if (!allowed) expect(violations[0]?.boundary).toBe("artifact-acquisition");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user