fix(dotnet): keep admitted CLI header facts when metadata is unreadable

When the CLI header parsed but its metadata could not be admitted, the
native-boundary fallback reported hard-coded false flags and zero header
values. A corrupt-metadata ReadyToRun image therefore appeared IL-free
and non-native. The fallback now reports the parsed CLI header and
derives the summary from it as the full inspection does. When the CLI
header itself is unreadable, a limitation says the values are defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-07 07:47:44 +00:00
co-authored by Claude Opus 5.5
parent d98dcfa8c2
commit e5ba6934e4
3 changed files with 93 additions and 38 deletions
@@ -116,6 +116,7 @@ describe("managed native boundaries", () => {
const malformedBytes = buildManagedPeFixture({
corruptMetadataSignature: true,
readyToRun: true,
});
const malformed = inspectManagedNativeBoundariesBytes(
malformedBytes,
@@ -123,10 +124,37 @@ describe("managed native boundaries", () => {
);
expect(malformed).toMatchObject({
metadata: { status: "malformed" },
cli_native: {
il_only: true,
ready_to_run_signature: true,
managed_native_header_rva: 0x2700,
managed_native_header_size: 4,
},
summary: { ready_to_run: true, mixed_mode_or_native_header: true },
coverage: {
state: "unavailable",
issues: [expect.objectContaining({ code: "invalid-metadata-root" })],
},
});
expect(malformed.limitations).not.toContainEqual(
expect.stringContaining("CLI header was not admitted"),
);
});
it("marks CLI header facets as defaults when the CLI header is unreadable", () => {
const bytes = buildManagedPeFixture();
bytes.writeUInt32LE(0x7fff_0000, 0x84 + 20 + 96 + 14 * 8);
const result = inspectManagedNativeBoundariesBytes(
bytes,
managedPeFixtureTarget(bytes),
);
expect(result).toMatchObject({
metadata: { status: "malformed" },
cli_native: { il_only: false },
coverage: { state: "unavailable", issues: [expect.anything()] },
});
expect(result.limitations).toContainEqual(
expect.stringContaining("CLI header was not admitted"),
);
});
});