Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m25s
Foundation / postgres-tools (push) Successful in 5s
Foundation / image (push) Successful in 5s
Foundation / server-image (push) Successful in 5s
The ADR-0131 browser sign-in and grant broker requests link winhttp.dll, a Windows
system DLL, but the package's import allowlist predates them, so package-windows.ps1
refused evo-client.exe ("imports winhttp.dll, which is not an allowed system DLL").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
146 lines
6.4 KiB
PowerShell
146 lines
6.4 KiB
PowerShell
# Shared by package-windows.ps1 and verify-windows-package.ps1 (ADR-0086).
|
|
# Windows PowerShell 5.1 compatible; no Visual Studio needed for verification.
|
|
Set-StrictMode -Version Latest
|
|
|
|
# Exact package content (relative paths). Anything else fails packaging/verification.
|
|
$script:PackageFiles = @(
|
|
'BUILD-INFO.txt',
|
|
'LICENSES/Apache-2.0.txt',
|
|
'LICENSES/DearImGui-FONTS.md',
|
|
'LICENSES/DearImGui-embedded-fonts.txt',
|
|
'LICENSES/DearImGui-stb.txt',
|
|
'LICENSES/DearImGui.txt',
|
|
'LICENSES/Khronos.txt',
|
|
'LICENSES/MbedTLS.txt',
|
|
'LICENSES/OpenSSL.txt',
|
|
'LICENSES/SDL3-hidapi.txt',
|
|
'LICENSES/SDL3-stb_image.txt',
|
|
'LICENSES/SDL3-yuv2rgb.txt',
|
|
'LICENSES/SDL3.txt',
|
|
'LICENSES/msquic.txt',
|
|
'README.txt',
|
|
'SDL3.dll',
|
|
'SHA256SUMS.txt',
|
|
'THIRD-PARTY-NOTICES.txt',
|
|
'evo-client.exe',
|
|
'msquic.dll'
|
|
)
|
|
# Imports allowed for the executables: Windows system DLLs and the bundled SDL3.dll and
|
|
# msquic.dll (M10.5c). The C/C++ runtime is static (no MSVCP/VCRUNTIME/api-ms-win-crt/
|
|
# ucrtbase), in msquic.dll too. winhttp.dll carries the Keycloak sign-in and grant broker
|
|
# requests (ADR-0131).
|
|
$script:AllowedImports = @(
|
|
'advapi32.dll', 'bcrypt.dll', 'crypt32.dll', 'gdi32.dll', 'imm32.dll', 'iphlpapi.dll',
|
|
'kernel32.dll', 'msquic.dll', 'ncrypt.dll', 'ntdll.dll', 'ole32.dll', 'oleaut32.dll',
|
|
'sdl3.dll', 'setupapi.dll', 'shell32.dll', 'user32.dll', 'version.dll', 'winmm.dll',
|
|
'winhttp.dll', 'ws2_32.dll'
|
|
)
|
|
# Every shipped image whose imports are checked.
|
|
$script:PackageImages = @('evo-client.exe', 'SDL3.dll', 'msquic.dll')
|
|
|
|
function Get-Sha256([string]$Path) {
|
|
(Get-FileHash -Algorithm SHA256 -LiteralPath $Path).Hash.ToLowerInvariant()
|
|
}
|
|
|
|
function Get-RelativeFiles([string]$Root) {
|
|
$prefix = (Resolve-Path -LiteralPath $Root).Path.TrimEnd('\') + '\'
|
|
Get-ChildItem -LiteralPath $Root -Recurse -File -Force | ForEach-Object {
|
|
$_.FullName.Substring($prefix.Length).Replace('\', '/')
|
|
} | Sort-Object -CaseSensitive
|
|
}
|
|
|
|
# Names of DLLs in the import and delay-import tables of a PE32+ image.
|
|
function Get-PeImports([string]$Path) {
|
|
$bytes = [IO.File]::ReadAllBytes($Path)
|
|
$pe = [BitConverter]::ToInt32($bytes, 0x3C)
|
|
if ([BitConverter]::ToUInt32($bytes, $pe) -ne 0x4550) { throw "Not a PE image: $Path" }
|
|
$sections = [BitConverter]::ToUInt16($bytes, $pe + 6)
|
|
$optionalSize = [BitConverter]::ToUInt16($bytes, $pe + 20)
|
|
$optional = $pe + 24
|
|
if ([BitConverter]::ToUInt16($bytes, $optional) -ne 0x20B) { throw "Not PE32+ (x64): $Path" }
|
|
$table = $optional + $optionalSize
|
|
$toOffset = {
|
|
param([uint32]$rva)
|
|
for ($i = 0; $i -lt $sections; ++$i) {
|
|
$s = $table + 40 * $i
|
|
$size = [Math]::Max([BitConverter]::ToUInt32($bytes, $s + 8), [BitConverter]::ToUInt32($bytes, $s + 16))
|
|
$address = [BitConverter]::ToUInt32($bytes, $s + 12)
|
|
if ($rva -ge $address -and $rva -lt $address + $size) {
|
|
return [int]($rva - $address + [BitConverter]::ToUInt32($bytes, $s + 20))
|
|
}
|
|
}
|
|
throw "RVA outside sections in $Path"
|
|
}
|
|
$readName = {
|
|
param([uint32]$rva)
|
|
$start = & $toOffset $rva
|
|
$end = [Array]::IndexOf($bytes, [byte]0, $start)
|
|
[Text.Encoding]::ASCII.GetString($bytes, $start, $end - $start)
|
|
}
|
|
$names = New-Object System.Collections.Generic.List[string]
|
|
# Data directories start at optional+112 (PE32+): [1] imports, [13] delay imports.
|
|
foreach ($entry in @(@{ Index = 1; Stride = 20; Name = 12 }, @{ Index = 13; Stride = 32; Name = 4 })) {
|
|
$rva = [BitConverter]::ToUInt32($bytes, $optional + 112 + 8 * $entry.Index)
|
|
if ($rva -eq 0) { continue }
|
|
$at = & $toOffset $rva
|
|
$n = 0
|
|
while ($true) {
|
|
if (++$n -gt 4096) { throw "Unterminated import table in $Path" }
|
|
$nameRva = [BitConverter]::ToUInt32($bytes, $at + $entry.Name)
|
|
if ($nameRva -eq 0) { break }
|
|
$names.Add((& $readName $nameRva).ToLowerInvariant())
|
|
$at += $entry.Stride
|
|
}
|
|
}
|
|
$names | Sort-Object -Unique
|
|
}
|
|
|
|
function Assert-AllowedImports([string]$Path) {
|
|
foreach ($name in (Get-PeImports $Path)) {
|
|
if ($script:AllowedImports -notcontains $name) {
|
|
throw "$([IO.Path]::GetFileName($Path)) imports $name, which is not an allowed system DLL"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Refuses credential material and developer profile paths in any staged file.
|
|
function Assert-NoSecrets([string]$Root) {
|
|
$forbidden = @('.pem', '.key', '.crt', '.cer', '.der', '.p12', '.pfx', '.bin', '.env', '.ini', '.json')
|
|
foreach ($relative in (Get-RelativeFiles $Root)) {
|
|
if ($forbidden -contains [IO.Path]::GetExtension($relative).ToLowerInvariant()) {
|
|
throw "Credential-like file type staged: $relative"
|
|
}
|
|
$text = [Text.Encoding]::GetEncoding(28591).GetString([IO.File]::ReadAllBytes((Join-Path $Root $relative)))
|
|
if ($text -match '-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----\s*[A-Za-z0-9+/=]{32}') {
|
|
throw "Private key material found in $relative"
|
|
}
|
|
if ($text -match '-----BEGIN CERTIFICATE-----\s*[A-Za-z0-9+/=]{32}') {
|
|
throw "Certificate found in $relative"
|
|
}
|
|
if ($text -match '(?i)[A-Z]:[\\/]Users[\\/]') {
|
|
throw "A user profile path is embedded in $relative"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Checks SHA256SUMS.txt against the folder and that the folder holds exactly the
|
|
# expected files.
|
|
function Assert-PackageContent([string]$Root) {
|
|
$files = @(Get-RelativeFiles $Root)
|
|
$expected = @($script:PackageFiles | Sort-Object -CaseSensitive)
|
|
if (Compare-Object $files $expected -CaseSensitive) {
|
|
throw "Package content differs from the allowlist: $((Compare-Object $files $expected -CaseSensitive | ForEach-Object { $_.InputObject }) -join ', ')"
|
|
}
|
|
$listed = @{}
|
|
foreach ($line in [IO.File]::ReadAllLines((Join-Path $Root 'SHA256SUMS.txt'))) {
|
|
if ($line -notmatch '^([0-9a-f]{64}) (\S+)$') { throw "Malformed SHA256SUMS line: $line" }
|
|
$listed[$matches[2]] = $matches[1]
|
|
}
|
|
foreach ($relative in $expected) {
|
|
if ($relative -eq 'SHA256SUMS.txt') { continue }
|
|
if (!$listed.ContainsKey($relative)) { throw "Not in SHA256SUMS.txt: $relative" }
|
|
if ((Get-Sha256 (Join-Path $Root $relative)) -ne $listed[$relative]) { throw "Checksum mismatch: $relative" }
|
|
}
|
|
if ($listed.Count -ne $expected.Count - 1) { throw 'SHA256SUMS.txt lists unexpected files' }
|
|
}
|