mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
* build(scripts): type-check the Evidence verification scripts against src Six JavaScript callers kept passing `undefined` as an Evidence subject after `createEvidence` stopped accepting it (#11536); `npm run typecheck` saw only the TypeScript callers. The scripts import built modules by relative `../dist/` paths, which a checker resolves to the built JavaScript (or nothing, before a build) rather than the source types. A package-private `#dist/*` import alias resolves to `./dist/*` at run time, and `tsconfig.scripts.json` maps it to `./src/*` and checks the listed scripts with `checkJs` under the main compiler options. `typecheck`, and so `check:fast`, runs it; turbo's typecheck inputs include the scripts and the new config. First slice: `verify-package-evidence.mjs` (its evidence-bundle import becomes static), `verify/javascript/output.mjs` and `verify/javascript/digests.mjs`, with the JSDoc types the check required. Refs #11545 * build(scripts): type-check the MCP verifier results and Ghidra snapshot lifecycle helpers (#11590) * build(scripts): type-check the managed app manifest verifier (#11592) * build(scripts): type-check the managed oracles and completion report (#11605) oracles.mjs and completion-report.mjs join tsconfig.scripts.json (72 errors). ensureIlspy is an assertion function, the ILSpy import returns the imported Evidence and reads its normalized result through managedReconstructionImportResultSchema, the manifest-rejection controls are named records walked by a checked field lookup, and the completion report names its input.
214 lines
6.4 KiB
JavaScript
214 lines
6.4 KiB
JavaScript
import { createEvidence } from "#dist/domain/evidence.js";
|
|
import { unknownTarget } from "#dist/domain/targetIdentity.js";
|
|
|
|
/** @typedef {import("#dist/domain/binaryTargetTypes.js").BinaryTarget} BinaryTarget */
|
|
/** @typedef {import("#dist/domain/evidence.js").EvidenceSubjectTarget} EvidenceSubjectTarget */
|
|
/**
|
|
* A verified file as the manifest verifier and ILSpy oracle report it.
|
|
* @typedef {{ readonly file_name: string; readonly sha256: string }} ReportedTarget
|
|
*/
|
|
/**
|
|
* A source-owned fixture the conformance run wrote and resolved.
|
|
* @typedef {{ readonly target: BinaryTarget }} ResolvedFixture
|
|
*/
|
|
/**
|
|
* The completed conformance observations the claims are projected from.
|
|
* @typedef {{
|
|
* readonly modern: ResolvedFixture;
|
|
* readonly framework: ResolvedFixture;
|
|
* readonly nativeFunctionTarget: EvidenceSubjectTarget;
|
|
* readonly readyToRun: ResolvedFixture;
|
|
* readonly obfuscated: ResolvedFixture;
|
|
* readonly left: ResolvedFixture;
|
|
* readonly right: ResolvedFixture;
|
|
* readonly nativeOnly: ResolvedFixture;
|
|
* readonly malformed: ResolvedFixture;
|
|
* readonly manifestSelfTest: { readonly target: ReportedTarget };
|
|
* readonly operatorManifest: { readonly target: ReportedTarget } | null;
|
|
* readonly ilspyOracle: { readonly fixture: ReportedTarget } | null;
|
|
* }} ManagedCompletionReportInput
|
|
*/
|
|
|
|
const COMPLETION_PROVIDER = {
|
|
id: "rea-managed-conformance",
|
|
name: "REA managed conformance verifier",
|
|
version: "1",
|
|
};
|
|
|
|
/**
|
|
* @param {{
|
|
* readonly claimId: string;
|
|
* readonly scenarioId: string;
|
|
* readonly targets?: readonly (BinaryTarget | EvidenceSubjectTarget)[];
|
|
* readonly status?: "pass" | "unsupported";
|
|
* readonly limitations?: readonly string[];
|
|
* }} claim
|
|
*/
|
|
const completionClaim = ({
|
|
claimId,
|
|
scenarioId,
|
|
targets = [],
|
|
status = "pass",
|
|
limitations = [],
|
|
}) => {
|
|
const artifactSha256s = [
|
|
...new Set(targets.map(({ sha256: digest }) => digest)),
|
|
].sort();
|
|
const evidence = createEvidence(
|
|
// A claim without an observed artifact (an unsupported optional
|
|
// scenario) names no file.
|
|
targets[0] ?? unknownTarget("not-observed"),
|
|
COMPLETION_PROVIDER,
|
|
{
|
|
predicateType: "rea.verification",
|
|
operation: "verify_managed_conformance",
|
|
parameters: {
|
|
scenario_id: scenarioId,
|
|
scenario_version: 1,
|
|
artifact_sha256s: artifactSha256s,
|
|
},
|
|
result: { status },
|
|
rawResult: null,
|
|
limitations,
|
|
},
|
|
);
|
|
return {
|
|
claim_id: claimId,
|
|
scenario: { id: scenarioId, version: 1 },
|
|
artifact_sha256s: artifactSha256s,
|
|
provider: {
|
|
id: COMPLETION_PROVIDER.id,
|
|
version: COMPLETION_PROVIDER.version,
|
|
},
|
|
status,
|
|
evidence_ids: [evidence.evidence_id],
|
|
};
|
|
};
|
|
|
|
/**
|
|
* @param {ReportedTarget | undefined} target
|
|
* @returns {EvidenceSubjectTarget[]}
|
|
*/
|
|
const optionalTarget = (target) =>
|
|
target === undefined
|
|
? []
|
|
: [{ path: target.file_name, sha256: target.sha256, format: "pe" }];
|
|
|
|
/** @param {ManagedCompletionReportInput} input */
|
|
const sourceOwnedClaims = ({
|
|
modern,
|
|
framework,
|
|
nativeFunctionTarget,
|
|
readyToRun,
|
|
obfuscated,
|
|
left,
|
|
right,
|
|
nativeOnly,
|
|
malformed,
|
|
manifestSelfTest,
|
|
}) => [
|
|
completionClaim({
|
|
claimId: "managed.modern-dotnet-anycpu",
|
|
scenarioId: "modern-dotnet-anycpu",
|
|
targets: [modern.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.dotnet-framework-x86-pinvoke",
|
|
scenarioId: "dotnet-framework-x86-pinvoke",
|
|
targets: [framework.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.x64-ready-to-run-native-body",
|
|
scenarioId: "x64-ready-to-run-native-body",
|
|
targets: [readyToRun.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.managed-native-verification",
|
|
scenarioId: "managed-native-verification",
|
|
targets: [framework.target, nativeFunctionTarget],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.application-graph-projection",
|
|
scenarioId: "managed-application-graph-projection",
|
|
targets: [framework.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.unicode-obfuscated-identifiers",
|
|
scenarioId: "unicode-obfuscated-identifiers",
|
|
targets: [obfuscated.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.decompiler-reconstruction-import",
|
|
scenarioId: "decompiler-reconstruction-import",
|
|
targets: [obfuscated.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.mvid-and-token-drift",
|
|
scenarioId: "mvid-and-token-drift",
|
|
targets: [left.target, right.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.not-managed",
|
|
scenarioId: "not-managed",
|
|
targets: [nativeOnly.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.malformed-metadata",
|
|
scenarioId: "malformed-metadata",
|
|
targets: [malformed.target],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.operator-manifest-self-test",
|
|
scenarioId: "operator-manifest-self-test",
|
|
targets: [
|
|
{
|
|
path: manifestSelfTest.target.file_name,
|
|
sha256: manifestSelfTest.target.sha256,
|
|
format: "pe",
|
|
},
|
|
],
|
|
}),
|
|
];
|
|
|
|
/** @param {ManagedCompletionReportInput} input */
|
|
const optionalClaims = ({ operatorManifest, ilspyOracle }) => [
|
|
completionClaim({
|
|
claimId: "managed.operator-local-manifest",
|
|
scenarioId: "operator-local-manifest",
|
|
targets: optionalTarget(operatorManifest?.target),
|
|
status: operatorManifest === null ? "unsupported" : "pass",
|
|
limitations:
|
|
operatorManifest === null
|
|
? ["REA_MANAGED_APP_MANIFEST_PATH is not configured."]
|
|
: [],
|
|
}),
|
|
completionClaim({
|
|
claimId: "managed.ilspy-reconstruction-oracle",
|
|
scenarioId: "ilspy-reconstruction-oracle",
|
|
targets: optionalTarget(ilspyOracle?.fixture),
|
|
status: ilspyOracle === null ? "unsupported" : "pass",
|
|
limitations:
|
|
ilspyOracle === null ? ["REA_ILSPY_CMD_PATH is not configured."] : [],
|
|
}),
|
|
];
|
|
|
|
/**
|
|
* Project completed managed assertions into the standard verifier report.
|
|
* @param {ManagedCompletionReportInput} input
|
|
* @param {unknown} verifierRun The completed run record, reported unchanged.
|
|
*/
|
|
export const createManagedCompletionReport = (input, verifierRun) => ({
|
|
verifier: {
|
|
id: COMPLETION_PROVIDER.id,
|
|
version: COMPLETION_PROVIDER.version,
|
|
},
|
|
verifier_run: verifierRun,
|
|
environment: {
|
|
platform: process.platform,
|
|
architecture: process.arch,
|
|
runtime: "node",
|
|
runtime_version: process.versions.node.split(".")[0],
|
|
},
|
|
claims: [...sourceOwnedClaims(input), ...optionalClaims(input)],
|
|
});
|