跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

test-windows-signing.ps1

48 行 · 2.6 KB历史下载
1#requires -Version 7.0
2# Offline orchestration checks; Windows trust is exercised separately on Windows.
3. (Join-Path $PSScriptRoot 'windows-common.ps1')
4$stage = Join-Path ([IO.Path]::GetTempPath()) ('cage-signing-test-' + [guid]::NewGuid().ToString('N'))
5New-Item -ItemType Directory -Path $stage | Out-Null
6$names = @('CAGE_WINDOWS_SIGNING_PROVIDER', 'CAGE_ESIGNER_CERTIFICATE_SERIAL', 'CAGE_WINDOWS_CERT_SHA1')
7$saved = @{}
8foreach ($name in $names) { $saved[$name] = [Environment]::GetEnvironmentVariable($name) }
9try {
10 $env:CAGE_WINDOWS_SIGNING_PROVIDER = 'esigner'
11 $env:CAGE_ESIGNER_CERTIFICATE_SERIAL = '7' * 32
12 function Assert-WindowsSigningConfiguration {}
13 function Get-BuildCommand { return 'fixture-node' }
14 $script:mode = 'valid'
15 function Invoke-BuildTool {
16 param([string]$Tool, [string[]]$Arguments)
17 if ($Tool -eq 'fixture-node') {
18 New-Item -ItemType Directory -Path $Arguments[4] -Force | Out-Null
19 [IO.File]::WriteAllText((Join-Path $Arguments[4] ([IO.Path]::GetFileName($Arguments[2]))), 'signed fixture')
20 } elseif ($script:mode -eq 'untrusted') { throw 'Fixture trust failure' }
21 }
22 function Get-AuthenticodeSignature {
23 return [pscustomobject]@{
24 Status = 'Valid'
25 TimeStamperCertificate = if ($script:mode -eq 'no-timestamp') { $null } else { 'fixture' }
26 SignerCertificate = [pscustomobject]@{
27 SerialNumber = if ($script:mode -eq 'wrong-serial') { '8' * 32 } else { '7' * 32 }
28 Thumbprint = if ($script:mode -eq 'wrong-key') { 'b' * 40 } else { 'a' * 40 }
29 }
30 }
31 }
32 $inputFile = Join-Path $stage 'Cage 空格.exe'
33 foreach ($script:mode in @('valid', 'untrusted', 'no-timestamp', 'wrong-serial', 'wrong-key')) {
34 [IO.File]::WriteAllText($inputFile, 'original fixture')
35 $env:CAGE_WINDOWS_CERT_SHA1 = 'a' * 40
36 $rejected = $false
37 try { Sign-CageFile $inputFile 'fixture-signtool' } catch { $rejected = $true }
38 if ($script:mode -eq 'valid') {
39 if ($rejected -or [IO.File]::ReadAllText($inputFile) -ne 'signed fixture') { throw 'Valid signed copy was not promoted.' }
40 } else {
41 if (-not $rejected -or [IO.File]::ReadAllText($inputFile) -ne 'original fixture') { throw "Original file was replaced on $script:mode." }
42 }
43 }
44 Write-Host 'Passed: valid output promoted; untrusted, untimestamped, wrong-serial and wrong-key outputs rejected without replacing originals.'
45} finally {
46 foreach ($name in $names) { [Environment]::SetEnvironmentVariable($name, $saved[$name]) }
47 Remove-Item -LiteralPath $stage -Recurse -Force
48}