feat(dotnet): import managed reconstructions

This commit is contained in:
N0zoM1z0
2026-07-16 20:37:42 +09:00
committed by N0zoM1z0
parent 798631ade6
commit c506664744
88 changed files with 1251 additions and 212 deletions
+46 -8
View File
@@ -9,6 +9,7 @@ import { inspectManagedArtifactBytes } from "../dist/dotnet/ManagedArtifactInspe
import { inspectManagedMembersBytes } from "../dist/dotnet/ManagedMemberInspector.js";
import { inspectManagedNativeBoundariesBytes } from "../dist/dotnet/ManagedNativeBoundaryInspector.js";
import { compareManagedMemberPaths } from "../dist/application/ManagedMemberComparisonService.js";
import { importManagedReconstructionEvidence } from "../dist/application/ManagedReconstructionService.js";
import { planManagedRuntimeCorrelationEvidence } from "../dist/application/ManagedRuntimeCorrelationService.js";
import { createPermissionAuthority } from "../dist/application/PermissionAuthority.js";
import { MANAGED_STATIC_PROVIDER } from "../dist/application/InvestigationProviders.js";
@@ -207,6 +208,47 @@ try {
assert.equal(runtimeAuthority.ok, true);
const runtimeMethod = obfuscatedMembers.methods.items[0];
assert.ok(runtimeMethod);
const obfuscatedMembersEvidence = createEvidence(
undefined,
MANAGED_STATIC_PROVIDER,
{
operation: "inspect_managed_members",
parameters: { path: obfuscated.path },
result: obfuscatedMembers,
rawResult: null,
limitations: obfuscatedMembers.limitations,
},
);
const reconstructionImport = importManagedReconstructionEvidence({
static_members: obfuscatedMembersEvidence,
decompiler: {
name: "ilspycmd",
version: "9.1.0.7988",
family: "ilspy",
executable_sha256: null,
options: ["--type", "Fixture.ꙮType"],
},
methods: [
{
token: runtimeMethod.token,
signature_sha256: runtimeMethod.signature.raw_sha256,
normalized_il_sha256: runtimeMethod.body.normalized_il_sha256,
reconstruction: {
kind: "decompiled-csharp",
language: "csharp",
text: "internal static void λ⛧() { /* synthetic fixture */ }",
},
},
],
notes: ["source-owned synthetic decompiler reconstruction"],
});
assert.equal(reconstructionImport.ok, true);
assert.equal(
reconstructionImport.value.normalized_result.methods[0].validation
.canonical_observation,
false,
);
assert.equal(reconstructionImport.value.confidence, "inferred");
const runtimePlan = await planManagedRuntimeCorrelationEvidence(
{
policy: {
@@ -217,13 +259,7 @@ try {
authority: runtimeAuthority.value,
},
{
static_members: createEvidence(undefined, MANAGED_STATIC_PROVIDER, {
operation: "inspect_managed_members",
parameters: { path: obfuscated.path },
result: obfuscatedMembers,
rawResult: null,
limitations: obfuscatedMembers.limitations,
}),
static_members: obfuscatedMembersEvidence,
method: {
token: runtimeMethod.token,
signature_sha256: runtimeMethod.signature.raw_sha256,
@@ -311,12 +347,13 @@ try {
process.stdout.write(
`${JSON.stringify({
verified: 8,
verified: 9,
managedSurfaces: [
"inspect_managed_artifact",
"inspect_managed_members",
"inspect_managed_native_boundaries",
"compare_managed_members",
"import_managed_reconstruction",
"plan_managed_runtime_correlation",
],
coverage: [
@@ -324,6 +361,7 @@ try {
"dotnet-framework-x86-pinvoke",
"x64-ready-to-run-native-body",
"unicode-obfuscated-identifiers",
"decompiler-reconstruction-import",
"runtime-correlation-admission-plan",
"mvid-and-token-drift",
"not-managed",
+43 -1
View File
@@ -266,6 +266,48 @@ try {
)
throw new Error("packaged managed member CLI failed");
const managedMethod = managedMembers.normalized_result.methods.items[0];
const managedReconstructionInput = {
static_members: managedMembers,
decompiler: {
name: "ilspycmd",
version: "9.1.0.7988",
family: "ilspy",
executable_sha256: null,
options: ["--type", "Fixture.Program"],
},
methods: [
{
token: managedMethod.token,
signature_sha256: managedMethod.signature.raw_sha256,
normalized_il_sha256: managedMethod.body.normalized_il_sha256,
reconstruction: {
kind: "decompiled-csharp",
language: "csharp",
text: "internal static void Main() { }",
},
},
],
notes: ["packaged synthetic reconstruction import"],
};
const managedReconstruction = json(
await run(
cli,
[
"import-managed-reconstruction",
JSON.stringify(managedReconstructionInput),
"--json",
],
environment,
),
);
if (
managedReconstruction.operation !== "import_managed_reconstruction" ||
managedReconstruction.provider?.id !== "rea-dotnet-workflows" ||
managedReconstruction.normalized_result?.executed !== false ||
managedReconstruction.normalized_result?.methods?.[0]?.validation
?.canonical_observation !== false
)
throw new Error("packaged managed reconstruction import CLI failed");
const managedRuntimePlanInput = {
static_members: managedMembers,
method: {
@@ -894,7 +936,7 @@ try {
}
process.stdout.write(
`${JSON.stringify({ cli: true, analysisCli: true, artifactCli: true, managedCli: true, managedRuntimePlanCli: true, evidenceCli: true, incurMcpCommand: "npx -y rea-agents mcp", doctor: "platform-appropriate", setup: supportedSetupHost ? "planned-then-idempotent" : "unsupported-host-rejected", setupPlanReadOnly: supportedSetupHost, existingHopperPreserved: supportedSetupHost, clients: supportedSetupHost ? 3 : 0, backupReadback: supportedSetupHost, failureRecovery: supportedSetupHost, configSymlinkLifecycle: supportedSetupHost, skill: supportedSetupHost, mcpTools: TOOL_CONTRACTS.length, mcpPrompts: prompts.names.length, promptCompletion: true, promptCompletionLifecycle: true, evidenceMcp: true, targetFree: true, targetLifecycle: true, boundedRegexBridge: true })}\n`,
`${JSON.stringify({ cli: true, analysisCli: true, artifactCli: true, managedCli: true, managedReconstructionCli: true, managedRuntimePlanCli: true, evidenceCli: true, incurMcpCommand: "npx -y rea-agents mcp", doctor: "platform-appropriate", setup: supportedSetupHost ? "planned-then-idempotent" : "unsupported-host-rejected", setupPlanReadOnly: supportedSetupHost, existingHopperPreserved: supportedSetupHost, clients: supportedSetupHost ? 3 : 0, backupReadback: supportedSetupHost, failureRecovery: supportedSetupHost, configSymlinkLifecycle: supportedSetupHost, skill: supportedSetupHost, mcpTools: TOOL_CONTRACTS.length, mcpPrompts: prompts.names.length, promptCompletion: true, promptCompletionLifecycle: true, evidenceMcp: true, targetFree: true, targetLifecycle: true, boundedRegexBridge: true })}\n`,
);
} finally {
if (tarball) await rm(join(root, tarball), { force: true });