diff --git a/__tests__/version/emudhra-warning-bundle.test.ts b/__tests__/version/emudhra-warning-bundle.test.ts new file mode 100644 index 0000000..55cabd9 --- /dev/null +++ b/__tests__/version/emudhra-warning-bundle.test.ts @@ -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 }); + } + }, +); diff --git a/dist/setup/index.cjs b/dist/setup/index.cjs index dc3879b..e1e7411 100644 --- a/dist/setup/index.cjs +++ b/dist/setup/index.cjs @@ -103322,6 +103322,7 @@ function emptyToUndefined(value) { } // src/version/resolve.ts +var EMUDHRA_FIXED_VERSION = "0.13.5"; var ExactVersionResolver = class { async resolve(context3) { if (context3.parsedSpecifier.kind !== "exact") { @@ -103389,6 +103390,15 @@ async function resolveUvVersion(options, source) { ); 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") { debug(`Resolving version: ${versionInput}`); if (versionInput.trim() === "latest-known") { @@ -103523,6 +103533,7 @@ async function run() { throw new Error(`Unsupported architecture: ${process.arch}`); } const setupResult = await setupUv(inputs, platform2, arch3); + warnIfUvVersionPredatesEmudhraFix(setupResult.version); const uvPath = path17.join( setupResult.uvDir, process.platform === "win32" ? "uv.exe" : "uv" diff --git a/src/setup-uv.ts b/src/setup-uv.ts index e441537..47acfc7 100644 --- a/src/setup-uv.ts +++ b/src/setup-uv.ts @@ -24,7 +24,10 @@ import { } from "./utils/platforms"; import { setupPythonArch } from "./utils/python-arch"; import { getPythonRuntimeId } from "./utils/python-runtime"; -import { resolveUvVersion } from "./version/resolve"; +import { + resolveUvVersion, + warnIfUvVersionPredatesEmudhraFix, +} from "./version/resolve"; const sourceDir = __dirname; @@ -93,6 +96,8 @@ async function run(): Promise { throw new Error(`Unsupported architecture: ${process.arch}`); } const setupResult = await setupUv(inputs, platform, arch); + warnIfUvVersionPredatesEmudhraFix(setupResult.version); + const uvPath = path.join( setupResult.uvDir, process.platform === "win32" ? "uv.exe" : "uv", diff --git a/src/version/resolve.ts b/src/version/resolve.ts index e800c8f..47a5a64 100644 --- a/src/version/resolve.ts +++ b/src/version/resolve.ts @@ -17,6 +17,8 @@ import { import type { ResolveUvVersionOptions } from "./types"; import { resolveVersionRequest } from "./version-request-resolver"; +const EMUDHRA_FIXED_VERSION = "0.13.5"; + interface ConcreteVersionResolutionContext { source: ManifestSource; parsedSpecifier: ParsedVersionSpecifier; @@ -137,6 +139,18 @@ export async function resolveUvVersion( 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( versionInput: string, source: ManifestSource,