mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-09-02 21:59:22 +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:
co-authored by
Zanie Blue
William Woodruff
Kevin Stillhammer
parent
3aef7b92c5
commit
cd13f92170
@@ -26,9 +26,49 @@ test("provided checksum beats known checksums", async () => {
|
||||
"x86_64",
|
||||
"unknown-linux-gnu",
|
||||
"0.3.0",
|
||||
"incorrect-manifest-checksum",
|
||||
);
|
||||
});
|
||||
|
||||
test("known checksums beat manifest checksums", async () => {
|
||||
await expect(
|
||||
validateChecksum(
|
||||
undefined,
|
||||
filePath,
|
||||
"x86_64",
|
||||
"unknown-linux-gnu",
|
||||
"0.3.0",
|
||||
validChecksum,
|
||||
),
|
||||
).rejects.toThrow("did not match");
|
||||
});
|
||||
|
||||
test("manifest checksums are used when no known checksum exists", async () => {
|
||||
await expect(
|
||||
validateChecksum(
|
||||
undefined,
|
||||
filePath,
|
||||
"aarch64",
|
||||
"pc-windows-msvc",
|
||||
"1.2.3",
|
||||
"incorrect-manifest-checksum",
|
||||
),
|
||||
).rejects.toThrow("did not match");
|
||||
});
|
||||
|
||||
test("empty manifest checksums are rejected", async () => {
|
||||
await expect(
|
||||
validateChecksum(
|
||||
undefined,
|
||||
filePath,
|
||||
"aarch64",
|
||||
"pc-windows-msvc",
|
||||
"1.2.3",
|
||||
"",
|
||||
),
|
||||
).rejects.toThrow("No checksum found");
|
||||
});
|
||||
|
||||
type KnownVersionFixture = { version: string; known: boolean };
|
||||
|
||||
it.each<KnownVersionFixture>([
|
||||
|
||||
@@ -227,10 +227,10 @@ describe("download-version", () => {
|
||||
expect(mockValidateChecksum).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("uses built-in checksums for default manifest downloads", async () => {
|
||||
it("uses the default manifest checksum as a fallback", async () => {
|
||||
mockGetArtifact.mockResolvedValue({
|
||||
archiveFormat: "tar.gz",
|
||||
checksum: "manifest-checksum-that-should-be-ignored",
|
||||
checksum: "manifest-checksum",
|
||||
downloadUrl: "https://example.com/uv.tar.gz",
|
||||
});
|
||||
|
||||
@@ -248,6 +248,7 @@ describe("download-version", () => {
|
||||
"x86_64",
|
||||
"unknown-linux-gnu",
|
||||
"0.9.26",
|
||||
"manifest-checksum",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -400,6 +401,7 @@ describe("download-version", () => {
|
||||
"x86_64",
|
||||
"unknown-linux-gnu",
|
||||
"0.9.26",
|
||||
"manifest-checksum",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -425,6 +427,7 @@ describe("download-version", () => {
|
||||
"x86_64",
|
||||
"unknown-linux-gnu",
|
||||
"0.9.26",
|
||||
"manifest-checksum",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user