fix(dotnet): inspect native boundaries of non-managed and malformed PEs

`inspect_managed_native_boundaries` wrote the PE classification
(`not-managed` or `malformed`) into `coverage.state`, which accepts only
`complete`, `partial`, or `unavailable`. Its own result validation then
threw, so every native DLL and every PE with unreadable CLI metadata
failed as a generic execution failure advising a retry. The sibling
artifact and member inspectors succeed on the same files.

Report these files with `unavailable` coverage, as the member inspector
does, keeping the metadata status and parse issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822 2026-10-07 00:05:58 -07:00
parent 01be082e9e
commit d98dcfa8c2
2 changed files with 32 additions and 6 deletions

View File

@ -101,4 +101,32 @@ describe("managed native boundaries", () => {
expect.objectContaining({ code: "invalid-metadata-root" }),
]);
});
it("reports unavailable boundaries for native and malformed PE files", () => {
const nativeBytes = buildNativePeFixture();
const native = inspectManagedNativeBoundariesBytes(
nativeBytes,
managedPeFixtureTarget(nativeBytes),
);
expect(native).toMatchObject({
metadata: { status: "absent" },
pinvoke_imports: [],
coverage: { state: "unavailable", issues: [] },
});
const malformedBytes = buildManagedPeFixture({
corruptMetadataSignature: true,
});
const malformed = inspectManagedNativeBoundariesBytes(
malformedBytes,
managedPeFixtureTarget(malformedBytes),
);
expect(malformed).toMatchObject({
metadata: { status: "malformed" },
coverage: {
state: "unavailable",
issues: [expect.objectContaining({ code: "invalid-metadata-root" })],
},
});
});
});

View File

@ -29,10 +29,11 @@ import {
type Inventory = ReturnType<typeof readManagedMetadataInventory>;
/** Report a PE whose CLI data is absent or cannot be admitted. */
const emptyInspection = (
target: BinaryTarget,
bytes: Buffer,
classification: "not-managed" | "malformed" | "not-available" | "managed",
classification: "not-managed" | "malformed",
issues: readonly ManagedParseIssue[] = [],
): ManagedNativeBoundaryInspection =>
managedNativeBoundaryInspectionSchema.parse({
@ -44,10 +45,7 @@ const emptyInspection = (
},
module: null,
metadata: {
status:
classification === "malformed" || classification === "not-available"
? "malformed"
: "absent",
status: classification === "malformed" ? "malformed" : "absent",
version: null,
table_row_counts: {},
},
@ -75,7 +73,7 @@ const emptyInspection = (
ready_to_run: false,
mixed_mode_or_native_header: false,
},
coverage: { state: classification, issues },
coverage: { state: "unavailable", issues },
limitations: [
"No CLI data was admitted; native boundary declarations are unavailable.",
"Static inspection does not load or execute target code, so native export resolution is not performed.",