From d98dcfa8c2e46a7cc918aeb01058c26c4a84060c Mon Sep 17 00:00:00 2001 From: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Date: Wed, 7 Oct 2026 00:05:58 -0700 Subject: [PATCH] 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 --- .../ManagedNativeBoundaryInspector.test.ts | 28 +++++++++++++++++++ src/dotnet/ManagedNativeBoundaryInspector.ts | 10 +++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/dotnet/ManagedNativeBoundaryInspector.test.ts b/src/dotnet/ManagedNativeBoundaryInspector.test.ts index a33c803bf..978110590 100644 --- a/src/dotnet/ManagedNativeBoundaryInspector.test.ts +++ b/src/dotnet/ManagedNativeBoundaryInspector.test.ts @@ -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" })], + }, + }); + }); }); diff --git a/src/dotnet/ManagedNativeBoundaryInspector.ts b/src/dotnet/ManagedNativeBoundaryInspector.ts index 9fd96790b..e3f82c7cb 100644 --- a/src/dotnet/ManagedNativeBoundaryInspector.ts +++ b/src/dotnet/ManagedNativeBoundaryInspector.ts @@ -29,10 +29,11 @@ import { type Inventory = ReturnType; +/** 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.",