mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-12-05 02:25:59 +00:00
Warn when uv predates the eMudhra intermediate-key fix (#1172)
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>
This commit is contained in:
1 parent
1b7eca8c42
commit
390b79e1c2
4 files changed
+114
-1
No files matched your search
@@ -0,0 +1,83 @@
|
|||||||
|
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 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
+11
@@ -103322,6 +103322,7 @@ function emptyToUndefined(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/version/resolve.ts
|
// src/version/resolve.ts
|
||||||
|
var EMUDHRA_FIXED_VERSION = "0.13.5";
|
||||||
var ExactVersionResolver = class {
|
var ExactVersionResolver = class {
|
||||||
async resolve(context3) {
|
async resolve(context3) {
|
||||||
if (context3.parsedSpecifier.kind !== "exact") {
|
if (context3.parsedSpecifier.kind !== "exact") {
|
||||||
@@ -103389,6 +103390,15 @@ async function resolveUvVersion(options, source) {
|
|||||||
);
|
);
|
||||||
return version3;
|
return version3;
|
||||||
}
|
}
|
||||||
|
function warnIfUvVersionPredatesEmudhraFix(version3) {
|
||||||
|
if (semver5.satisfies(version3, `<${EMUDHRA_FIXED_VERSION}`, {
|
||||||
|
includePrerelease: true
|
||||||
|
})) {
|
||||||
|
warning2(
|
||||||
|
`uv ${version3} predates the fix that blocks the compromised eMudhra intermediate keys. Upgrade to uv ${EMUDHRA_FIXED_VERSION} or later.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
async function resolveVersion(versionInput, source, resolutionStrategy = "highest") {
|
async function resolveVersion(versionInput, source, resolutionStrategy = "highest") {
|
||||||
debug(`Resolving version: ${versionInput}`);
|
debug(`Resolving version: ${versionInput}`);
|
||||||
if (versionInput.trim() === "latest-known") {
|
if (versionInput.trim() === "latest-known") {
|
||||||
@@ -103523,6 +103533,7 @@ async function run() {
|
|||||||
throw new Error(`Unsupported architecture: ${process.arch}`);
|
throw new Error(`Unsupported architecture: ${process.arch}`);
|
||||||
}
|
}
|
||||||
const setupResult = await setupUv(inputs, platform2, arch3);
|
const setupResult = await setupUv(inputs, platform2, arch3);
|
||||||
|
warnIfUvVersionPredatesEmudhraFix(setupResult.version);
|
||||||
const uvPath = path17.join(
|
const uvPath = path17.join(
|
||||||
setupResult.uvDir,
|
setupResult.uvDir,
|
||||||
process.platform === "win32" ? "uv.exe" : "uv"
|
process.platform === "win32" ? "uv.exe" : "uv"
|
||||||
|
|||||||
+6
-1
@@ -24,7 +24,10 @@ import {
|
|||||||
} from "./utils/platforms";
|
} from "./utils/platforms";
|
||||||
import { setupPythonArch } from "./utils/python-arch";
|
import { setupPythonArch } from "./utils/python-arch";
|
||||||
import { getPythonRuntimeId } from "./utils/python-runtime";
|
import { getPythonRuntimeId } from "./utils/python-runtime";
|
||||||
import { resolveUvVersion } from "./version/resolve";
|
import {
|
||||||
|
resolveUvVersion,
|
||||||
|
warnIfUvVersionPredatesEmudhraFix,
|
||||||
|
} from "./version/resolve";
|
||||||
|
|
||||||
const sourceDir = __dirname;
|
const sourceDir = __dirname;
|
||||||
|
|
||||||
@@ -93,6 +96,8 @@ async function run(): Promise<void> {
|
|||||||
throw new Error(`Unsupported architecture: ${process.arch}`);
|
throw new Error(`Unsupported architecture: ${process.arch}`);
|
||||||
}
|
}
|
||||||
const setupResult = await setupUv(inputs, platform, arch);
|
const setupResult = await setupUv(inputs, platform, arch);
|
||||||
|
warnIfUvVersionPredatesEmudhraFix(setupResult.version);
|
||||||
|
|
||||||
const uvPath = path.join(
|
const uvPath = path.join(
|
||||||
setupResult.uvDir,
|
setupResult.uvDir,
|
||||||
process.platform === "win32" ? "uv.exe" : "uv",
|
process.platform === "win32" ? "uv.exe" : "uv",
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import {
|
|||||||
import type { ResolveUvVersionOptions } from "./types";
|
import type { ResolveUvVersionOptions } from "./types";
|
||||||
import { resolveVersionRequest } from "./version-request-resolver";
|
import { resolveVersionRequest } from "./version-request-resolver";
|
||||||
|
|
||||||
|
const EMUDHRA_FIXED_VERSION = "0.13.5";
|
||||||
|
|
||||||
interface ConcreteVersionResolutionContext {
|
interface ConcreteVersionResolutionContext {
|
||||||
source: ManifestSource;
|
source: ManifestSource;
|
||||||
parsedSpecifier: ParsedVersionSpecifier;
|
parsedSpecifier: ParsedVersionSpecifier;
|
||||||
@@ -137,6 +139,18 @@ export async function resolveUvVersion(
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function warnIfUvVersionPredatesEmudhraFix(version: string): void {
|
||||||
|
if (
|
||||||
|
semver.satisfies(version, `<${EMUDHRA_FIXED_VERSION}`, {
|
||||||
|
includePrerelease: true,
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
log.warning(
|
||||||
|
`uv ${version} predates the fix that blocks the compromised eMudhra intermediate keys. Upgrade to uv ${EMUDHRA_FIXED_VERSION} or later.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function resolveVersion(
|
export async function resolveVersion(
|
||||||
versionInput: string,
|
versionInput: string,
|
||||||
source: ManifestSource,
|
source: ManifestSource,
|
||||||
|
|||||||
Reference in new issue
Block a user