fix(apple): attribute only application-root components in macOS inventories

Directory, ZIP, and DMG inventories can hold installers, disk-image
extras, and AppleDouble sidecars beside the app. Those components were
classified as the application's frameworks, libraries, JavaScript, and
metadata, and fed runtime families and bridge candidates. For these
formats, components outside every application root are now left out,
with a limitation that counts them. IPA projection is unchanged.

A selected directory whose name ends in .app is now its own root by
identity, so an empty or partial inventory still reports it. iOS is
claimed only for shallow roots that have an Info.plist, so an empty root
reports no platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-07 10:30:47 +00:00
co-authored by Claude Opus 5.5
parent b956bd589f
commit 55249704c5
4 changed files with 123 additions and 15 deletions
+9 -10
View File
@@ -73,8 +73,12 @@ export const isWithin = (path: string, root: string): boolean =>
*/
export const applicationRoots = (
entries: readonly Entry[],
subjectName: string,
subject: { readonly name: string; readonly format: string },
): string[] => {
// A selected `.app` directory is the application, even when its inventory
// is partial or lacks Contents/; coverage and limitations describe that.
if (subject.format === "directory" && /\.app$/iu.test(subject.name))
return ["."];
const found = new Set<string>();
for (const { path } of entries) {
if (isSidecar(path)) continue;
@@ -83,13 +87,6 @@ export const applicationRoots = (
found.add(ios[1]);
continue;
}
if (
/\.app$/iu.test(subjectName) &&
/^Contents\/(?:Info\.plist|MacOS\/[^/]+)$/u.test(path)
) {
found.add(".");
continue;
}
const segments = path.split("/");
const index = segments.findIndex(
(segment, position) =>
@@ -280,13 +277,15 @@ const signingPaths = (
.filter((path) => tree.files.has(path))
.sort(compare);
/** Platforms of application roots whose layout was observed, not assumed. */
export const platformsOf = (bundles: readonly Bundle[]): ("ios" | "macos")[] =>
[
...new Set(
bundles.flatMap(({ role, layout }) => {
bundles.flatMap(({ role, layout, info_plist_path: plist }) => {
if (role !== "application") return [];
if (layout === "macos-deep") return ["macos" as const];
if (layout === "shallow") return ["ios" as const];
// An empty or partial root has no Contents/ either; require Info.plist.
if (layout === "shallow" && plist !== null) return ["ios" as const];
return [];
}),
),