* fix: bind identity and coverage to the producing rule Logical paths, container families, examined bytes, path-segment conventions, destination collisions, file-id leases, Mach-O CPU selection, and firmware cleanup now follow the observation that owns each rule. * fix: fail unmatched Mach-O slices and keep firmware roots independent A fat target whose architecture lipo did not list now stops before slice tools run. Chained fixups still count unread LC_DYLD_INFO rebase bytes, and a firmware cleanup failure no longer blocks the next workspace. * test: cover path identity and runtime families at the projection boundary NFC joins and segment conventions are now asserted by the path resolver, the Apple projection, and a real APK inventory instead of helper unit tests. * test: expect unread dyld rebase bytes in the Apple dispatch fixture The legacy LC_DYLD_INFO fixture keeps a rebase range this reader does not decode, so the public CLI and MCP check now requires that partial coverage beside the bind opcodes. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import { AsarArtifactReader } from "../AsarArtifactReader.js";
|
|
import type { ArtifactReader } from "../ArtifactReader.js";
|
|
import { DirectoryArtifactReader } from "../DirectoryArtifactReader.js";
|
|
import { MachOSliceArtifactReader } from "../MachOSliceArtifactReader.js";
|
|
import { NativeDmgArtifactReader } from "../NativeDmgArtifactReader.js";
|
|
import { ZipArtifactReader } from "../ZipArtifactReader.js";
|
|
import type { ArtifactOccurrence } from "../../domain/artifactGraph.js";
|
|
import { ZIP_NON_ENTRY_TAIL_LIMITATION } from "../../domain/zipPackageFormat.js";
|
|
|
|
export const createReader = async (
|
|
path: string,
|
|
format: ArtifactOccurrence["artifact_format"],
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
signal?: AbortSignal,
|
|
): Promise<ArtifactReader | undefined> => {
|
|
switch (format) {
|
|
case "directory":
|
|
return new DirectoryArtifactReader(path);
|
|
case "zip":
|
|
case "ipa":
|
|
case "apk":
|
|
case "msix":
|
|
case "appx":
|
|
return new ZipArtifactReader(path, format);
|
|
case "asar":
|
|
return new AsarArtifactReader(path);
|
|
case "mach-o-universal":
|
|
return process.platform === "darwin"
|
|
? new MachOSliceArtifactReader(path, environment)
|
|
: undefined;
|
|
case "dmg":
|
|
if (process.platform !== "darwin") return undefined;
|
|
return NativeDmgArtifactReader.create(path, environment, signal);
|
|
default:
|
|
return undefined;
|
|
}
|
|
};
|
|
|
|
export const inventoryLimitations = (
|
|
format: ArtifactOccurrence["artifact_format"],
|
|
reader: ArtifactReader | undefined,
|
|
): string[] => {
|
|
if (reader !== undefined)
|
|
return reader.format === "zip" ||
|
|
reader.format === "ipa" ||
|
|
reader.format === "apk" ||
|
|
reader.format === "msix" ||
|
|
reader.format === "appx"
|
|
? [ZIP_NON_ENTRY_TAIL_LIMITATION]
|
|
: [];
|
|
// dmg and pkg reach here only after classifyRootFormat matched their bytes.
|
|
if (format === "dmg" || format === "pkg")
|
|
return [
|
|
`${format.toUpperCase()} root hash is observed; child inventory requires a native macOS adapter.`,
|
|
];
|
|
if (format === "mach-o-universal" && process.platform !== "darwin")
|
|
return ["Universal Mach-O slices require the native macOS lipo adapter."];
|
|
return ["Artifact has no child container entries."];
|
|
};
|