mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-10-02 00:35:59 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user