fix(artifacts): defer lazy loads and tighten Mach-O validation
Address review findings in trace_dylib_resolution: - Resolve LC_LAZY_LOAD_DYLIB dependencies without traversing them, since dyld loads them on first use. An unresolved one becomes `lazy-load-unresolved`, not a launch failure. - Accept FAT tables up to 128 records, as target opening does. A table that names no Mach-O CPU type, such as a Java class file, is not Mach-O. - Require 8-byte load-command alignment in 64-bit images. 1,508 real slices still match otool. - Report EACCES/EPERM while probing, reading, or hashing as an `unavailable` failure naming the code and path, rather than generic io. Findings and limitations move to dylibResolutionFindings.ts to keep the resolver under the module size limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a0ec3e2016
commit
91280393cd
@@ -123,6 +123,13 @@ export const traceDylibResolution = async (options: {
|
||||
"Dylib resolution was cancelled",
|
||||
{ cause },
|
||||
);
|
||||
const denied = permissionDenied(cause);
|
||||
if (denied !== undefined)
|
||||
throw new ArtifactReaderFailure(
|
||||
"unavailable",
|
||||
`Permission denied (${denied.code}) reading ${denied.path === undefined ? "a file in the analyzed root" : relative(root, denied.path) || denied.path}`,
|
||||
{ cause },
|
||||
);
|
||||
throw cause;
|
||||
}
|
||||
};
|
||||
@@ -242,6 +249,21 @@ const cancelled = (signal?: AbortSignal): void => {
|
||||
);
|
||||
};
|
||||
|
||||
/** Host permission denials, kept distinct from malformed or missing files. */
|
||||
const permissionDenied = (
|
||||
cause: unknown,
|
||||
): { readonly code: string; readonly path: string | undefined } | undefined => {
|
||||
if (!(cause instanceof Error) || !("code" in cause)) return undefined;
|
||||
if (cause.code !== "EACCES" && cause.code !== "EPERM") return undefined;
|
||||
return {
|
||||
code: cause.code,
|
||||
path:
|
||||
"path" in cause && typeof cause.path === "string"
|
||||
? cause.path
|
||||
: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
const missing = (cause: unknown): boolean =>
|
||||
cause instanceof Error &&
|
||||
"code" in cause &&
|
||||
|
||||
Reference in New Issue
Block a user