fix(native): preserve universal Mach-O container identity
Keep FAT container format distinct from selected slice architecture through target admission, Evidence, snapshots, and CLI/MCP lifecycle results. Preserve native, Hopper, Ghidra, extraction, and dylib routing for the Mach-O family. Reject selected FAT ranges overlapping their table or too short for a Mach-O header. Replace empty-slice fixtures with in-bounds executable headers and cover thin, universal, single-slice, FAT64, and swapped containers. Validation: static and architecture checks, generated docs, targeted producer and public MCP tests. Provider routing uses controlled fixtures; no live Hopper, IDA, JADX, or Ghidra analysis was performed for this change.
This commit is contained in:
@@ -664,6 +664,30 @@ describe("Ghidra native decompiler admission", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts a one-slice universal-format Darwin native decompiler", () => {
|
||||
const bytes = fat([0x0100000c]);
|
||||
const result = inspectGhidraInstallation(
|
||||
{
|
||||
environment: {},
|
||||
installDir: INSTALL,
|
||||
platform: "darwin",
|
||||
architecture: "arm64",
|
||||
},
|
||||
host({
|
||||
executableHeader: (path: string) =>
|
||||
path === MAC_DECOMPILER ? { bytes, size: bytes.length } : undefined,
|
||||
}),
|
||||
);
|
||||
expect(result.status).toBe("available");
|
||||
if (result.status !== "available") return;
|
||||
expect(
|
||||
result.checks.find(({ name }) => name === "native_decompiler"),
|
||||
).toMatchObject({
|
||||
status: "passed",
|
||||
detail: `${MAC_DECOMPILER} reports mach-o-universal arm64, which matches darwin/arm64`,
|
||||
});
|
||||
});
|
||||
|
||||
it("names the observed and the required executable in the failure", () => {
|
||||
const result = inspectGhidraInstallation(
|
||||
{
|
||||
|
||||
@@ -17,7 +17,10 @@ import {
|
||||
parseExecutableHeader,
|
||||
type ExecutableMetadata,
|
||||
} from "../domain/binaryTarget.js";
|
||||
import type { BinaryArchitecture } from "../domain/binaryTargetTypes.js";
|
||||
import {
|
||||
isMachOFormat,
|
||||
type BinaryArchitecture,
|
||||
} from "../domain/binaryTargetTypes.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import {
|
||||
ghidraApplicationProperties,
|
||||
@@ -131,7 +134,10 @@ const assessNativeDecompiler = (
|
||||
};
|
||||
const observed = `${parsed.value.format} ${parsed.value.architecture}`;
|
||||
const expected = `${expectedFormat} ${expectedArchitecture}`;
|
||||
if (observed === expected)
|
||||
const formatMatches = isMachOFormat(expectedFormat)
|
||||
? isMachOFormat(parsed.value.format)
|
||||
: parsed.value.format === expectedFormat;
|
||||
if (formatMatches && parsed.value.architecture === expectedArchitecture)
|
||||
return {
|
||||
status: "compatible",
|
||||
detail: `${path} reports ${observed}, which matches ${platform}/${architecture}`,
|
||||
|
||||
@@ -239,7 +239,7 @@ describe("Ghidra Mach-O slice support", () => {
|
||||
path: "/tmp/fixture",
|
||||
sha256: "a".repeat(64),
|
||||
kind: "executable",
|
||||
format: "mach-o",
|
||||
format: "mach-o-universal",
|
||||
architecture: "arm64",
|
||||
availableArchitectures: ["x86_64", "arm64"],
|
||||
};
|
||||
@@ -256,6 +256,13 @@ describe("Ghidra Mach-O slice support", () => {
|
||||
expect(
|
||||
ghidra.inspectTargetSupport(executableTarget("mach-o", "arm64")),
|
||||
).toMatchObject({ status: "supported" });
|
||||
|
||||
expect(
|
||||
ghidra.inspectTargetSupport({
|
||||
...universal,
|
||||
availableArchitectures: ["arm64"] as const,
|
||||
}),
|
||||
).toMatchObject({ status: "supported" });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@ import {
|
||||
createAnalysisProfile,
|
||||
type AnalysisProfileCommitment,
|
||||
} from "../domain/analysisProfile.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
|
||||
import {
|
||||
isMachOFormat,
|
||||
type BinaryTarget,
|
||||
} from "../domain/binaryTargetTypes.js";
|
||||
import {
|
||||
jsonObjectSchema,
|
||||
jsonValueSchema,
|
||||
@@ -164,7 +167,10 @@ export class GhidraProvider implements AnalysisProviderCandidate {
|
||||
reason: mipsReason,
|
||||
diagnostics,
|
||||
};
|
||||
if (target.format === "mach-o" && target.availableArchitectures.length > 1)
|
||||
if (
|
||||
isMachOFormat(target.format) &&
|
||||
target.availableArchitectures.length > 1
|
||||
)
|
||||
return {
|
||||
status: "unsupported",
|
||||
code: "architecture_unsupported",
|
||||
|
||||
Reference in New Issue
Block a user