fix(dotnet): validate managed metadata and CIL boundaries (#938)
* perf(dotnet): reuse decoded metadata rows * test(dotnet): preserve expanded fixture metadata * style(dotnet): format metadata inventory * fix(dotnet): bound method bodies to PE section data * fix(dotnet): derive fixture metadata index widths * fix(dotnet): validate managed metadata bounds * test(dotnet): cover large metadata ReadyToRun layout * fix(dotnet): validate exception instruction boundaries * fix(dotnet): report invalid metadata coded indexes * fix(dotnet): clarify MemberForwarded null diagnostics * fix(dotnet): honor complete CIL and EH boundaries * fix(dotnet): validate metadata identity rows and offsets
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { inspectManagedArtifactBytes } from "./ManagedArtifactInspector.js";
|
||||
import { inspectManagedMembersBytes } from "./ManagedMemberInspector.js";
|
||||
import { inspectManagedNativeBoundariesBytes } from "./ManagedNativeBoundaryInspector.js";
|
||||
import {
|
||||
buildManagedPeFixture,
|
||||
buildNativePeFixture,
|
||||
@@ -43,4 +45,37 @@ describe("managed artifact failure classification", () => {
|
||||
expect.objectContaining({ code: "invalid-tables" }),
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps malformed reference and attribute issues across inventory callers", () => {
|
||||
const bytes = buildManagedPeFixture({
|
||||
references: [
|
||||
"System.Runtime",
|
||||
"System.Runtime",
|
||||
"UnityEngine.CoreModule",
|
||||
],
|
||||
malformedAssemblyReferenceRows: [3],
|
||||
malformedCustomAttributeRows: [1],
|
||||
});
|
||||
const target = managedPeFixtureTarget(bytes);
|
||||
const artifact = inspectManagedArtifactBytes(bytes, target);
|
||||
const members = inspectManagedMembersBytes(bytes, target);
|
||||
const boundaries = inspectManagedNativeBoundariesBytes(bytes, target);
|
||||
const issueCodes = ["invalid-heap-index", "invalid-row"];
|
||||
|
||||
expect(artifact.references.map(({ name }) => name)).toEqual([
|
||||
"System.Runtime",
|
||||
"System.Runtime",
|
||||
]);
|
||||
expect(artifact.coverage.issues.map(({ code }) => code)).toEqual(
|
||||
issueCodes,
|
||||
);
|
||||
expect(members.coverage.issues.map(({ code }) => code)).toEqual(issueCodes);
|
||||
expect(boundaries.coverage).toMatchObject({
|
||||
state: "partial",
|
||||
issues: [
|
||||
expect.objectContaining({ code: "invalid-heap-index" }),
|
||||
expect.objectContaining({ code: "invalid-row" }),
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user