Files
AetherForge/scripts/_final_patch.py
AetherForge 11c15cdcfb
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Add recon network batch 1: stack banners and smart port profiles.
Parse technology stack from crawl headers, grab SSH/HTTP/WinRM banners, merge smart port bundles with FleetPorts, and suggest deploy-kit lane plus SSM for EC2 metadata targets.
2026-06-07 12:04:04 -07:00

78 lines
3.9 KiB
Python

from pathlib import Path
p = Path(r"G:/crypto miner/scripts/test-suite.ps1")
t = p.read_text(encoding="utf-8")
if "[switch]$SubnetRecon," not in t:
t = t.replace("[switch]$Recon,", "[switch]$Recon,\n [switch]$SubnetRecon,")
blocks = """
if ($SubnetRecon) {
Invoke-Phase \"Subnet recon (LAN sweep + fleet discoveries)\" {
Push-Location (Join-Path $Root \"agent\")
go test ./client/... ./config/... -run SubnetRecon -count=1
go test ./deploy/... -run SubnetRecon -count=1
Pop-Location
Push-Location (Join-Path $Root \"server\\web\")
if (-not (Test-Path \"node_modules\")) { npm install --silent }
npm run test -- --run src/help/fleetDiscoveries.test.ts
Pop-Location
}
Exit-FeatureRun \"SubnetRecon\"
}
if ($Recon) {
Invoke-Phase \"Deploy recon (engine + API + UI)\" {
Push-Location (Join-Path $Root \"server\")
go test ./internal/recon/... -count=1
go test ./internal/api/... -run \"Recon|DeployKit|FleetSpread\" -count=1
Pop-Location
Push-Location (Join-Path $Root \"server\\web\")
if (-not (Test-Path \"node_modules\")) { npm install --silent }
npm run test -- --run src/help/deployRecon.test.ts src/help/fleetDiscoveries.test.ts src/pages/DeployReconPage.test.tsx src/help/reconRisk.test.ts src/components/Fleet/ReconBadges.test.tsx src/components/Fleet/CrucibleExpandedOps.test.tsx
Pop-Location
}
if (-not $SkipE2E) {
Invoke-Phase \"Deploy recon E2E smoke (Playwright)\" {
$DataDir = Join-Path $env:TEMP (\"aether-recon-e2e-\" + [guid]::NewGuid().ToString(\"n\"))
New-Item -ItemType Directory -Force -Path $DataDir | Out-Null
$E2EUser = if ($env:AETHERFORGE_E2E_USER) { $env:AETHERFORGE_E2E_USER } else { \"testuser\" }
$E2EPass = if ($env:AETHERFORGE_E2E_PASS) { $env:AETHERFORGE_E2E_PASS } else { \"testpass\" }
[System.IO.File]::WriteAllText((Join-Path $DataDir \"users.json\"), (@{ $E2EUser = $E2EPass } | ConvertTo-Json -Compress))
$ServerExe = Join-Path $Root \"bin\\miner-server.exe\"
if (-not (Test-Path $ServerExe)) {
Push-Location (Join-Path $Root \"server\")
go build -o $ServerExe .
Pop-Location
}
$env:AETHERFORGE_E2E = \"1\"
$proc = Start-Process -FilePath $ServerExe -ArgumentList \"-port\",\"18989\",\"-data\",$DataDir -WorkingDirectory $Root -PassThru -WindowStyle Hidden
try {
$ready = $false
for ($i = 0; $i -lt 30; $i++) {
try {
$r = Invoke-RestMethod \"http://127.0.0.1:18989/api/v1/health\" -TimeoutSec 2
if ($r.status -eq \"ok\") { $ready = $true; break }
} catch {}
Start-Sleep -Seconds 1
}
if (-not $ready) { throw \"recon E2E server not healthy on :18989\" }
Push-Location (Join-Path $Root \"server\\web\")
$env:AETHERFORGE_URL = \"http://127.0.0.1:18989\"
npx playwright test e2e/deploy-recon.spec.ts --config playwright.config.ts
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { throw \"deploy-recon E2E failed (exit $LASTEXITCODE)\" }
Pop-Location
} finally {
if ($proc -and -not $proc.HasExited) { Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue }
Remove-Item $DataDir -Recurse -Force -ErrorAction SilentlyContinue
}
}
}
Exit-FeatureRun \"Recon\"
}
"""
# remove old Recon block(s) before phase 1
import re
t = re.sub(r"\nif \(\$Recon\) \{.*?\n\}\n\n(?=Invoke-Phase \"1/8)", "\n", t, flags=re.S)
if "if ($SubnetRecon)" not in t:
t = t.replace("if ($ReconOnly) {", blocks + "if ($ReconOnly) {")
p.write_text(t, encoding="utf-8")
print("final patch ok")