fix(hopper): load verified FAT64 slices with native Mach-O semantics
This commit is contained in:
@@ -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 ?? []),
|
||||
|
||||
Reference in New Issue
Block a user