fix(artifacts): flag truncated Mach-O headers and keep canonicalization denials
- A file with a recognized Mach-O or FAT magic but fewer than 8 bytes is a malformed image, so it stays visible in coverage and root diagnostics. - Canonicalize the analyzed root and target inside the translated region, so a permission revoked after open_binary keeps its reason and path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e5c6fccc35
commit
9a487a4e00
@@ -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";
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user