fix(native): keep the resolved bundle plist and permission failures

- Carry the Info.plist that declared the program file on the target as
  bundleInfoPlist, so inspect_plist defaults to it even when the program
  file is a symlink into another bundle directory.
- Accept a readable Info.plist symlink, as reading the plist directly did.
- Treat only a missing path as an absent layout or wrapper; a permission
  denial now reaches the resolver's permission-denied classification.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-07 09:10:29 +00:00
co-authored by Claude Opus 5.5
parent aeebba391e
commit 418a5562f6
6 changed files with 118 additions and 45 deletions
+61 -1
View File
@@ -1,5 +1,5 @@
import { execFile } from "node:child_process";
import { mkdir, realpath, symlink, writeFile } from "node:fs/promises";
import { chmod, mkdir, realpath, symlink, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { promisify } from "node:util";
@@ -306,10 +306,70 @@ describe("iOS-style app bundle targets", () => {
const result = await parseBinaryTarget(app, directory, "arm64");
expect(result.ok && result.value).toMatchObject({
path: await realpath(join(app, "Flat")),
bundleInfoPlist: join(await realpath(app), "Info.plist"),
format: "mach-o",
});
});
it.skipIf(process.platform === "win32")(
"keeps the declaring Info.plist for a symlinked program file",
async () => {
const directory = await createTestTempDirectory("rea-target-");
const app = join(directory, "Linked.app");
await mkdir(join(app, "bin"), { recursive: true });
await writeFile(join(app, "Info.plist"), plist("Linked"));
await writeFile(
join(app, "bin", "real"),
thinMach(0xfeedfacf, 0x0100000c),
);
await symlink("bin/real", join(app, "Linked"));
const result = await parseBinaryTarget(app, directory, "arm64");
expect(result.ok && result.value).toMatchObject({
path: await realpath(join(app, "bin", "real")),
bundleInfoPlist: join(await realpath(app), "Info.plist"),
});
},
);
it.skipIf(process.platform === "win32")(
"follows a readable Contents/Info.plist symlink",
async () => {
const directory = await createTestTempDirectory("rea-target-");
const app = join(directory, "Linked.app");
const contents = join(app, "Contents");
await mkdir(join(contents, "MacOS"), { recursive: true });
await writeFile(join(contents, "Real.plist"), plist("Linked"));
await symlink("Real.plist", join(contents, "Info.plist"));
await writeFile(
join(contents, "MacOS", "Linked"),
thinMach(0xfeedfacf, 0x0100000c),
);
const result = await parseBinaryTarget(app, directory, "arm64");
expect(result.ok && result.value).toMatchObject({
path: await realpath(join(contents, "MacOS", "Linked")),
});
},
);
it.skipIf(process.platform === "win32" || process.getuid?.() === 0)(
"reports a wrapper it cannot read as a permission denial",
async () => {
const directory = await createTestTempDirectory("rea-target-");
const app = join(directory, "Locked.app");
const wrapper = join(app, "Wrapper");
await mkdir(join(wrapper, "Locked.app"), { recursive: true });
await chmod(wrapper, 0o000);
try {
const result = await parseBinaryTarget(app, directory, "arm64");
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected a permission denial");
expect(result.error.message).toContain("permission denied");
} finally {
await chmod(wrapper, 0o755);
}
},
);
it.skipIf(process.platform === "win32")(
"resolves an iOS-on-Mac wrapper through its single Wrapper bundle",
async () => {
@@ -279,7 +279,7 @@ describe("native macOS provider inspection", () => {
});
describe("native plist defaults for iOS-style bundles", () => {
it("defaults to the Info.plist beside a flat bundle's program file", async () => {
it("defaults to the Info.plist the bundle program was resolved from", async () => {
directory = await createTestTempDirectory("rea-native-flat-");
const app = join(directory, "Flat.app");
const executable = join(app, "Flat");
@@ -289,7 +289,10 @@ describe("native plist defaults for iOS-style bundles", () => {
const client = new NativeMacOSProvider(
new FixtureRunner(),
"darwin",
).createClient(machoTarget(executable, app));
).createClient({
...machoTarget(executable, app),
bundleInfoPlist: join(app, "Info.plist"),
});
const plist = await client.execute("inspect_plist", {});
expect(plist.ok && plist.value.result).toMatchObject({