fix(domain): report target read-permission denials as access_denied

Opening a target the current user cannot read returned
`target_unavailable`, the same code as a missing target, although the
reason named EACCES. Clients that branch on the error code could not choose
read-access recovery, contrary to the boundary contract that separates host
permission denial from unavailable targets.

A BinaryTargetError whose cause is an OS EACCES or EPERM now records that
system code and projects as `access_denied` with `system_code`, the
filesystem-read boundary, and read-access remediation, while keeping its
specific reason and path. This covers target files, app bundle paths and
Info.plist reads, and selected plist reads, since every site passes the OS
error as the cause.

Fixes #1188

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-09 03:56:38 +00:00
co-authored by Claude Opus 5.5
parent e6abaefbbc
commit d0ff57a45c
6 changed files with 84 additions and 3 deletions
@@ -22,6 +22,7 @@ import {
pe,
thinMach,
} from "../../../src/domain/binaryTarget.fixture.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
describe("binary target I/O: app plist permissions and decoding", () => {
@@ -48,6 +49,7 @@ describe("binary target I/O: app plist permissions and decoding", () => {
path: join(app, "Contents", "Info.plist"),
reason: expect.stringContaining(message),
cause: denied,
systemCode: code,
},
});
});
@@ -232,6 +234,28 @@ describe("binary target I/O: filesystem and app bundle target resolution", () =>
expect((await parseBinaryTarget("missing", directory)).ok).toBe(false);
});
it.skipIf(process.platform === "win32" || process.getuid?.() === 0)(
"reports an unreadable target as a host read denial",
async () => {
const directory = await createTestTempDirectory("rea-target-denied-");
const path = join(directory, "unreadable");
await writeFile(path, thinMach(0xcffaedfe, 0x0100000c));
await chmod(path, 0);
try {
const result = await parseBinaryTarget(path, directory, "arm64");
expect(result.ok).toBe(false);
if (result.ok) return;
expect(result.error).toMatchObject({ path, systemCode: "EACCES" });
expect(projectAnalysisError(result.error)).toMatchObject({
code: "access_denied",
details: { path, system_code: "EACCES" },
});
} finally {
await chmod(path, 0o600);
}
},
);
it("rejects non-regular targets before reading them", async () => {
const directory = await createTestTempDirectory("rea-target-");
expect((await parseBinaryTarget(directory)).ok).toBe(false);