feat(artifacts): name the integrity check for target digests, Apple bundle readers and extraction (#11125)

This commit is contained in:
morluto authored and GitHub committed 2026-11-15 21:05:00 +08:00
1 parent 682a57a987
commit 6363881faa
13 files changed
+82 -34

No files matched your search

+14 -7
View File
@@ -8,6 +8,7 @@ import {
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import { hashStableRootArtifactHandle } from "../artifacts/inventory/hashStableRootArtifact.js";
import { targetDigestChangedFailure } from "../artifacts/withArtifactTargetIdentity.js";
/** A positional reader for one slice of the descriptor bound to the target. */
export interface NativeMachoSource {
@@ -37,9 +38,13 @@ export class NativeMachoSourceVerificationFailure extends ArtifactReaderFailure
: String(verificationCause),
{
cause: verificationCause,
...(verificationCause instanceof ArtifactReaderFailure &&
verificationCause.cancellation !== undefined
? { cancellation: verificationCause.cancellation }
...(verificationCause instanceof ArtifactReaderFailure
? {
...verificationCause.primaryFacts(),
...(verificationCause.cancellation === undefined
? {}
: { cancellation: verificationCause.cancellation }),
}
: {}),
},
verificationCause instanceof ArtifactReaderFailure
@@ -82,14 +87,15 @@ export const withNativeMachoSource = <T>(
throw new ArtifactReaderFailure(
"integrity",
`Active Mach-O target changed: ${target.path}`,
{ cause },
{ cause, integrityCheck: "container-identity" },
);
throw cause;
});
if (digest.sha256 !== target.sha256)
throw new ArtifactReaderFailure(
"integrity",
`Active Mach-O target digest changed: expected ${target.sha256}, observed ${digest.sha256}`,
throw targetDigestChangedFailure(
"Mach-O target",
target.sha256,
digest.sha256,
);
};
await verify();
@@ -122,6 +128,7 @@ export const withNativeMachoSource = <T>(
throw new ArtifactReaderFailure(
"integrity",
"Mach-O source changed during slice read.",
{ integrityCheck: "read-coverage" },
);
return bytes;
},