Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions .github/actions/setup-certum/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,24 @@ runs:
CERTUM_OTP_URI: ${{ inputs.otp-uri }}
CERTUM_KEY_ID: ${{ inputs.thumbprint }}
run: node "${{ github.action_path }}/../../../scripts/validate-certum-configuration.mjs"
- name: Verify SimplySign installer
- name: Install verified SimplySign client
shell: pwsh
run: '& "${{ github.action_path }}/../../../scripts/certum/Install-SimplySign.ps1"'
- name: Authenticate cloud certificate
shell: pwsh
env:
CERTUM_USERNAME: ${{ inputs.username }}
CERTUM_OTP_URI: ${{ inputs.otp-uri }}
CERTUM_KEY_ID: ${{ inputs.thumbprint }}
CAPTURE_DIAGNOSTICS: 'false'
run: '& "${{ github.action_path }}/../../../scripts/certum/Connect-SimplySign.ps1"'
- name: Verify expected signing certificate
shell: pwsh
env:
CERTUM_KEY_ID: ${{ inputs.thumbprint }}
run: |
$ErrorActionPreference = 'Stop'
Invoke-WebRequest 'https://files.certum.eu/software/SimplySignDesktop/Windows/9.4.3.90/SimplySignDesktop-9.4.3.90-64-bit-en.msi' -OutFile SimplySignDesktop.msi
$hash = (Get-FileHash -Algorithm SHA256 SimplySignDesktop.msi).Hash
if ($hash -ne 'CE2B38EF0124A574BC08E5558726099CAAC79A7C58B8D3D712F629371FE1BCB7') {
throw 'SimplySign installer SHA-256 does not match the pinned 9.4.3.90 build'
$certificate = @(Get-ChildItem Cert:\CurrentUser\My | Where-Object { $_.Thumbprint -eq $env:CERTUM_KEY_ID -and $_.EnhancedKeyUsageList -like '*Code Signing*' })
if ($certificate.Count -ne 1 -or $certificate[0].NotAfter -le (Get-Date) -or $certificate[0].NotBefore -gt (Get-Date)) {
throw 'Expected current Certum code-signing certificate is unavailable.'
}
$signature = Get-AuthenticodeSignature SimplySignDesktop.msi
if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'Asseco Data Systems') {
throw 'SimplySign installer signature or publisher verification failed'
}
- name: Authenticate cloud certificate
uses: dismine/windows-app-signing-setup-action@89ae3b032d4bc7a5b98d1a42a34e61ecb6faad64
with:
certum-username: ${{ inputs.username }}
certum-otp-uri: ${{ inputs.otp-uri }}
certum-key-id: ${{ inputs.thumbprint }}
capture-diagnostics: 'false'
Write-Host 'Expected Certum code-signing certificate is available; actual signatures must still pass trust and timestamp verification.'
3 changes: 3 additions & 0 deletions .github/release-signing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ fingerprint_files:
- .github/actions/setup-certum/action.yml
- scripts/sign-certum.ps1
- scripts/validate-certum-configuration.mjs
- scripts/certum/Install-SimplySign.ps1
- scripts/certum/Connect-SimplySign.ps1
- scripts/certum-login-ui.ps1
- scripts/install-nsis.ps1
- .github/workflows/release-candidate.yml
- .github/workflows/release-promote.yml
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/certum-signing-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Certum signing smoke test

on:
workflow_dispatch:
inputs:
client_probe_only:
description: Inspect the pinned client's login controls without credentials or signing
type: boolean
default: false

permissions:
contents: read
Expand All @@ -11,8 +16,27 @@ concurrency:
cancel-in-progress: false

jobs:
client-probe:
if: github.repository == 'SivanCola/deepzora' && inputs.client_probe_only
runs-on: windows-2022
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.workflow_sha }}
persist-credentials: false
- name: Probe official client control roles without credentials
shell: pwsh
run: ./scripts/certum-client-probe.ps1
- name: Save empty client UI on probe failure
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: certum-credential-free-probe
path: simplysign-diag-*-credential-free-probe.png
retention-days: 1
sign:
if: github.repository == 'SivanCola/deepzora' && github.ref == 'refs/heads/main' && github.ref_protected
if: github.repository == 'SivanCola/deepzora' && github.ref == 'refs/heads/main' && github.ref_protected && !inputs.client_probe_only
runs-on: windows-2022
environment: release
timeout-minutes: 20
Expand Down
7 changes: 7 additions & 0 deletions LICENSING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ Explicit component licenses remain in effect, including:
merely because it renders or generates themes.
- Dependencies and bundled runtimes under their respective licenses; their
notices must be retained when required.
- The SimplySign authentication script derived from
`dismine/windows-app-signing-setup-action` at commit
`89ae3b032d4bc7a5b98d1a42a34e61ecb6faad64`; its MIT notice is preserved in
[scripts/certum/UPSTREAM-LICENSE](scripts/certum/UPSTREAM-LICENSE).

各组件明确声明的许可继续有效,包括 Harness 上游 MIT 声明、供应商和 Seti 图标
许可、明确标注 MIT 的官方主题素材与主题包数据,以及依赖和运行时各自的协议。
主题素材例外不延伸到仅因渲染或生成主题而相关的应用代码。分发时须保留适用的
第三方声明;本清单不替代逐次发布的依赖与许可核查。

SimplySign 认证脚本源自 `dismine/windows-app-signing-setup-action` 的上述固定提交,
其 MIT 版权与许可原文保留在 [UPSTREAM-LICENSE](scripts/certum/UPSTREAM-LICENSE)。

## Distribution and network use / 分发与网络使用

Commercial use, paid redistribution and independent forks are allowed subject
Expand Down
53 changes: 53 additions & 0 deletions cmd/release-signing-contract/certum_ui_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package main

import (
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
)

func TestPowerShellCertumWindowReadiness(t *testing.T) {
script, err := filepath.Abs("../../scripts/certum-login-ui.test.ps1")
if err != nil {
t.Fatal(err)
}
found := false
for _, name := range []string{"pwsh", "powershell.exe"} {
binary, err := exec.LookPath(name)
if err != nil {
continue
}
found = true
t.Run(name, func(t *testing.T) {
command := exec.Command(binary, "-NoLogo", "-NoProfile", "-NonInteractive", "-File", script)
if output, err := command.CombinedOutput(); err != nil {
t.Fatalf("Certum UI regression: %v\n%s", err, output)
}
})
}
if !found {
t.Skip("PowerShell is unavailable; Windows CI runs both PowerShell runtimes")
}
}

func TestCertumOfficialClientReadiness(t *testing.T) {
if runtime.GOOS != "windows" || os.Getenv("GITHUB_ACTIONS") != "true" || os.Getenv("RUNNER_ENVIRONMENT") != "github-hosted" {
t.Skip("Official client probe requires a disposable GitHub-hosted Windows runner")
}
binary, err := exec.LookPath("pwsh")
if err != nil {
t.Fatal(err)
}
root, err := filepath.Abs("../..")
if err != nil {
t.Fatal(err)
}
// The probe has no signing credentials and never submits a login. It checks
// that the official pinned client exposes the control roles our wait needs.
command := exec.Command(binary, "-NoLogo", "-NoProfile", "-NonInteractive", "-File", filepath.Join(root, "scripts/certum-client-probe.ps1"))
if output, err := command.CombinedOutput(); err != nil {
t.Fatalf("Official SimplySign form probe: %v\n%s", err, output)
}
}
28 changes: 19 additions & 9 deletions docs/CERTUM_SIGNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ TOTP 密钥。

The smoke workflow checks credential format before compiling probes. The shared
login action checks it again, pins the SimplySign installer SHA-256 as well as
its publisher signature, and keeps authentication screenshots disabled. Both
signing workflows disconnect the cloud session even when signing fails. Format
its publisher signature, and keeps authentication screenshots disabled. The
owned login adapter waits for two editable controls and an OK button, rather
than treating the first visible splash window as the login form. It ignores
background windows when identifying acknowledgement dialogs. A credential-free
probe of the official client runs only on disposable GitHub-hosted Windows
runners; deterministic tests reproduce the splash/disappearance/form ordering.
Both signing workflows disconnect the cloud session even when signing fails. Format
validation does not prove that the account, certificate or TOTP seed is valid;
only a successful live signing test does.

签名测试在编译探针前检查凭据格式;共享登录 Action 再次检查,并同时验证 SimplySign
安装器的固定 SHA-256 和发布者签名,保持登录截图关闭。两个签名工作流在签名失败时
也会断开云签名会话。格式检查不能证明账号、证书或 TOTP 密钥有效,仍须实际签名成功。
安装器的固定 SHA-256 和发布者签名,保持登录截图关闭。仓库维护的登录适配器等待两个
可编辑控件和 OK 按钮出现,不把最先出现的启动窗口当作登录表单,识别确认弹窗时也会
排除后台窗口。官方客户端的无凭据探测只在可丢弃的 GitHub 托管 Windows runner 上
运行;确定性测试覆盖“启动窗出现、消失、登录表单出现”的顺序。两个签名工作流在
签名失败时也会断开云签名会话。格式检查不能证明账号、证书或 TOTP 密钥有效,仍须实际签名成功。

Historical Stable versions `0.0.1`–`0.0.6` retain their explicit unsigned policy.
Unlisted versions such as `0.0.7` require Certum automatically and cannot fall
Expand All @@ -59,13 +67,15 @@ a new signed candidate rather than silently replacing an existing release.

Run **Certum signing smoke test** on protected `main`, approve the `release`
environment, and require successful login, signing, trust, signer and timestamp
verification. This test publishes nothing. The third-party login action is
pinned to an audited commit; authentication screenshots are disabled. Review
upstream code before updating the pin.
verification. This test publishes nothing. The authentication implementation is
vendored from an audited upstream commit with its MIT notice; the local window
readiness adapter is covered by regression tests. Authentication screenshots
are disabled. Review upstream changes before updating the vendored code.

先在 `main` 手动运行签名测试并批准 `release` 环境。测试不发布产物,必须通过
登录、实际签名、信任链、签名者及时间戳检查。第三方登录 Action 固定提交,更新前
需要审查,登录截图默认关闭。
登录、实际签名、信任链、签名者及时间戳检查。认证实现从已审查的上游固定提交引入
仓库并保留 MIT 声明,本地窗口就绪适配器有回归测试。更新上游代码前需要审查,登录
截图保持关闭。

Release builds retain native x64 and ARM64 startup tests. Their exact payloads
and generated NSIS identity files pass through same-run artifacts to serialized
Expand Down
16 changes: 16 additions & 0 deletions scripts/certum-client-probe.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$ErrorActionPreference = 'Stop'
if ($env:GITHUB_ACTIONS -ne 'true' -or $env:RUNNER_ENVIRONMENT -ne 'github-hosted') {
throw 'The credential-free SimplySign UI probe requires a disposable GitHub-hosted runner.'
}
foreach ($name in @('CERTUM_USERNAME', 'CERTUM_OTP_URI', 'CERTUM_KEY_ID')) {
[Environment]::SetEnvironmentVariable($name, $null, 'Process')
}
# This disposable probe has no credentials and never submits a login. Capture
# its empty UI on failure only; normal authentication keeps captures disabled.
$env:CAPTURE_DIAGNOSTICS = 'true'
try {
& (Join-Path $PSScriptRoot 'certum/Install-SimplySign.ps1') -InstallerPath (Join-Path $env:RUNNER_TEMP 'SimplySign-probe.msi')
& (Join-Path $PSScriptRoot 'certum/Connect-SimplySign.ps1') -ProbeOnly
} finally {
Get-Process -Name '*SimplySign*' -ErrorAction SilentlyContinue | Stop-Process -Force
}
96 changes: 96 additions & 0 deletions scripts/certum-login-ui.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Read only control roles; never read field values or capture authentication UI.
function Get-CertumWindowObservation {
param([IntPtr]$Handle)
if (-not ('CertumControlRoles' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
public static class CertumControlRoles {
public sealed class Control { public IntPtr Handle; public string ClassName; public string ButtonName; }
private delegate bool EnumProc(IntPtr handle, IntPtr parameter);
[DllImport("user32.dll")] private static extern bool EnumChildWindows(IntPtr parent, EnumProc callback, IntPtr parameter);
[DllImport("user32.dll", CharSet=CharSet.Unicode)] private static extern int GetClassName(IntPtr handle, StringBuilder text, int count);
[DllImport("user32.dll", CharSet=CharSet.Unicode)] private static extern int GetWindowText(IntPtr handle, StringBuilder text, int count);
public static Control[] Read(IntPtr parent) {
var controls = new List<Control>();
EnumChildWindows(parent, (handle, parameter) => {
var name = new StringBuilder(256);
GetClassName(handle, name, name.Capacity);
var control = new Control { Handle = handle, ClassName = name.ToString() };
// Never read edit text. Only acknowledgement button labels matter.
if (control.ClassName == "Button" || control.ClassName.StartsWith("WindowsForms10.BUTTON.")) {
var label = new StringBuilder(128);
GetWindowText(handle, label, label.Capacity);
control.ButtonName = label.ToString();
}
controls.Add(control);
return true;
}, IntPtr.Zero);
return controls.ToArray();
}
}
'@
}
try {
$controls = @([CertumControlRoles]::Read($Handle))
$edits = @($controls | Where-Object { $_.ClassName -eq 'Edit' -or $_.ClassName -like 'WindowsForms10.EDIT.*' })
$names = @($controls | Where-Object { $_.ClassName -eq 'Button' -or $_.ClassName -like 'WindowsForms10.BUTTON.*' } | ForEach-Object { ($_.ButtonName -replace '&', '').Trim() } |
Where-Object { $_ -in @('OK', 'No', 'Cancel') })
return [pscustomobject]@{ Handle = $Handle; EditCount = $edits.Count; Buttons = $names; Classes = @($controls.ClassName | Sort-Object -Unique) }
} catch {
# A window may disappear while Qt constructs or replaces its controls.
return $null
}
}

function Select-CertumLoginWindow {
param([object[]]$Observations)
$forms = @($Observations | Where-Object { $null -ne $_ -and $_.EditCount -eq 2 -and $_.Buttons -contains 'OK' })
if ($forms.Count -gt 1) { throw 'Multiple SimplySign credential forms; refusing ambiguous input.' }
if ($forms.Count -eq 1) { return [IntPtr]$forms[0].Handle }
return [IntPtr]::Zero
}

function Wait-CertumLoginWindow {
param(
[scriptblock]$EnumerateWindows = { Get-SimplySignWindows },
[scriptblock]$ObserveWindow = { param($handle) Get-CertumWindowObservation -Handle $handle },
[scriptblock]$StillRunning = { $proc.Refresh(); -not $proc.HasExited },
[int]$MaxPolls = 120,
[int]$PollMilliseconds = 250
)
$lastShape = $null
for ($poll = 0; $poll -lt $MaxPolls; $poll++) {
if (-not (& $StillRunning)) { throw 'SimplySign exited before its credential form was ready.' }
$observations = @(& $EnumerateWindows | ForEach-Object { & $ObserveWindow $_ })
$shape = (@($observations | Where-Object { $null -ne $_ } | ForEach-Object {
"handle=$($_.Handle) edits=$($_.EditCount) acknowledgementButtons=$($_.Buttons.Count) classes=$($_.Classes -join ',')"
}) -join '; ')
if ($shape -ne $lastShape) {
Write-Host "SimplySign control roles: $shape"
$lastShape = $shape
}
$handle = Select-CertumLoginWindow -Observations $observations
if ($handle -ne [IntPtr]::Zero) {
Write-Host 'SimplySign credential form is ready (two edit controls and OK); splash windows were ignored.'
return $handle
}
if ($PollMilliseconds -gt 0) { Start-Sleep -Milliseconds $PollMilliseconds }
}
throw 'SimplySign did not expose an unambiguous credential form; no credentials were submitted.'
}

function Get-CertumPopupWindows {
param([IntPtr]$LoginHandle)
foreach ($handle in @(Get-SimplySignWindows)) {
if ([IntPtr]$handle -eq $LoginHandle) { continue }
$observation = Get-CertumWindowObservation -Handle $handle
# Background/splash windows are not acknowledgement dialogs. In
# particular, never press Enter into a second credential form.
if ($null -ne $observation -and $observation.EditCount -eq 0 -and $observation.Buttons.Count -gt 0) {
$handle
}
}
}
46 changes: 46 additions & 0 deletions scripts/certum-login-ui.test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'certum-login-ui.ps1')
function Assert-Equal($actual, $expected, $message) {
if ($actual -ne $expected) { throw $message }
}
function Assert-Rejected([scriptblock]$action) {
$rejected = $false
try { & $action | Out-Null } catch { $rejected = $true }
if (-not $rejected) { throw 'Expected fail-closed rejection.' }
}
$splash = [pscustomobject]@{ Handle = 1; EditCount = 0; Buttons = @() }
$login = [pscustomobject]@{ Handle = 2; EditCount = 2; Buttons = @('OK', 'Cancel') }
$update = [pscustomobject]@{ Handle = 3; EditCount = 0; Buttons = @('No') }
Assert-Equal (Select-CertumLoginWindow @($splash)) ([IntPtr]::Zero) 'A splash screen was mistaken for a login form.'
Assert-Equal (Select-CertumLoginWindow @($splash, $update, $login)) ([IntPtr]2) 'Control roles did not select the login form.'
Assert-Rejected { Select-CertumLoginWindow @($login, $login) }

# Reproduce the recorded ordering: a splash exists first, it disappears, and
# only then does the actual credential form become visible.
$script:poll = 0
$handle = Wait-CertumLoginWindow -EnumerateWindows {
$script:poll++
if ($script:poll -eq 1) { 1 }
if ($script:poll -eq 3) { 1; 2; 3 }
} -ObserveWindow {
param($value)
if ($value -eq 1) { $splash }
if ($value -eq 2) { $login }
if ($value -eq 3) { $update }
} -StillRunning { $true } -MaxPolls 3 -PollMilliseconds 0
Assert-Equal $handle ([IntPtr]2) 'Readiness returned before credential controls existed.'
Assert-Equal $script:poll 3 'The transient splash window ended the wait early.'
Assert-Rejected { Wait-CertumLoginWindow -EnumerateWindows { 1 } -ObserveWindow { $splash } -StillRunning { $true } -MaxPolls 2 -PollMilliseconds 0 }
Assert-Rejected { Wait-CertumLoginWindow -StillRunning { $false } -PollMilliseconds 0 }

function Get-SimplySignWindows { 1; 2; 3; 4 }
function Get-CertumWindowObservation($Handle) {
if ($Handle -eq 1) { return $splash }
if ($Handle -eq 2) { return $login }
if ($Handle -eq 3) { return $update }
return [pscustomobject]@{ Handle = 4; EditCount = 2; Buttons = @('OK') }
}
$popups = @(Get-CertumPopupWindows -LoginHandle 2)
Assert-Equal $popups.Count 1 'Splash or credential windows were treated as popups.'
Assert-Equal $popups[0] ([IntPtr]3) 'The acknowledgement dialog was not selected.'
Write-Host 'Certum credential form readiness and popup isolation: PASS'
Loading
Loading