Skip to content

Commit e3c2e88

Browse files
Copilotbytemain
andauthored
Use SHA256 length constant
Agent-Logs-Url: https://github.com/version-fox/vfox-python/sessions/130dc982-32c0-4ae6-8db0-e62d21f8918d Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent 2c1d335 commit e3c2e88

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

lib/util.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ end
1414
local version_vault_url = "https://vault.vfox.dev/python/pyenv"
1515
local uv_build_vault_url = "https://vault.vfox.dev/python/uv-build"
1616
local UV_BUILD_GITHUB_RELEASE_PATTERN = "/releases/download/([^/]+)/([^/]+)$"
17+
local SHA256_HEX_LENGTH = 64
1718

1819
-- request headers
1920
local REQUEST_HEADERS = {
@@ -462,18 +463,15 @@ local function verifyUvBuildArchive(path, sha256)
462463
error("Unable to verify uv-build archive sha256 for " .. path .. ": certutil command could not be started")
463464
end
464465

465-
local readOk, output = pcall(function()
466-
local data = handle:read("*a")
467-
handle:close()
468-
return data
469-
end)
470-
if not readOk or output == nil then
466+
local output = handle:read("*a")
467+
handle:close()
468+
if output == nil then
471469
error("Unable to verify uv-build archive sha256 for " .. path .. ": failed to read certutil output")
472470
end
473471
local actualSha256
474472
for line in string.gmatch(output, "[^\r\n]+") do
475473
local normalizedLine = string.gsub(string.lower(line), "%s+", "")
476-
if string.match(normalizedLine, "^[0-9a-f]+$") and string.len(normalizedLine) == 64 then
474+
if string.match(normalizedLine, "^[0-9a-f]+$") and string.len(normalizedLine) == SHA256_HEX_LENGTH then
477475
actualSha256 = normalizedLine
478476
break
479477
end

0 commit comments

Comments
 (0)