Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
ci/windows-dual-app-lab-20261016
ci/public-windows-bridge-probe-20261017
ci/windows-dispatch-bootstrap-20261016
ci/windows-dual-app-lab-20261016
dev/v7-production-failclosed-20261021
feature/reconciliation-guard-20261013
main
phase-1-foundation
phase-1-implementation
phase-2-treasury-core
phase-3-banking-reconciliation
phase-4-operations-enterprise-ux
phase-5-hardening-release
phase-6-production-platform
phase-7-production-infrastructure-bank-golive
phase-7-sql-readonly-ux-20261015
transfer-exe-to-drive-20261006
| 1 | param([Parameter(Mandatory=$true)][string]$SourceRoot) |
| 2 | $ErrorActionPreference='Stop' |
| 3 | $evidenceDir=Join-Path $env:RUNNER_TEMP 'treasuryflow-vm-evidence' |
| 4 | New-Item -ItemType Directory -Path $evidenceDir -Force | Out-Null |
| 5 | $exe=Join-Path $SourceRoot 'release/win-unpacked/TreasuryFlow.exe' |
| 6 | $stdout=Join-Path $env:RUNNER_TEMP 'treasuryflow-unpacked-stdout.txt' |
| 7 | $stderr=Join-Path $env:RUNNER_TEMP 'treasuryflow-unpacked-stderr.txt' |
| 8 | $report=[ordered]@{ |
| 9 | mode='DIRECT_UNPACKED_ELECTRON_EXE' |
| 10 | executablePresent=$false |
| 11 | launched=$false |
| 12 | exited=$false |
| 13 | exitCode=$null |
| 14 | httpReady=$false |
| 15 | bankAdapterDisabled=$false |
| 16 | loginHtmlLoaded=$false |
| 17 | stdoutBytes=0 |
| 18 | stderrBytes=0 |
| 19 | stderrMarkers=@() |
| 20 | stderrExcerpt='' |
| 21 | stdoutExcerpt='' |
| 22 | inheritedElectronRunAsNode=($env:ELECTRON_RUN_AS_NODE -eq '1') |
| 23 | outcome='NOT_RUN' |
| 24 | } |
| 25 | $p=$null |
| 26 | try { |
| 27 | if(!(Test-Path $exe)){throw 'UNPACKED_ELECTRON_EXE_MISSING'} |
| 28 | $report.executablePresent=$true |
| 29 | $env:BANK_ADAPTER_MODE='disabled' |
| 30 | $env:TREASURYFLOW_DESKTOP_LOCAL='1' |
| 31 | $env:TREASURYFLOW_VM_DIAGNOSTICS='1' |
| 32 | $env:TREASURYFLOW_DATA_FILE=Join-Path $evidenceDir 'unpacked-synthetic.sqlite' |
| 33 | $p=Start-Process -FilePath $exe -WorkingDirectory (Split-Path $exe) -PassThru -RedirectStandardOutput $stdout -RedirectStandardError $stderr |
| 34 | $report.launched=$true |
| 35 | $stopAt=[DateTime]::UtcNow.AddSeconds(90) |
| 36 | while([DateTime]::UtcNow -lt $stopAt){ |
| 37 | Start-Sleep -Milliseconds 700 |
| 38 | $p.Refresh() |
| 39 | if($p.HasExited){ |
| 40 | $report.exited=$true |
| 41 | $report.exitCode=$p.ExitCode |
| 42 | throw ('UNPACKED_ELECTRON_PROCESS_EXITED_'+$p.ExitCode) |
| 43 | } |
| 44 | try { |
| 45 | $ready=Invoke-RestMethod 'http://127.0.0.1:3210/api/ready' -TimeoutSec 2 |
| 46 | if($ready.status -eq 'ready' -and $ready.bankAdapter -eq 'disabled'){ |
| 47 | $report.httpReady=$true |
| 48 | $report.bankAdapterDisabled=$true |
| 49 | break |
| 50 | } |
| 51 | }catch{} |
| 52 | } |
| 53 | if(!$report.httpReady){throw 'UNPACKED_ELECTRON_READINESS_TIMEOUT'} |
| 54 | $login=Invoke-WebRequest 'http://127.0.0.1:3210/login' -TimeoutSec 10 |
| 55 | $report.loginHtmlLoaded=($login.StatusCode -eq 200 -and $login.Content -match 'TreasuryFlow') |
| 56 | if(!$report.loginHtmlLoaded){throw 'UNPACKED_ELECTRON_LOCAL_LOGIN_FAILED'} |
| 57 | $report.outcome='UNPACKED_ELECTRON_HTTP_AND_PROCESS_PASS' |
| 58 | 'Direct win-unpacked TreasuryFlow.exe launched and passed local-bank-disabled HTTP checks.' >> $env:GITHUB_STEP_SUMMARY |
| 59 | }catch{ |
| 60 | $report.outcome='FAILED' |
| 61 | $report.failureCode=$_.Exception.Message |
| 62 | throw |
| 63 | }finally{ |
| 64 | if($p -and !$p.HasExited){try{& taskkill.exe /T /F /PID $p.Id | Out-Null}catch{}} |
| 65 | foreach($item in @(@{file=$stdout;key='stdoutBytes'},@{file=$stderr;key='stderrBytes'})){ |
| 66 | if(Test-Path $item.file){$report[$item.key]=(Get-Item $item.file).Length} |
| 67 | } |
| 68 | if(Test-Path $stderr){ |
| 69 | $raw=Get-Content $stderr -Raw -ErrorAction SilentlyContinue |
| 70 | $report.stderrMarkers=@('MODULE_NOT_FOUND','ERR_MODULE_NOT_FOUND','ENOENT', |
| 71 | 'EACCES','EPERM','EADDRINUSE','UNHANDLED_REJECTION','Failed to launch', |
| 72 | 'server did not start') | Where-Object {$raw -match [regex]::Escape($_)} |
| 73 | } |
| 74 | # Disposable test runner uses synthetic data. Redact probable credentials and |
| 75 | # user paths before emitting bounded diagnostics into public Actions evidence. |
| 76 | foreach($stream in @( |
| 77 | @{file=$stdout;key='stdoutExcerpt'}, |
| 78 | @{file=$stderr;key='stderrExcerpt'} |
| 79 | )){ |
| 80 | if(Test-Path $stream.file){ |
| 81 | $raw=[string](Get-Content -LiteralPath $stream.file -Raw -ErrorAction SilentlyContinue) |
| 82 | $safe=$raw -replace '(?i)(password|token|secret|credential|authorization|api[_-]?key)(\s*[:=]\s*)[^\s,;]+','$1$2[REDACTED]' |
| 83 | $safe=$safe -replace '(?i)(https?://)[^:\s/@]+:[^\s/@]+@','$1[REDACTED]@' |
| 84 | $safe=$safe -replace '(?i)([A-Z]:\\Users\\)[^\\\r\n]+','$1[USER]' |
| 85 | $safe=$safe -replace '[\x00-\x08\x0B\x0C\x0E-\x1F]','' |
| 86 | if($safe.Length -gt 1400){$safe=$safe.Substring(0,1400)+' [TRUNCATED]'} |
| 87 | $report[$stream.key]=$safe |
| 88 | } |
| 89 | } |
| 90 | Write-Host "Unpacked Electron diagnostics: inherited run-as-node=$($report.inheritedElectronRunAsNode); stdout bytes=$($report.stdoutBytes); stderr bytes=$($report.stderrBytes)" |
| 91 | if($report.stderrExcerpt){Write-Host "Sanitized Electron stderr: $($report.stderrExcerpt)"} |
| 92 | $report | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $evidenceDir 'unpacked-runtime.json') -Encoding UTF8 |
| 93 | } |