fix(managed): budget decoding before representation expansion
Validation: integrated changes passed formatting, typecheck, lint, resolved module-boundary verification and git diff --check. Tests and real-provider workflows were not run.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { admitManagedProjection } from "./ManagedDecodeBudget.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
|
||||
import {
|
||||
managedNativeBoundaryInspectionSchema,
|
||||
@@ -47,39 +48,45 @@ const emptyInspection = (
|
||||
readonly issues?: readonly ManagedParseIssue[];
|
||||
} = {},
|
||||
): ManagedNativeBoundaryInspection => {
|
||||
return managedNativeBoundaryInspectionSchema.parse({
|
||||
artifact: {
|
||||
path: target.path,
|
||||
sha256: target.sha256,
|
||||
byte_length: bytes.length,
|
||||
format: "pe",
|
||||
},
|
||||
module: null,
|
||||
metadata: {
|
||||
status: classification === "malformed" ? "malformed" : "absent",
|
||||
version: null,
|
||||
table_row_counts: {},
|
||||
},
|
||||
identity_scope: {
|
||||
token_identity: "build-local",
|
||||
requires_artifact_sha256: target.sha256,
|
||||
requires_mvid: null,
|
||||
},
|
||||
cli_native: native,
|
||||
module_refs: [],
|
||||
pinvoke_imports: [],
|
||||
native_implementations: [],
|
||||
summary: nativeBoundarySummary(native, {
|
||||
module_ref_count: 0,
|
||||
pinvoke_import_count: 0,
|
||||
native_implementation_count: 0,
|
||||
return managedNativeBoundaryInspectionSchema.parse(
|
||||
admitManagedProjection({
|
||||
artifact: {
|
||||
path: target.path,
|
||||
sha256: target.sha256,
|
||||
byte_length: bytes.length,
|
||||
format: "pe",
|
||||
},
|
||||
module: null,
|
||||
metadata: {
|
||||
status: issues.some((issue) => issue.code === "resource-limit")
|
||||
? "partial"
|
||||
: classification === "malformed"
|
||||
? "malformed"
|
||||
: "absent",
|
||||
version: null,
|
||||
table_row_counts: {},
|
||||
},
|
||||
identity_scope: {
|
||||
token_identity: "build-local",
|
||||
requires_artifact_sha256: target.sha256,
|
||||
requires_mvid: null,
|
||||
},
|
||||
cli_native: native,
|
||||
module_refs: [],
|
||||
pinvoke_imports: [],
|
||||
native_implementations: [],
|
||||
summary: nativeBoundarySummary(native, {
|
||||
module_ref_count: 0,
|
||||
pinvoke_import_count: 0,
|
||||
native_implementation_count: 0,
|
||||
}),
|
||||
coverage: { state: "unavailable", issues },
|
||||
limitations: [
|
||||
"No CLI metadata was admitted; native boundary declarations are unavailable.",
|
||||
"Static inspection does not load or execute target code, so native export resolution is not performed.",
|
||||
],
|
||||
}),
|
||||
coverage: { state: "unavailable", issues },
|
||||
limitations: [
|
||||
"No CLI metadata was admitted; native boundary declarations are unavailable.",
|
||||
"Static inspection does not load or execute target code, so native export resolution is not performed.",
|
||||
],
|
||||
});
|
||||
);
|
||||
};
|
||||
|
||||
const readBoundaryInventory = (
|
||||
@@ -142,40 +149,48 @@ export const inspectManagedNativeBoundariesBytes = (
|
||||
issues: [cause.issue],
|
||||
});
|
||||
}
|
||||
const heapExtent = Math.max(layout.strings.size, layout.blob.size);
|
||||
issues.push(...inventory.issues);
|
||||
const moduleRefs = parseModuleRefs(bytes, layout, heapExtent, issues);
|
||||
const members = new Map([
|
||||
...parseFields(bytes, layout, heapExtent, issues),
|
||||
...parseMethods(bytes, layout, heapExtent, issues),
|
||||
]);
|
||||
const imports = parseImplMaps({
|
||||
bytes,
|
||||
layout,
|
||||
heapExtent,
|
||||
modules: moduleRefs,
|
||||
members,
|
||||
issues,
|
||||
});
|
||||
const pinvokeTokens = new Set(
|
||||
imports
|
||||
.map(({ member_token }) => member_token)
|
||||
.filter((token): token is string => token !== null),
|
||||
);
|
||||
const implementations = nativeImplementations(
|
||||
members.values(),
|
||||
pinvokeTokens,
|
||||
);
|
||||
return buildNativeBoundaryInspection({
|
||||
target,
|
||||
bytes,
|
||||
pe,
|
||||
layout,
|
||||
inventory,
|
||||
moduleRefs,
|
||||
imports,
|
||||
implementations,
|
||||
native: cliNative(pe),
|
||||
issues,
|
||||
});
|
||||
try {
|
||||
const heapExtent = Math.max(layout.strings.size, layout.blob.size);
|
||||
issues.push(...inventory.issues);
|
||||
const moduleRefs = parseModuleRefs(bytes, layout, heapExtent, issues);
|
||||
const members = new Map([
|
||||
...parseFields(bytes, layout, heapExtent, issues),
|
||||
...parseMethods(bytes, layout, heapExtent, issues),
|
||||
]);
|
||||
const imports = parseImplMaps({
|
||||
bytes,
|
||||
layout,
|
||||
heapExtent,
|
||||
modules: moduleRefs,
|
||||
members,
|
||||
issues,
|
||||
});
|
||||
const pinvokeTokens = new Set(
|
||||
imports
|
||||
.map(({ member_token }) => member_token)
|
||||
.filter((token): token is string => token !== null),
|
||||
);
|
||||
const implementations = nativeImplementations(
|
||||
members.values(),
|
||||
pinvokeTokens,
|
||||
);
|
||||
return buildNativeBoundaryInspection({
|
||||
target,
|
||||
bytes,
|
||||
pe,
|
||||
layout,
|
||||
inventory,
|
||||
moduleRefs,
|
||||
imports,
|
||||
implementations,
|
||||
native: cliNative(pe),
|
||||
issues,
|
||||
});
|
||||
} catch (cause: unknown) {
|
||||
if (!(cause instanceof ManagedReaderFailure)) throw cause;
|
||||
return emptyInspection(target, bytes, "malformed", {
|
||||
native: cliNative(pe),
|
||||
issues: [...issues, cause.issue],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user