fix(dotnet): bound RVA reads by section virtual size

Use the shared resolver for virtual containment, overlap checks, and file-backed extent. Raw alignment padding no longer supplies method bytes or shadows a later virtual section. Preserve malformed body coverage and suppress CIL hashes outside the admitted range.

Verify zero, exact-end, truncated-body, padding, and true-overlap cases through compiled CLI and MCP consumers. Synthetic PE fixtures only; no Windows loader or real managed-provider verification.

Fixes #1596. Supersedes #1595.
This commit is contained in:
morluto
2026-10-11 07:02:16 +08:00
parent 1b527f4898
commit 975dff2e25
4 changed files with 139 additions and 13 deletions
+29
View File
@@ -29,8 +29,16 @@ it("runs every managed static inspection independently of an active native targe
);
const path = join(directory, "fixture.dll");
const otherPath = join(directory, "other-fixture.dll");
const partialPath = join(directory, "partial-method.dll");
await writeFile(path, buildManagedPeFixture());
await writeFile(otherPath, buildManagedPeFixture({ methodName: "Other" }));
await writeFile(
partialPath,
buildManagedPeFixture({
virtualSectionSize: 0x801,
ilBody: Buffer.from([0x06, 0x2a]),
}),
);
const session = composeBinarySession(new AnalysisProviderRegistry([]), [
new ManagedStaticProvider(),
]);
@@ -116,6 +124,27 @@ it("runs every managed static inspection independently of an active native targe
provider: { id: "rea-dotnet-static" },
subject: { local_path: path, format: "pe" },
});
const partial = structured(
await client.callTool({
name: "inspect_managed_members",
arguments: { path: partialPath },
}),
);
expect(partial).toMatchObject({
subject: { local_path: partialPath, format: "pe" },
normalized_result: {
methods: [
{
body: {
status: "malformed",
normalized_il_sha256: null,
issue: "Method body leaves file-backed PE section data",
},
},
],
coverage: { state: "partial" },
},
});
} finally {
await Promise.all([client.close(), server.close()]);
await session.close();