feat(dotnet): add managed member inspection
This commit is contained in:
@@ -82,6 +82,138 @@ const customAttributeSchema = z.object({
|
||||
row_offset: offsetSchema,
|
||||
});
|
||||
|
||||
const managedSignatureSchema = z.object({
|
||||
raw_length: z.number().int().min(0),
|
||||
raw_sha256: digestSchema,
|
||||
kind: z.enum(["method", "field", "unknown"]),
|
||||
parse_status: z.enum(["decoded", "partial", "unsupported", "malformed"]),
|
||||
calling_convention: z.string().nullable(),
|
||||
generic_parameter_count: z.number().int().min(0).nullable(),
|
||||
parameter_count: z.number().int().min(0).nullable(),
|
||||
return_type: z.string().nullable(),
|
||||
parameter_types: z.array(z.string()),
|
||||
field_type: z.string().nullable(),
|
||||
issue: z.string().nullable(),
|
||||
});
|
||||
|
||||
const managedTypeSchema = z.object({
|
||||
token: tokenSchema,
|
||||
row_offset: offsetSchema,
|
||||
namespace: z.string(),
|
||||
name: z.string(),
|
||||
full_name: z.string(),
|
||||
flags: z.number().int().min(0).max(0xffff_ffff),
|
||||
extends_token: tokenSchema.nullable(),
|
||||
field_list: z.object({
|
||||
first_row: z.number().int().min(1).nullable(),
|
||||
last_row: z.number().int().min(0).nullable(),
|
||||
count: z.number().int().min(0),
|
||||
}),
|
||||
method_list: z.object({
|
||||
first_row: z.number().int().min(1).nullable(),
|
||||
last_row: z.number().int().min(0).nullable(),
|
||||
count: z.number().int().min(0),
|
||||
}),
|
||||
});
|
||||
|
||||
const managedFieldSchema = z.object({
|
||||
token: tokenSchema,
|
||||
row_offset: offsetSchema,
|
||||
declaring_type_token: tokenSchema.nullable(),
|
||||
declaring_type: z.string().nullable(),
|
||||
name: z.string(),
|
||||
flags: z.number().int().min(0).max(0xffff),
|
||||
signature: managedSignatureSchema,
|
||||
});
|
||||
|
||||
const managedExceptionRegionSchema = z.object({
|
||||
flags: z.number().int().min(0).max(0xffff_ffff),
|
||||
try_offset: z.number().int().min(0),
|
||||
try_length: z.number().int().min(0),
|
||||
handler_offset: z.number().int().min(0),
|
||||
handler_length: z.number().int().min(0),
|
||||
class_token: tokenSchema.nullable(),
|
||||
filter_offset: z.number().int().min(0).nullable(),
|
||||
});
|
||||
|
||||
const managedInstructionAnchorSchema = z.object({
|
||||
il_offset: z.number().int().min(0),
|
||||
opcode: z.string().min(1),
|
||||
operand_kind: z.enum([
|
||||
"none",
|
||||
"branch",
|
||||
"constant",
|
||||
"field",
|
||||
"method",
|
||||
"signature",
|
||||
"string",
|
||||
"switch",
|
||||
"token",
|
||||
"type",
|
||||
"variable",
|
||||
"unknown",
|
||||
]),
|
||||
operand: z.string().nullable(),
|
||||
});
|
||||
|
||||
const managedMethodBodySchema = z.object({
|
||||
status: z.enum(["present", "absent", "malformed", "too-large"]),
|
||||
header_format: z.enum(["tiny", "fat", "none", "unknown"]),
|
||||
rva: z.number().int().min(0).max(0xffff_ffff),
|
||||
file_offset: offsetSchema.nullable(),
|
||||
max_stack: z.number().int().min(0).nullable(),
|
||||
init_locals: z.boolean().nullable(),
|
||||
local_var_sig_token: tokenSchema.nullable(),
|
||||
il_size: z.number().int().min(0),
|
||||
il_sha256: digestSchema.nullable(),
|
||||
normalized_il_sha256: digestSchema.nullable(),
|
||||
instruction_count: z.number().int().min(0),
|
||||
decoded_instruction_count: z.number().int().min(0),
|
||||
truncated_instructions: z.number().int().min(0),
|
||||
opcode_counts: z.record(z.string(), z.number().int().min(1)),
|
||||
anchors: z.array(managedInstructionAnchorSchema),
|
||||
exception_regions: z.array(managedExceptionRegionSchema),
|
||||
issue: z.string().nullable(),
|
||||
});
|
||||
|
||||
const managedMethodSchema = z.object({
|
||||
token: tokenSchema,
|
||||
row_offset: offsetSchema,
|
||||
declaring_type_token: tokenSchema.nullable(),
|
||||
declaring_type: z.string().nullable(),
|
||||
name: z.string(),
|
||||
rva: z.number().int().min(0).max(0xffff_ffff),
|
||||
impl_flags: z.number().int().min(0).max(0xffff),
|
||||
flags: z.number().int().min(0).max(0xffff),
|
||||
signature: managedSignatureSchema,
|
||||
body: managedMethodBodySchema,
|
||||
});
|
||||
|
||||
const managedMemberReferenceSchema = z.object({
|
||||
token: tokenSchema,
|
||||
row_offset: offsetSchema,
|
||||
parent_token: tokenSchema.nullable(),
|
||||
name: z.string(),
|
||||
signature: managedSignatureSchema,
|
||||
});
|
||||
|
||||
const managedCallEdgeSchema = z.object({
|
||||
caller_token: tokenSchema,
|
||||
caller: z.string().nullable(),
|
||||
opcode: z.string(),
|
||||
target_token: tokenSchema,
|
||||
target_kind: z.enum(["method-def", "member-ref", "method-spec", "unknown"]),
|
||||
target_name: z.string().nullable(),
|
||||
});
|
||||
|
||||
const managedFieldAccessSchema = z.object({
|
||||
method_token: tokenSchema,
|
||||
method: z.string().nullable(),
|
||||
opcode: z.string(),
|
||||
field_token: tokenSchema,
|
||||
field_name: z.string().nullable(),
|
||||
});
|
||||
|
||||
const managedParseIssueSchema = z.object({
|
||||
code: z.enum([
|
||||
"invalid-cli-header",
|
||||
@@ -199,7 +331,46 @@ export const managedArtifactInspectionSchema = z.object({
|
||||
limitations: z.array(z.string()),
|
||||
});
|
||||
|
||||
/** Provider-neutral, execution-free metadata/signature/IL member inspection. */
|
||||
export const managedMemberInspectionSchema = z.object({
|
||||
schema_version: z.literal(1),
|
||||
artifact: z.object({
|
||||
path: z.string().min(1),
|
||||
sha256: digestSchema,
|
||||
byte_length: z.number().int().min(0),
|
||||
format: z.literal("pe"),
|
||||
}),
|
||||
module: moduleIdentitySchema.nullable(),
|
||||
metadata: z.object({
|
||||
status: z.enum(["absent", "complete", "partial", "malformed"]),
|
||||
version: z.string().nullable(),
|
||||
table_row_counts: z.record(
|
||||
z.string(),
|
||||
z.number().int().min(0).max(0xffff_ffff),
|
||||
),
|
||||
}),
|
||||
identity_scope: z.object({
|
||||
token_identity: z.literal("build-local"),
|
||||
requires_artifact_sha256: digestSchema,
|
||||
requires_mvid: z.string().uuid().nullable(),
|
||||
}),
|
||||
types: managedPage(managedTypeSchema),
|
||||
fields: managedPage(managedFieldSchema),
|
||||
methods: managedPage(managedMethodSchema),
|
||||
member_refs: managedPage(managedMemberReferenceSchema),
|
||||
call_edges: managedPage(managedCallEdgeSchema),
|
||||
field_accesses: managedPage(managedFieldAccessSchema),
|
||||
coverage: z.object({
|
||||
state: z.enum(["complete", "partial", "unavailable"]),
|
||||
issues: z.array(managedParseIssueSchema),
|
||||
}),
|
||||
limitations: z.array(z.string()),
|
||||
});
|
||||
|
||||
export type ManagedArtifactInspection = z.infer<
|
||||
typeof managedArtifactInspectionSchema
|
||||
>;
|
||||
export type ManagedMemberInspection = z.infer<
|
||||
typeof managedMemberInspectionSchema
|
||||
>;
|
||||
export type ManagedParseIssue = z.infer<typeof managedParseIssueSchema>;
|
||||
|
||||
Reference in New Issue
Block a user