fix(hopper): load verified FAT64 slices with native Mach-O semantics

This commit is contained in:
morluto
2026-10-09 05:12:36 +08:00
parent 458771cb58
commit 0a49d5bfb9
10 changed files with 630 additions and 54 deletions
+38 -1
View File
@@ -24,6 +24,7 @@ import {
resolveHopperAnalysisProfile,
} from "./HopperAnalysisProfile.js";
import { HopperClient } from "./HopperClient.js";
import { hopperMachOImageSchema } from "./HopperMachOImage.js";
import {
CAPABILITIES,
@@ -158,7 +159,30 @@ export class HopperProvider implements AnalysisProviderCandidate {
),
close: () => Promise.resolve(),
};
const container = profile?.parameters.macho_container;
const preparation = profile?.parameters.prepared_image;
const parsedImage =
preparation === undefined
? undefined
: hopperMachOImageSchema.safeParse(preparation);
if (parsedImage?.success === false)
return {
execute: (operation) =>
Promise.resolve(
err(
new AnalysisCapabilityUnavailableError(
IDENTITY.id,
operation,
"Hopper prepared-image profile is malformed; resolve the analysis profile again.",
),
),
),
close: () => Promise.resolve(),
};
const preparedImage = parsedImage?.data;
const container =
preparedImage === undefined
? profile?.parameters.macho_container
: "thin";
const derivedLoaderArgs = hopperLoaderArgsForTarget(
target,
container === "thin" || container === "fat32" || container === "fat64"
@@ -176,6 +200,14 @@ export class HopperProvider implements AnalysisProviderCandidate {
launcherPath: this.config.hopperLauncherPath,
targetPath: target.path,
targetKind: target.kind,
...(preparedImage === undefined
? {}
: {
preparedImage: {
image: preparedImage,
sourceSha256: target.sha256,
},
}),
loaderArgs:
this.config.hopperLoaderArgs.length > 0
? this.config.hopperLoaderArgs
@@ -206,6 +238,11 @@ export class HopperProvider implements AnalysisProviderCandidate {
value: createAnalysisExecution(result.value, executionProvider, {
...(profile === undefined ? {} : { analysisProfile: profile }),
limitations: [
...(preparedImage === undefined
? []
: [
"REA loaded a verified thin Mach-O slice from the original FAT64 source. Identity and file offsets refer to the original file. The owned temporary image and its Hopper document close together, including on MCP shutdown.",
]),
...(CAPABILITIES.find(
(descriptor) => descriptor.operation === operation,
)?.limitations ?? []),