Skip to content

Commit f590d94

Browse files
Copilotbytemain
andauthored
Use Get-FileHash for Windows uv-build sha256
Agent-Logs-Url: https://github.com/version-fox/vfox-python/sessions/5852e539-b06d-4c0c-b5d1-b981726a91d9 Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent e3c2e88 commit f590d94

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

.github/workflows/vfox-test.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ jobs:
149149
VFOX_PYTHON_USE_UV_BUILD: "1"
150150
run: |
151151
Invoke-Expression "$(vfox activate pwsh)"
152-
vfox install python@3.10.20
152+
$install_output = vfox install python@3.10.20 2>&1
153+
$install_output | Write-Output
154+
if ($LASTEXITCODE -ne 0 -or ($install_output -join "`n") -like "*failed to install python*") {
155+
exit 1
156+
}
153157
vfox use -g python@3.10.20
154158
vfox current
155159

lib/util.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ local function shellQuote(value)
246246
return "'" .. string.gsub(value, "'", "'\\''") .. "'"
247247
end
248248

249+
local function powershellQuote(value)
250+
if string.find(value, "[\r\n%z]") then
251+
error("Path contains unsupported control character: " .. value)
252+
end
253+
if string.find(value, "%.%.%/") or string.find(value, "%.%.\\") then
254+
error("Path contains unsupported traversal segment: " .. value)
255+
end
256+
257+
return "'" .. string.gsub(value, "'", "''") .. "'"
258+
end
259+
249260
local function startsWith(value, prefix)
250261
return string.sub(value, 1, string.len(prefix)) == prefix
251262
end
@@ -458,15 +469,17 @@ local function verifyUvBuildArchive(path, sha256)
458469

459470
local status
460471
if RUNTIME.osType == "windows" or OS_TYPE == "windows" then
461-
local handle = io.popen("certutil -hashfile " .. shellQuote(path) .. " SHA256")
472+
local command = "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command " ..
473+
shellQuote("(Get-FileHash -LiteralPath " .. powershellQuote(path) .. " -Algorithm SHA256).Hash")
474+
local handle = io.popen(command)
462475
if handle == nil then
463-
error("Unable to verify uv-build archive sha256 for " .. path .. ": certutil command could not be started")
476+
error("Unable to verify uv-build archive sha256 for " .. path .. ": powershell Get-FileHash command could not be started")
464477
end
465478

466479
local output = handle:read("*a")
467480
handle:close()
468481
if output == nil then
469-
error("Unable to verify uv-build archive sha256 for " .. path .. ": failed to read certutil output")
482+
error("Unable to verify uv-build archive sha256 for " .. path .. ": failed to read Get-FileHash output")
470483
end
471484
local actualSha256
472485
for line in string.gmatch(output, "[^\r\n]+") do

0 commit comments

Comments
 (0)