mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-12-05 02:25:59 +00:00
This implements the idea in #1171. TL;DR we now warn if the user explicitly requests an older uv version that doesn't reject the compromised eMudhra intermediates. <details> <summary>Automated notes</summary> - Warn when the selected uv version predates 0.13.5, which added rejection of certificate chains containing the compromised eMudhra intermediate keys. The warning appears in quiet mode and setup continues. [uv 0.13.5 release notes](https://github.com/astral-sh/uv/releases/tag/0.13.5#security) - Regenerate the published bundle and test versions on both sides of the cutoff. All 189 tests passed with `npm run all` on Node 24.22.1. Closes #1171 </details>
84 lines
2.9 KiB
TypeScript
84 lines
2.9 KiB
TypeScript
import { ok } from "node:assert/strict";
|
|
import { execFileSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { expect, it } from "@jest/globals";
|
|
import { getArch } from "../../src/utils/platforms";
|
|
|
|
const bundle = fileURLToPath(
|
|
new URL("../../dist/setup/index.cjs", import.meta.url),
|
|
);
|
|
|
|
it.each([
|
|
{ fromConfig: true, version: "0.13.4", warns: true },
|
|
{ fromConfig: false, version: "0.13.5-rc.1", warns: true },
|
|
{ fromConfig: false, version: "0.13.5", warns: false },
|
|
{ fromConfig: false, version: "0.13.10", warns: false },
|
|
])(
|
|
"sets up uv $version with eMudhra warning: $warns",
|
|
({ version, fromConfig, warns }) => {
|
|
const arch = getArch();
|
|
ok(arch);
|
|
const dir = fs.mkdtempSync(path.join(tmpdir(), "setup-uv-emudhra-"));
|
|
try {
|
|
const toolCache = path.join(dir, "cache");
|
|
const cachedUv = path.join(toolCache, "uv", version, arch);
|
|
fs.mkdirSync(cachedUv, { recursive: true });
|
|
fs.writeFileSync(`${cachedUv}.complete`, "");
|
|
if (fromConfig) {
|
|
fs.writeFileSync(
|
|
path.join(dir, "uv.toml"),
|
|
`required-version = "==${version}"\n`,
|
|
);
|
|
}
|
|
const outputFile = path.join(dir, "output");
|
|
fs.writeFileSync(outputFile, "");
|
|
|
|
const stdout = execFileSync(process.execPath, [bundle], {
|
|
encoding: "utf8",
|
|
env: {
|
|
GITHUB_OUTPUT: outputFile,
|
|
"INPUT_ACTIVATE-ENVIRONMENT": "false",
|
|
// Keep the test offline even if the tool-cache lookup misses.
|
|
"INPUT_MANIFEST-FILE": "data:application/x-ndjson,",
|
|
"INPUT_NO-PROJECT": "false",
|
|
// Skip Python discovery so the action never executes the cached uv.
|
|
"INPUT_PYTHON-VERSION": "3.13",
|
|
INPUT_QUIET: "true",
|
|
"INPUT_REQUIRE-CHECKSUMS": "false",
|
|
INPUT_VERSION: fromConfig ? "" : version,
|
|
"INPUT_WORKING-DIRECTORY": dir,
|
|
PATH: process.env.PATH,
|
|
RUNNER_TEMP: dir,
|
|
RUNNER_TOOL_CACHE: toolCache,
|
|
SystemRoot: process.env.SystemRoot,
|
|
UV_NO_MODIFY_PATH: "1",
|
|
UV_PYTHON_INSTALL_DIR: path.join(dir, "python"),
|
|
},
|
|
timeout: 10_000,
|
|
});
|
|
|
|
const warnings = stdout
|
|
.split(/\r?\n/)
|
|
.filter(
|
|
(line) => line.startsWith("::warning::") && line.includes("eMudhra"),
|
|
);
|
|
expect(warnings).toEqual(
|
|
warns
|
|
? [
|
|
`::warning::uv ${version} predates the fix that blocks the compromised eMudhra intermediate keys. Upgrade to uv 0.13.5 or later.`,
|
|
]
|
|
: [],
|
|
);
|
|
const outputs = fs.readFileSync(outputFile, "utf8");
|
|
expect(outputs.match(/^uv-version<<[^\r\n]+\r?\n([^\r\n]+)/m)?.[1]).toBe(
|
|
version,
|
|
);
|
|
} finally {
|
|
fs.rmSync(dir, { force: true, recursive: true });
|
|
}
|
|
},
|
|
);
|