From 9d2b0a93d909dde08ebec7d58988e92fa3ea5d89 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:39:45 -0800 Subject: [PATCH] Packaging: unsigned Windows builds the caller asked for print a notice sign.ps1 printed "Windows signing secrets not set" as a ::warning:: annotation in every workflow that builds without signing secrets, including the Windows ARM64 package job, which has none by design. A caller that wants unsigned output now sets CRAFT_ALLOW_UNSIGNED=1, and the same message is printed as a ::notice:: instead. Without the variable the warning stays. Any other value is rejected with an error. -Required still refuses to run without signing material. The signing suite checks the warning without the variable, the notice with CRAFT_ALLOW_UNSIGNED=1, and the error for other values. --- packaging/windows/nightly-signing-tests.ps1 | 23 +++++++++++++++++++++ packaging/windows/sign.ps1 | 15 ++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/packaging/windows/nightly-signing-tests.ps1 b/packaging/windows/nightly-signing-tests.ps1 index 51a8e2ade9..535ad4e222 100644 --- a/packaging/windows/nightly-signing-tests.ps1 +++ b/packaging/windows/nightly-signing-tests.ps1 @@ -73,6 +73,29 @@ try { Clear-SigningFixtures Write-Output 'PASS: supported-configuration-presence-without-signing' + # The unsigned message is captured here, so it does not become an annotation of this job. + $optInFile = Join-Path $root 'opt-in-sentinel.exe' + [IO.File]::WriteAllText($optInFile, 'generated sentinel, not a real executable') + $savedActions = $env:GITHUB_ACTIONS + try { + $env:GITHUB_ACTIONS = 'true' + $env:CRAFT_ALLOW_UNSIGNED = $null + $default = (& $sign $optInFile) -join "`n" + Assert-Policy ($default.Contains('::warning::Windows signing secrets not set')) "unsigned output without the opt-in must warn; got: $default" + $env:CRAFT_ALLOW_UNSIGNED = '1' + $optedIn = (& $sign $optInFile) -join "`n" + Assert-Policy ($optedIn.Contains('::notice::Windows signing secrets not set')) "opted-in unsigned output must be a notice; got: $optedIn" + Assert-Policy (-not $optedIn.Contains('::warning::')) "opted-in unsigned output must not warn; got: $optedIn" + foreach ($value in @('true', '0', 'yes')) { + $env:CRAFT_ALLOW_UNSIGNED = $value + Invoke-Refusal { & $sign $optInFile } 'CRAFT_ALLOW_UNSIGNED must be 1 or unset' + } + } finally { + $env:CRAFT_ALLOW_UNSIGNED = $null + $env:GITHUB_ACTIONS = $savedActions + } + Write-Output 'PASS: opted-in-unsigned-output-is-a-notice' + # Load the policy function without signing. These objects are not crypto evidence. . $sign -CheckOnly foreach ($value in @($null, [pscustomobject]@{Status='NotSigned';SignerCertificate='fixture'}, [pscustomobject]@{Status='HashMismatch';SignerCertificate='fixture'}, [pscustomobject]@{Status='Valid';SignerCertificate=$null})) { diff --git a/packaging/windows/sign.ps1 b/packaging/windows/sign.ps1 index 11a391dd60..2a768c7338 100644 --- a/packaging/windows/sign.ps1 +++ b/packaging/windows/sign.ps1 @@ -9,7 +9,8 @@ AZURE_SIGNING_ENDPOINT (e.g. https://eus.codesigning.azure.net), AZURE_SIGNING_ACCOUNT, AZURE_CERT_PROFILE With neither, it prints a warning and leaves the files unsigned (exit code 0), so test builds - still produce installers. Nightly callers require signing with -Required and can check the + still produce installers. A caller that builds unsigned on purpose sets CRAFT_ALLOW_UNSIGNED=1, + and the message is then a notice instead of a warning. Nightly callers require signing with -Required and can check the signing configuration with -Required -CheckOnly. Compilation uses the separate -CheckBuildEnvironment mode, which refuses any signing material without importing a key. @@ -38,6 +39,10 @@ function Write-Warn([string] $Message) { if ($env:GITHUB_ACTIONS) { Write-Output "::warning::$Message" } else { Write-Warning $Message } } +function Write-Note([string] $Message) { + if ($env:GITHUB_ACTIONS) { Write-Output "::notice::$Message" } else { Write-Output $Message } +} + function Find-SignTool { if ($env:SIGNTOOL) { return $env:SIGNTOOL } $onPath = Get-Command signtool.exe -ErrorAction SilentlyContinue @@ -64,6 +69,11 @@ if ($CheckBuildEnvironment) { } return } +$allowUnsigned = switch -CaseSensitive ([string]$env:CRAFT_ALLOW_UNSIGNED) { + '' { $false } + '1' { $true } + default { throw "CRAFT_ALLOW_UNSIGNED must be 1 or unset, got '$env:CRAFT_ALLOW_UNSIGNED'" } +} $haveCert = [bool]$env:WINDOWS_CERTIFICATE $haveAzure = -not ($azureVars | Where-Object { -not [Environment]::GetEnvironmentVariable($_) }) @@ -78,7 +88,8 @@ if (-not $Files) { throw 'At least one file is required for signing' } $Files = $Files | ForEach-Object { (Resolve-Path $_).Path } if (-not $haveCert -and -not $haveAzure) { - Write-Warn "Windows signing secrets not set (WINDOWS_CERTIFICATE or AZURE_*): leaving unsigned: $($Files -join ', ')" + $message = "Windows signing secrets not set (WINDOWS_CERTIFICATE or AZURE_*): leaving unsigned: $($Files -join ', ')" + if ($allowUnsigned) { Write-Note $message } else { Write-Warn $message } exit 0 }