fix(managed): bind inspection evidence to artifact identity

This commit is contained in:
morluto
2026-10-09 05:15:23 +08:00
parent dbcf8c3391
commit 73b09f4c5c
8 changed files with 222 additions and 35 deletions
@@ -60,6 +60,54 @@ const nativeEvidenceWithExports = (names: readonly string[]) => {
);
};
describe("managed/native boundary Evidence identity", () => {
it("rejects managed boundary Evidence whose subject digest differs from its artifact", () => {
const input = exampleInput();
const managed = input.managed_boundaries;
const result = managedNativeBoundaryInspectionSchema.parse(
managed.normalized_result,
);
const otherDigest = "b".repeat(64);
const mismatched = createEvidence(
{
path: result.artifact.path,
sha256: result.artifact.sha256,
format: "pe",
},
managed.provider,
{
operation: managed.operation,
parameters: managed.parameters,
result: {
...result,
artifact: { ...result.artifact, sha256: otherDigest },
identity_scope: {
...result.identity_scope,
requires_artifact_sha256: otherDigest,
},
},
rawResult: managed.raw_result,
confidence: managed.confidence,
authority: managed.authority,
environment: managed.environment,
limitations: managed.limitations,
locations: managed.locations,
evidenceLinks: managed.evidence_links,
},
);
expect(() =>
verifyManagedNativeBoundaries({
...input,
managed_boundaries: mismatched,
}),
).toThrow(
`Managed Evidence inspect_managed_native_boundaries (${mismatched.evidence_id}) subject SHA-256 ${result.artifact.sha256} does not match normalized artifact SHA-256 ${otherDigest}`,
);
expect(verifyManagedNativeBoundaries(input).summary.verified).toBe(1);
});
});
describe("managed/native boundary verification", () => {
it("verifies a P/Invoke declaration against native export Evidence", () => {
const result = verifyManagedNativeBoundaries(exampleInput());