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
@@ -32,10 +32,23 @@ import { readManagedValue } from "./ManagedReaderFailure.js";
|
||||
import { methodBody } from "./ManagedMethodBodyReader.js";
|
||||
import { memberDeclaringTypeRowLookup } from "./ManagedMemberOwnership.js";
|
||||
|
||||
/**
|
||||
* Declaring-type tokens whose members are decoded in full; null selects every
|
||||
* type. Unselected members keep only their name so edges stay labelled.
|
||||
*/
|
||||
export type SelectedTypeTokens = ReadonlySet<string> | null;
|
||||
|
||||
const isSelected = (
|
||||
selected: SelectedTypeTokens,
|
||||
declared: { readonly token: string } | undefined,
|
||||
): boolean =>
|
||||
selected === null || (declared !== undefined && selected.has(declared.token));
|
||||
|
||||
export const parseFields = (
|
||||
bytes: Buffer,
|
||||
layout: ManagedMetadataLayout,
|
||||
ranges: readonly TypeRange[],
|
||||
selected: SelectedTypeTokens = null,
|
||||
): {
|
||||
readonly fields: readonly ManagedField[];
|
||||
readonly core: ReadonlyMap<string, FieldCore>;
|
||||
@@ -59,18 +72,20 @@ export const parseFields = (
|
||||
cursor.readIndex(layout.stringIndexSize),
|
||||
layout.strings.size,
|
||||
);
|
||||
const sig = readMetadataBlob(
|
||||
bytes,
|
||||
layout,
|
||||
cursor.readIndex(layout.blobIndexSize),
|
||||
layout.blob.size,
|
||||
);
|
||||
const owner =
|
||||
ownerRow === undefined
|
||||
? 0
|
||||
: (readManagedValue(() => ownerRow(row), issues) ?? 0);
|
||||
const declared = ranges[owner - 1];
|
||||
const token = metadataToken(4, row);
|
||||
core.set(token, { token, name });
|
||||
if (!isSelected(selected, declared)) return;
|
||||
const sig = readMetadataBlob(
|
||||
bytes,
|
||||
layout,
|
||||
cursor.readIndex(layout.blobIndexSize),
|
||||
layout.blob.size,
|
||||
);
|
||||
fields.push({
|
||||
token,
|
||||
row_offset: cursor.start,
|
||||
@@ -80,7 +95,6 @@ export const parseFields = (
|
||||
flags,
|
||||
signature: budgetedSignature(sig, layout),
|
||||
});
|
||||
core.set(token, { token, name });
|
||||
}, issues);
|
||||
}
|
||||
return { fields, core, issues };
|
||||
@@ -227,6 +241,7 @@ interface ParseMethodsInput {
|
||||
readonly layout: ManagedMetadataLayout;
|
||||
readonly pe: ManagedPeLayout;
|
||||
readonly ranges: readonly TypeRange[];
|
||||
readonly selected?: SelectedTypeTokens;
|
||||
}
|
||||
|
||||
export const parseMethods = ({
|
||||
@@ -234,6 +249,7 @@ export const parseMethods = ({
|
||||
layout,
|
||||
pe,
|
||||
ranges,
|
||||
selected = null,
|
||||
}: ParseMethodsInput): {
|
||||
readonly methods: readonly ManagedMethod[];
|
||||
readonly core: ReadonlyMap<string, MethodCore>;
|
||||
@@ -259,6 +275,18 @@ export const parseMethods = ({
|
||||
cursor.readIndex(layout.stringIndexSize),
|
||||
layout.strings.size,
|
||||
);
|
||||
const owner =
|
||||
ownerRow === undefined
|
||||
? 0
|
||||
: (readManagedValue(() => ownerRow(row), issues) ?? 0);
|
||||
const declared = ranges[owner - 1];
|
||||
const token = metadataToken(6, row);
|
||||
core.set(token, {
|
||||
token,
|
||||
name,
|
||||
declaringType: declared?.fullName ?? null,
|
||||
});
|
||||
if (!isSelected(selected, declared)) return;
|
||||
const sig = readMetadataBlob(
|
||||
bytes,
|
||||
layout,
|
||||
@@ -266,12 +294,6 @@ export const parseMethods = ({
|
||||
layout.blob.size,
|
||||
);
|
||||
cursor.readIndex(layout.tableIndexSize(8));
|
||||
const owner =
|
||||
ownerRow === undefined
|
||||
? 0
|
||||
: (readManagedValue(() => ownerRow(row), issues) ?? 0);
|
||||
const declared = ranges[owner - 1];
|
||||
const token = metadataToken(6, row);
|
||||
methods.push({
|
||||
token,
|
||||
row_offset: cursor.start,
|
||||
@@ -290,11 +312,6 @@ export const parseMethods = ({
|
||||
managedDecodeBudget(layout),
|
||||
),
|
||||
});
|
||||
core.set(token, {
|
||||
token,
|
||||
name,
|
||||
declaringType: declared?.fullName ?? null,
|
||||
});
|
||||
}, issues);
|
||||
}
|
||||
return { methods, core, issues };
|
||||
|
||||
Reference in New Issue
Block a user