Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
test: prepare blocked-outbound Mayan Windows GUI launch probe with no live bank credentials
davoodmehraban89 committed
Oct 16, 2026 at 21:30 UTC
6bb4530d5aa65a56a9e08596d7bf5e66529d31b3
1 file changed
+43
scripts/windows-vm-mayan-sandbox.ps1
new
+43
@@ -0,0 +1,43 @@
1
+param([Parameter(Mandatory=$true)][string]$QaFolder)
2
+$ErrorActionPreference='Stop'
3
+$reportDir=Join-Path $env:RUNNER_TEMP 'mayan-vm-evidence'
4
+New-Item -ItemType Directory -Path $reportDir -Force|Out-Null
5
+$report=[ordered]@{binaryPresent=$false;framework472Plus=$false;networkRuleInstalled=$false;
6
+ processStarted=$false;windowHandlePresent=$false;licenseActivation='UNVERIFIED';
7
+ mayanFinancialOutput='NOT_TESTED';outcome='NOT_RUN'}
8
+$process=$null
9
+$ruleName="TreasuryFlow-Mayan-VM-$PID"
10
+try{
11
+ $exe=Join-Path $QaFolder 'Mayan.exe'
12
+ if(!(Test-Path $exe)){throw 'MAYAN_ORIGINAL_EXE_NOT_PRESENT'}
13
+ $report.binaryPresent=$true
14
+ $file=[System.IO.File]::OpenRead($exe)
15
+ try {
16
+ $bytes=New-Object byte[] 2
17
+ [void]$file.Read($bytes,0,2)
18
+ if($bytes[0] -ne 77 -or $bytes[1] -ne 90){throw 'MAYAN_NOT_WINDOWS_PE'}
19
+ }finally{$file.Dispose()}
20
+ $reg=Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -ErrorAction SilentlyContinue
21
+ if(!$reg -or $reg.Release -lt 461808){throw 'DOTNET_FRAMEWORK_472_REQUIRED'}
22
+ $report.framework472Plus=$true
23
+ # Do not run legacy banking EXE unless outbound traffic for that EXE is blocked.
24
+ try{
25
+ New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Action Block -Program $exe -Profile Any | Out-Null
26
+ $report.networkRuleInstalled=$true
27
+ }catch{throw 'MAYAN_NETWORK_ISOLATION_RULE_COULD_NOT_BE_CREATED'}
28
+ $process=Start-Process -FilePath $exe -WorkingDirectory $QaFolder -PassThru
29
+ $report.processStarted=$true
30
+ Start-Sleep -Seconds 9
31
+ $process.Refresh()
32
+ if(!$process.HasExited){$report.windowHandlePresent=($process.MainWindowHandle -ne [IntPtr]::Zero)}
33
+ $report.outcome=if($process.HasExited){'LAUNCHED_BUT_EXITED_OR_REQUIRES_CONFIG'}else{'PROCESS_ALIVE_GUI_NOT_VALIDATED'}
34
+ 'Mayan actual Windows PE was started with outbound program firewall block; bank outputs and activation remain unverified.' >> $env:GITHUB_STEP_SUMMARY
35
+}catch{
36
+ $report.outcome='BLOCKED_OR_FAILED'
37
+ $report.failureCode=$_.Exception.Message
38
+ throw
39
+}finally{
40
+ if($process -and !$process.HasExited){try{Stop-Process -Id $process.Id -Force -ErrorAction Stop}catch{}}
41
+ if($report.networkRuleInstalled){try{Remove-NetFirewallRule -DisplayName $ruleName -ErrorAction Stop}catch{}}
42
+ $report|ConvertTo-Json -Depth 3 |Set-Content (Join-Path $reportDir 'mayan-gui.json') -Encoding UTF8
43
+}