mirror of
https://github.com/morluto/rea.git
synced 2026-11-07 23:36:41 +00:00
Normalize parsed facts at their owning boundaries across PE exports and certificates, ELF section names, GPU bundles, IL2CPP generic types, dyld slice selection, source maps, environment replay, and JavaScript mapped arguments. Preserve partial facts and explicit unsupported cases; clarify the corresponding documentation. Validation: 831 affected tests passed with one existing skip across 23 files; build, typecheck/lint, documentation, formatting, and 2133-file test discovery passed. Format controls are synthetic; real Unity, GPU, and ARM-device execution is unverified. Fixes #6709 Fixes #6688 Fixes #6719 Fixes #6718 Fixes #6704 Fixes #6703 Fixes #6692 Fixes #6723 Fixes #6687 Fixes #6726 Fixes #6696 Fixes #6691 Fixes #6727
86 lines
3.0 KiB
TypeScript
86 lines
3.0 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect } from "vitest";
|
|
import { toolContract } from "../../src/contracts/toolContracts.js";
|
|
import {
|
|
compressedElfNoteFixture,
|
|
elfNoteFixture,
|
|
} from "../../src/native/elf/ElfNotes.fixture.js";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../support/cli/cliFixture.js";
|
|
|
|
cliTest("reports a GNU build-id through the public CLI", async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-elf-notes-cli-");
|
|
const path = join(root, "program");
|
|
await writeFile(path, elfNoteFixture({ ownership: "program" }));
|
|
const result = await cli.run({
|
|
arguments: ["inspect-elf-notes", path, "--json"],
|
|
});
|
|
expect(result.exitCode, result.stderr).toBe(0);
|
|
const evidence = toolContract("inspect_elf_notes").outputSchema.parse(
|
|
result.json,
|
|
);
|
|
expect(
|
|
evidence.normalized_result.entries.find(
|
|
(entry) => entry.type_name === "gnu_build_id",
|
|
)?.gnu?.build_id_hex,
|
|
).toBe("0123456789abcdef0123456789abcdef01234567");
|
|
});
|
|
|
|
cliTest(
|
|
"resolves section note names from a compressed string table through the CLI",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-elf-notes-compressed-cli-");
|
|
const path = join(root, "program");
|
|
await writeFile(path, compressedElfNoteFixture());
|
|
const result = await cli.run({
|
|
arguments: ["inspect-elf-notes", path, "--json"],
|
|
});
|
|
expect(result.exitCode, result.stderr).toBe(0);
|
|
const evidence = toolContract("inspect_elf_notes").outputSchema.parse(
|
|
result.json,
|
|
);
|
|
expect(evidence.normalized_result.tables[0]?.name).toBe(
|
|
".note.gnu.build-id",
|
|
);
|
|
expect(evidence.normalized_result.entries[0]?.gnu?.build_id_hex).toBe(
|
|
"0123456789abcdef0123456789abcdef01234567",
|
|
);
|
|
},
|
|
);
|
|
|
|
cliTest(
|
|
"resolves a relative ELF path against the working directory",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-elf-notes-cli-rel-");
|
|
await writeFile(
|
|
join(root, "unsigned"),
|
|
elfNoteFixture({ ownership: "none" }),
|
|
);
|
|
const result = await cli.run({
|
|
arguments: ["inspect-elf-notes", "unsigned", "--json"],
|
|
cwd: root,
|
|
});
|
|
expect(result.exitCode, result.stderr).toBe(0);
|
|
const evidence = toolContract("inspect_elf_notes").outputSchema.parse(
|
|
result.json,
|
|
);
|
|
expect(evidence.normalized_result.tables).toEqual([]);
|
|
expect(evidence.subject?.local_path).toBe(join(root, "unsigned"));
|
|
},
|
|
);
|
|
|
|
cliTest("reports a truncated ELF as invalid input", async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-elf-notes-cli-bad-");
|
|
const path = join(root, "broken");
|
|
await writeFile(path, Buffer.from("\x7fELF"));
|
|
const result = await cli.run({
|
|
arguments: ["inspect-elf-notes", path, "--json"],
|
|
});
|
|
expect(result.exitCode).toBe(1);
|
|
expect(result.json).toMatchObject({
|
|
code: "invalid_request",
|
|
details: { operation: "inspect_elf_notes" },
|
|
});
|
|
});
|