mirror of
https://github.com/morluto/rea.git
synced 2026-11-24 13:18:39 +00:00
Three formats had their own error mappers that still reported a selected file's corrupt bytes as an invalid_format path issue (invalid_request): managedInspectionInputFailure, Il2cppMetadataProvider and the Mach-O slice selection mappers. Each now projects its format owner's own failure through AnalysisMalformedTargetError at the path of the file whose bytes are at fault. - Managed PE/CLI: a broken rule is a malformed pe-cli target with the reader's scope and offset; unsupported-metadata and unsupported-signature are unsupported targets; resource limits stay with their producer. - Universal Mach-O: the container reader raises a ParseFailure once (malformed, truncated where it measured the end, unsupported from the container's own category), and requireSelectedNativeImage(FromReader) project it at the universal file's path. An unknown or ambiguous architecture stays invalid_request on the architecture field. SliceSelectionInput.pathField is removed. - IL2CPP: metadata and binary format failures each name their own file. A binary that parses but does not link to the metadata is a link conflict: invalid_request with invalid_value issues on both path and binary_path, no input-contract recovery, and the partial observation keeps both file identities. Neither file is called malformed. BREAKING CHANGE: inspect_managed_artifact, inspect_managed_members, inspect_managed_native_boundaries, compare_managed_members, inspect_il2cpp_metadata, inspect_go_binary, inspect_rust_binary, inspect_dwarf_units and inspect_native_initializers report corrupt or truncated target bytes as code unsupported_target with details.path, format, format_failure and reason instead of invalid_request with an invalid_format issue. IL2CPP link conflicts list both path and binary_path with reason invalid_value instead of one invalid_format binary_path issue.
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect } from "vitest";
|
|
import { createIl2cppMetadataFixture } from "../fixtures/il2cpp/metadata.js";
|
|
import { connectLocalToolsMcp } from "../fixtures/localToolsMcp.js";
|
|
import { parseMcpToolError } from "../fixtures/mcpToolError.js";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../support/cli/cliFixture.js";
|
|
|
|
cliTest(
|
|
"reports inconsistent IL2CPP table extents through CLI and MCP without a binary",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-il2cpp-extent-");
|
|
const { call } = await connectLocalToolsMcp();
|
|
for (const [version, name] of [
|
|
[31, "genericContainers"],
|
|
[31, "genericParameters"],
|
|
[31, "interfaceOffsets"],
|
|
[39, "genericContainers"],
|
|
[39, "genericParameters"],
|
|
[39, "parameters"],
|
|
] as const) {
|
|
const isCountedContainer = version === 39 && name === "genericContainers";
|
|
const fixture = createIl2cppMetadataFixture({
|
|
version,
|
|
genericOwners: true,
|
|
...(isCountedContainer && { interfaceOffsets: false }),
|
|
});
|
|
const path = join(root, `${version}-${name}.dat`);
|
|
await writeFile(path, fixture.bytes);
|
|
const intact = await cli.run({
|
|
arguments: ["inspect-il2cpp-metadata", path, "--json"],
|
|
});
|
|
expect(intact.exitCode, intact.stderr).toBe(0);
|
|
|
|
const damaged = Buffer.from(fixture.bytes);
|
|
if (isCountedContainer || name === "parameters") {
|
|
damaged.writeInt32LE(300, fixture.header(name, "count"));
|
|
} else {
|
|
damaged.writeInt32LE(
|
|
fixture.section(name).size - 1,
|
|
fixture.header(name, "size"),
|
|
);
|
|
}
|
|
await writeFile(path, damaged);
|
|
const invalid = await cli.run({
|
|
arguments: ["inspect-il2cpp-metadata", path, "--json"],
|
|
});
|
|
const expected = {
|
|
code: "unsupported_target",
|
|
details: {
|
|
path,
|
|
format_failure: "malformed",
|
|
format: "il2cpp-metadata",
|
|
reason: expect.stringContaining(
|
|
`record-size-mismatch: section ${name}`,
|
|
),
|
|
},
|
|
};
|
|
expect(invalid.exitCode).toBe(1);
|
|
expect(invalid.json).toMatchObject(expected);
|
|
const result = await call("inspect_il2cpp_metadata", { path });
|
|
expect(result.isError).toBe(true);
|
|
expect(parseMcpToolError(result).error).toMatchObject(expected);
|
|
}
|
|
},
|
|
);
|