mirror of
https://github.com/morluto/rea.git
synced 2026-11-26 22:28:44 +00:00
fix(errors)!: refuse corrupt managed, IL2CPP and universal Mach-O bytes as a malformed target (#14224)
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.
This commit is contained in:
1 parent
1a43f56354
commit
57f4e3c4bd
24 files changed
+934
-296
No files matched your search
@@ -667,16 +667,15 @@ it("retains the exact source when recognized magic has no complete version", asy
|
||||
|
||||
if (result.ok) throw new Error("Expected truncated metadata prefix");
|
||||
expect(result.error).toMatchObject({
|
||||
_tag: "AnalysisInputError",
|
||||
issues: [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_format",
|
||||
message: expect.stringMatching(
|
||||
/truncated-header:.*metadata version is unknown/u,
|
||||
),
|
||||
},
|
||||
],
|
||||
_tag: "AnalysisMalformedTargetError",
|
||||
path,
|
||||
failure: {
|
||||
kind: "truncated",
|
||||
format: "il2cpp-metadata",
|
||||
detail: expect.stringMatching(
|
||||
/truncated-header:.*metadata version is unknown/u,
|
||||
),
|
||||
},
|
||||
});
|
||||
expect(result.error.partialObservation).toMatchObject({
|
||||
operation: "observe_il2cpp_metadata_source",
|
||||
@@ -879,8 +878,13 @@ it.each([false, true])(
|
||||
expect(ordinary).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
_tag: "AnalysisInputError",
|
||||
issues: [{ path: ["binary_path"], reason: "invalid_format" }],
|
||||
_tag: "AnalysisMalformedTargetError",
|
||||
path: binary_path,
|
||||
failure: {
|
||||
kind: "malformed",
|
||||
format: "il2cpp-binary",
|
||||
detail: expect.stringMatching(/^malformed-container:/u),
|
||||
},
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
@@ -958,9 +962,44 @@ it("retains both observed file identities and the selected architecture when nat
|
||||
try {
|
||||
const result = await provider.inspect({ path, binary_path });
|
||||
if (result.ok) throw new Error("Unresolved registration accepted");
|
||||
// Both files parse; neither is called malformed. The conflict lists each
|
||||
// selecting field and keeps each file's identity.
|
||||
expect(result.error).toMatchObject({
|
||||
_tag: "AnalysisInputError",
|
||||
conformsToInputContract: true,
|
||||
issues: [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining(
|
||||
`Selected metadata ${path} does not link to the selected binary: code-registration-not-found:`,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: ["binary_path"],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining(
|
||||
`Selected binary ${binary_path} does not link to the metadata: code-registration-not-found:`,
|
||||
),
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||
code: "invalid_request",
|
||||
retryable: false,
|
||||
remediation: {
|
||||
action: expect.stringContaining("from the same build"),
|
||||
},
|
||||
});
|
||||
expect(projectAnalysisError(result.error)).not.toHaveProperty("recovery");
|
||||
expect(result.error.partialObservation).toMatchObject({
|
||||
normalized_result: {
|
||||
artifact: { path },
|
||||
artifact: {
|
||||
path,
|
||||
sha256: createHash("sha256")
|
||||
.update(createLinkedIl2cppMetadataFixture().bytes)
|
||||
.digest("hex"),
|
||||
},
|
||||
selected_binary: {
|
||||
path: binary_path,
|
||||
identity_status: "observed",
|
||||
@@ -1134,16 +1173,13 @@ it("names the metadata, not the binary, when linking reads a malformed metadata
|
||||
const result = await provider.inspect({ path, binary_path: binaryPath });
|
||||
if (result.ok) throw new Error("Expected the metadata name to be refused");
|
||||
expect(result.error).toMatchObject({
|
||||
_tag: "AnalysisInputError",
|
||||
issues: [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_format",
|
||||
message: expect.stringContaining(
|
||||
`Selected artifact ${path} is corrupt: invalid-string:`,
|
||||
),
|
||||
},
|
||||
],
|
||||
_tag: "AnalysisMalformedTargetError",
|
||||
path,
|
||||
failure: {
|
||||
kind: "malformed",
|
||||
format: "il2cpp-metadata",
|
||||
detail: expect.stringMatching(/^invalid-string:/u),
|
||||
},
|
||||
});
|
||||
|
||||
const corrected = Buffer.from(metadata);
|
||||
|
||||
Reference in new issue
Block a user