fix(native): report plist permission denials as access failures
A regular plist that the host refuses to open made both plutil conversions fail, which was reported as an undecodable property list. Open the file before running plutil and report EACCES/EPERM as a target access failure naming the path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0674facd46
commit
5738a0cf8c
@@ -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 { describe, expect } from "vitest";
|
||||
@@ -67,6 +67,38 @@ describe.skipIf(process.platform !== "darwin")(
|
||||
},
|
||||
);
|
||||
|
||||
// Root bypasses file modes, so the denial is only observable otherwise.
|
||||
cliTest.skipIf(process.getuid?.() === 0)(
|
||||
"reports a permission denial instead of a malformed plist",
|
||||
async ({ cli, onTestFinished }) => {
|
||||
const app = await fixtureApp();
|
||||
const locked = join(app, "Contents/Locked.plist");
|
||||
await writeFile(locked, "<plist><dict/></plist>");
|
||||
await chmod(locked, 0o000);
|
||||
onTestFinished(async () => {
|
||||
await chmod(locked, 0o600);
|
||||
});
|
||||
const result = await cli.run({
|
||||
arguments: [
|
||||
"inspect-plist",
|
||||
app,
|
||||
"--relative-path",
|
||||
"Contents/Locked.plist",
|
||||
"--json",
|
||||
],
|
||||
environment,
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.json).toMatchObject({
|
||||
code: "target_unavailable",
|
||||
details: {
|
||||
path: locked,
|
||||
reason: "permission denied while reading plist (EACCES)",
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
cliTest(
|
||||
"reports a missing default Info.plist as unavailable for the target",
|
||||
async ({ cli }) => {
|
||||
|
||||
Reference in New Issue
Block a user