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>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# M9.8e negative checks for the package guards (ADR-0086). Copies a staged package
|
||||
# folder, applies one defect at a time and requires each guard to refuse it.
|
||||
# Usage: package-selftest.ps1 -Staged build\packages\<name> [-DynamicRuntimeImage FILE]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Staged,
|
||||
# An image linked against the dynamic MSVC runtime (e.g. build\client-network\evo-client.exe).
|
||||
[string]$DynamicRuntimeImage = ''
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot 'package-common.ps1')
|
||||
$utf8 = New-Object Text.UTF8Encoding $false
|
||||
$failures = 0
|
||||
function Expect-Refused([string]$Label, [scriptblock]$Mutate, [scriptblock]$Check) {
|
||||
$copy = Join-Path ([IO.Path]::GetTempPath()) ("evo-package-selftest-" + [Guid]::NewGuid().ToString('N'))
|
||||
Copy-Item -LiteralPath $Staged -Destination $copy -Recurse
|
||||
try {
|
||||
& $Mutate $copy
|
||||
$refused = $false
|
||||
try { & $Check $copy } catch { $refused = $true; Write-Output "refused ($Label): $($_.Exception.Message)" }
|
||||
if (!$refused) { Write-Output "NOT REFUSED: $Label"; $script:failures++ }
|
||||
} finally { Remove-Item -LiteralPath $copy -Recurse -Force }
|
||||
}
|
||||
$content = { param($p) Assert-PackageContent $p }
|
||||
$secrets = { param($p) Assert-NoSecrets $p }
|
||||
|
||||
# Baseline: the untouched copy passes every guard.
|
||||
Assert-PackageContent $Staged
|
||||
Assert-NoSecrets $Staged
|
||||
foreach ($binary in @('evo-client.exe', 'SDL3.dll')) { Assert-AllowedImports (Join-Path $Staged $binary) }
|
||||
|
||||
Expect-Refused 'extra file' { param($p) [IO.File]::WriteAllText((Join-Path $p 'notes.txt'), 'x', $utf8) } $content
|
||||
Expect-Refused 'missing file' { param($p) Remove-Item -LiteralPath (Join-Path $p 'LICENSES\SDL3.txt') } $content
|
||||
Expect-Refused 'checksum mismatch' { param($p) [IO.File]::AppendAllText((Join-Path $p 'README.txt'), ' ', $utf8) } $content
|
||||
Expect-Refused 'credential file type' { param($p) [IO.File]::WriteAllText((Join-Path $p 'dev-ca.pem'), 'x', $utf8) } $secrets
|
||||
Expect-Refused 'grant bundle file type' { param($p) [IO.File]::WriteAllBytes((Join-Path $p 'client-grants.bin'), [byte[]]::new(108)) } $secrets
|
||||
Expect-Refused 'private key text' {
|
||||
param($p) [IO.File]::AppendAllText((Join-Path $p 'README.txt'),
|
||||
"-----BEGIN EC PRIVATE KEY-----`nMHcCAQEEIBbF0p3l9QpKl2+abcdefghijklmnopqrstuvwxyzABCDEFG`n", $utf8) } $secrets
|
||||
Expect-Refused 'certificate text' {
|
||||
param($p) [IO.File]::AppendAllText((Join-Path $p 'BUILD-INFO.txt'),
|
||||
"-----BEGIN CERTIFICATE-----`nMIIBkTCB+wIJAKHBfpE7d1cRMA0GCSqGSIb3DQEBCwUAMBExDzANBgNVBAMM`n", $utf8) } $secrets
|
||||
Expect-Refused 'user profile path' {
|
||||
param($p) [IO.File]::AppendAllText((Join-Path $p 'BUILD-INFO.txt'), "C:\Users\someone\build`n", $utf8) } $secrets
|
||||
if ($DynamicRuntimeImage) {
|
||||
$refused = $false
|
||||
try { Assert-AllowedImports $DynamicRuntimeImage } catch { $refused = $true; Write-Output "refused (dynamic runtime): $($_.Exception.Message)" }
|
||||
if (!$refused) { Write-Output 'NOT REFUSED: dynamic runtime image'; $failures++ }
|
||||
}
|
||||
if ($failures -ne 0) { throw "$failures package guard(s) did not refuse a defect" }
|
||||
Write-Output 'package guard self-test passed'
|
||||
Reference in New Issue
Block a user