Verify downloads with astral-sh/versions checksums (#1033)

`setup-uv` currently ignores the `sha256` supplied by the default
`astral-sh/versions` manifest when a selected artifact is newer than its
bundled checksum table, allowing that download to proceed without
validation. Use the manifest checksum as a fallback after explicit and
bundled checksums, and reject manifest entries that do not provide one.
This preserves the stronger pinned hashes for known releases while
verifying newer releases without requiring an action update. Part of
#1032.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: William Woodruff <william@yossarian.net>
Co-authored-by: Kevin Stillhammer <kevin.stillhammer@gmail.com>
This commit is contained in:
zaniebot
2026-09-01 10:07:32 -05:00
committed by GitHub
parent 3aef7b92c5
commit cd13f92170
6 changed files with 96 additions and 14 deletions

View File

@@ -11,19 +11,30 @@ export async function validateChecksum(
arch: Architecture,
platform: Platform,
version: string,
manifestChecksum?: string,
): Promise<void> {
const key = `${arch}-${platform}-${version}`;
const hasProvidedChecksum = checksum !== undefined && checksum !== "";
const checksumToUse = hasProvidedChecksum ? checksum : KNOWN_CHECKSUMS[key];
const knownChecksum = KNOWN_CHECKSUMS[key];
const hasManifestChecksum =
manifestChecksum !== undefined && manifestChecksum !== "";
const checksumToUse = hasProvidedChecksum
? checksum
: (knownChecksum ?? (hasManifestChecksum ? manifestChecksum : undefined));
if (checksumToUse === undefined) {
if (manifestChecksum !== undefined) {
throw new Error(`No checksum found for ${key} in manifest.`);
}
core.debug(`No checksum found for ${key}.`);
return;
}
const checksumSource = hasProvidedChecksum
? "provided checksum"
: `KNOWN_CHECKSUMS entry for ${key}`;
: knownChecksum !== undefined
? `KNOWN_CHECKSUMS entry for ${key}`
: "manifest checksum";
core.debug(`Validating checksum using ${checksumSource}.`);
const isValid = await validateFileCheckSum(downloadPath, checksumToUse);