mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 18:52:48 +00:00
When the byte reader for inspect_native_dispatch_metadata refuses a target
(for example a 32-bit Mach-O) and the list_names symbol fallback then fails
or returns an invalid inventory, only the fallback's error reached the
caller. Retain the reader failure under diagnostics.binary_metadata_failure.
Fixes #7651.
Carries forward e7884a704 (by @morluto, on @dreinst's #7701).
Signed-off-by: Zhaowei Gu <83746079+zw-g@users.noreply.github.com>
Supersedes #8036
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect } from "vitest";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../support/cli/cliFixture.js";
|
|
|
|
cliTest.skipIf(process.platform !== "darwin")(
|
|
"retains the 32-bit reader refusal when symbol fallback is unavailable",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-dispatch-width-");
|
|
for (const cpu of [7, 12]) {
|
|
const image = Buffer.alloc(28);
|
|
image.writeUInt32LE(0xfeedface, 0);
|
|
image.writeUInt32LE(cpu, 4);
|
|
image.writeUInt32LE(cpu === 7 ? 3 : 9, 8);
|
|
image.writeUInt32LE(2, 12);
|
|
const path = join(root, `image-${cpu}`);
|
|
await writeFile(path, image);
|
|
const result = await cli.run({
|
|
arguments: [
|
|
"inspect-native-dispatch-metadata",
|
|
path,
|
|
"--format",
|
|
"json",
|
|
],
|
|
environment: {
|
|
...process.env,
|
|
REA_ANALYSIS_PROVIDER: "auto",
|
|
HOPPER_LAUNCHER_PATH: join(root, "missing-hopper"),
|
|
GHIDRA_INSTALL_DIR: join(root, "missing-ghidra"),
|
|
JAVA_HOME: join(root, "missing-java"),
|
|
},
|
|
});
|
|
expect(result.exitCode).toBe(1);
|
|
expect(result.json).toMatchObject({
|
|
details: {
|
|
diagnostics: {
|
|
binary_metadata_failure: {
|
|
details: { reason: expect.stringMatching(/32.bit/i) },
|
|
},
|
|
},
|
|
},
|
|
});
|
|
}
|
|
},
|
|
);
|