Files
aevolution/tools/client/verify-windows-package.ps1
T
dingoandClaude Opus 5.5 6262c778c7 Add M9.8e reproducible Windows client package
Static-runtime client-package preset with /Brepro and a build identity printed by
evo-client --version (ADR-0086). tools/client packages an explicit allowlist with
licence texts from the verified sources, BUILD-INFO and SHA256SUMS into a
deterministic ZIP, refusing credentials, profile paths and non-system imports;
verification runs the extracted client without Visual Studio, and a self-test
proves each guard. Publication via Gitea Actions waits for a Windows runner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 16:48:12 -04:00

75 lines
4.8 KiB
PowerShell

# M9.8e package verification (ADR-0086). Needs no Visual Studio: extracts the ZIP into
# a fresh directory, checks the ZIP digest, SHA256SUMS and exact content, image
# imports and credentials, then runs the client from the extracted folder with a
# minimal environment (system PATH only, settings in the scratch directory).
param(
[Parameter(Mandatory = $true)][string]$Zip,
# Also open a real window with the default video driver and renderer for 3 s.
[switch]$Interactive
)
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'package-common.ps1')
Add-Type -AssemblyName System.IO.Compression.FileSystem
$Zip = (Resolve-Path -LiteralPath $Zip).Path
$expected = ([IO.File]::ReadAllText("$Zip.sha256") -split '\s+')[0]
if ((Get-Sha256 $Zip) -ne $expected) { throw 'ZIP digest does not match its .sha256 file' }
$scratch = Join-Path ([IO.Path]::GetTempPath()) ("evo-package-verify-" + [Guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory $scratch | Out-Null
try {
[IO.Compression.ZipFile]::ExtractToDirectory($Zip, (Join-Path $scratch 'x'))
$top = @(Get-ChildItem -LiteralPath (Join-Path $scratch 'x') -Force)
if ($top.Count -ne 1 -or !$top[0].PSIsContainer) { throw 'The ZIP must contain exactly one top-level folder' }
$folder = $top[0].FullName
Assert-PackageContent $folder
Assert-NoSecrets $folder
foreach ($binary in @('evo-client.exe', 'SDL3.dll')) { Assert-AllowedImports (Join-Path $folder $binary) }
$identity = ([IO.File]::ReadAllLines((Join-Path $folder 'BUILD-INFO.txt')) | Where-Object { $_ -like 'identity: *' }) -replace '^identity: ', ''
if ($top[0].Name -ne "evo-client-windows-x64-$identity") { throw 'Folder name does not match BUILD-INFO identity' }
# Runs the extracted client with only the Windows system directories on PATH.
$controls = Join-Path $scratch 'controls-v1.txt'
$run = {
param([string[]]$Arguments, [string]$VideoDriver, [int]$TimeoutSeconds = 60)
$info = New-Object Diagnostics.ProcessStartInfo
$info.FileName = Join-Path $folder 'evo-client.exe'
$info.Arguments = ($Arguments | ForEach-Object { '"' + $_ + '"' }) -join ' '
$info.WorkingDirectory = $scratch
$info.UseShellExecute = $false
$info.RedirectStandardOutput = $true
$info.RedirectStandardError = $true
$info.EnvironmentVariables['PATH'] = "$env:SystemRoot\System32;$env:SystemRoot"
foreach ($name in @('SDL_VIDEO_DRIVER', 'SDL_RENDER_DRIVER')) { $info.EnvironmentVariables.Remove($name) }
if ($VideoDriver) { $info.EnvironmentVariables['SDL_VIDEO_DRIVER'] = $VideoDriver }
$process = [Diagnostics.Process]::Start($info)
$stdout = $process.StandardOutput.ReadToEndAsync()
$stderr = $process.StandardError.ReadToEndAsync()
if (!$process.WaitForExit($TimeoutSeconds * 1000)) { $process.Kill(); throw "evo-client $($info.Arguments) timed out" }
[pscustomobject]@{ Code = $process.ExitCode; Out = $stdout.Result; Err = $stderr.Result }
}
$version = & $run @('--version') ''
if ($version.Code -ne 0 -or $version.Out -notmatch [regex]::Escape("evo-client $identity ") -or
$version.Out -notmatch 'remote sessions available') { throw "--version failed: $($version.Out)$($version.Err)" }
$usage = & $run @('--no-such-option') ''
if ($usage.Code -ne 2 -or $usage.Err -notmatch 'usage: evo-client') { throw 'Usage error path failed' }
$fixture = & $run @('--renderer', 'software', '--fixture', '--frames', '60', '--controls', $controls) 'dummy'
if ($fixture.Code -ne 0) { throw "Fixture run failed ($($fixture.Code)): $($fixture.Err)" }
$launcher = & $run @('--renderer', 'software', '--frames', '30', '--controls', $controls) 'dummy'
if ($launcher.Code -ne 0) { throw "Launcher run failed ($($launcher.Code)): $($launcher.Err)" }
$badCa = & $run @('--frames', '1', '--connect', '127.0.0.1:1', '--server-name', 'x', '--ca',
(Join-Path $scratch 'missing.pem'), '--grants', (Join-Path $scratch 'missing.bin'), '--controls', $controls) 'dummy'
if ($badCa.Code -ne 1 -or $badCa.Err -notmatch 'dev CA file could not be read' -or $badCa.Err -match [regex]::Escape($scratch)) {
throw 'Missing credential files must fail with fixed text and no path'
}
if ($Interactive) {
$window = & $run @('--fixture', '--frames', '180', '--controls', $controls) ''
if ($window.Code -ne 0) { throw "Interactive run failed ($($window.Code)): $($window.Err)" }
}
# Running must not write into the package folder (no ini/log/settings there).
Assert-PackageContent $folder
if (Test-Path -LiteralPath $controls) { throw 'A controls file was written without Apply' }
Write-Output "verified: $([IO.Path]::GetFileName($Zip)) ($identity)"
} finally {
Remove-Item -LiteralPath $scratch -Recurse -Force -ErrorAction SilentlyContinue
}