feat(managed): select declaring types in inspect_managed_members
Select exact declaring types before managed signatures and CIL bodies are decoded, preserving caller choices in CLI/MCP Evidence. Keep unmatched names and selected coverage explicit; comparisons and graphs retain unknowns outside their observed scope. Reuse existing metadata ownership/accounting and advertise unique selections through the actual SDK Schema. Validated with 229 focused tests across 21 files, 11 managed conformance controls, fullstatic/docs checks and real Linux CLI and fresh MCP inspection of two unchanged DLLs. All 118 selected CIL hashes matched original PE-mapped bytes; result/caller-argument parity and unmatched controls passed. Full artifact/native-boundary metadata is complete; whole-assembly members retain the unchanged 64 MiB resource constraint. No target code executes. Refs #1878 Co-authored-by: skared <190618464+skoodster@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
co-authored by
skared
Claude Opus 5.5
Ysopwnable
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Kaoru0822
parent
f28f338283
commit
a149d183ef
@@ -859,3 +859,68 @@ it.each([
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
describe("managed member type selection", () => {
|
||||
const bytes = buildManagedPeFixture();
|
||||
const target = managedPeFixtureTarget(bytes);
|
||||
const everything = inspectManagedMembersBytes(bytes, target);
|
||||
|
||||
it("reports no selection when every type is inspected", () => {
|
||||
expect(everything.selection).toBeNull();
|
||||
});
|
||||
|
||||
it("decodes the selected type's members and reports unmatched names", () => {
|
||||
const result = inspectManagedMembersBytes(bytes, target, {
|
||||
typeNames: ["Fixture.Program", "Missing.Type"],
|
||||
});
|
||||
|
||||
expect(result.selection).toEqual({
|
||||
type_names: ["Fixture.Program", "Missing.Type"],
|
||||
unmatched_type_names: ["Missing.Type"],
|
||||
});
|
||||
expect(result.types).toEqual(everything.types);
|
||||
expect(result.fields).toEqual(everything.fields);
|
||||
expect(result.methods).toEqual(everything.methods);
|
||||
expect(result.call_edges).toEqual(everything.call_edges);
|
||||
expect(result.field_accesses).toEqual(everything.field_accesses);
|
||||
expect(result.coverage).toEqual(everything.coverage);
|
||||
expect(result.limitations).toContain(
|
||||
"Types, fields, methods, call edges, and field accesses cover only the selected declaring types; coverage describes that selection. Edge targets outside it keep their names but are not described.",
|
||||
);
|
||||
});
|
||||
|
||||
it("does not treat a name as absent when a TypeDef name is unreadable", () => {
|
||||
const corrupt = Buffer.from(bytes);
|
||||
const row = everything.types[0]?.row_offset ?? 0;
|
||||
// Point the TypeDef Name past the #Strings heap.
|
||||
corrupt.writeUInt16LE(0xffff, row + 4);
|
||||
const result = inspectManagedMembersBytes(
|
||||
corrupt,
|
||||
managedPeFixtureTarget(corrupt),
|
||||
{ typeNames: ["Fixture.Program"] },
|
||||
);
|
||||
|
||||
expect(result.selection?.unmatched_type_names).toEqual(["Fixture.Program"]);
|
||||
expect(result.coverage.state).toBe("partial");
|
||||
expect(result.limitations).toContain(
|
||||
"1 TypeDef name(s) could not be read; a name in selection.unmatched_type_names may belong to one of them, so its absence is not observed.",
|
||||
);
|
||||
});
|
||||
|
||||
it("omits members of unselected types without dropping member references", () => {
|
||||
const result = inspectManagedMembersBytes(bytes, target, {
|
||||
typeNames: ["Missing.Type"],
|
||||
});
|
||||
|
||||
expect(result.selection).toEqual({
|
||||
type_names: ["Missing.Type"],
|
||||
unmatched_type_names: ["Missing.Type"],
|
||||
});
|
||||
expect(result.types).toEqual([]);
|
||||
expect(result.fields).toEqual([]);
|
||||
expect(result.methods).toEqual([]);
|
||||
expect(result.call_edges).toEqual([]);
|
||||
expect(result.field_accesses).toEqual([]);
|
||||
expect(result.member_refs).toEqual(everything.member_refs);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user