From 2771dc374f17bc84cc617ff9f6d2c80c82c77d95 Mon Sep 17 00:00:00 2001 From: chack-agent Date: Mon, 6 Jul 2026 08:12:42 +0000 Subject: [PATCH] Fix CI failures for PR #663 --- .github/workflows/PR-tests.yml | 44 ++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/PR-tests.yml b/.github/workflows/PR-tests.yml index d90dc82..740b1c1 100644 --- a/.github/workflows/PR-tests.yml +++ b/.github/workflows/PR-tests.yml @@ -161,9 +161,49 @@ jobs: HTTPServer(("127.0.0.1", 18768), Handler).handle_request() "@ | Set-Content -Path $serverPath -Encoding utf8 - $server = Start-Process python -ArgumentList "`"$serverPath`" `"$bodyPath`" `"$countPath`"" -PassThru -NoNewWindow + $pythonCandidates = @( + @{ FilePath = "py"; Arguments = @("-3", $serverPath, $bodyPath, $countPath) }, + @{ FilePath = "python"; Arguments = @($serverPath, $bodyPath, $countPath) }, + @{ FilePath = "python3"; Arguments = @($serverPath, $bodyPath, $countPath) } + ) + $pythonCommand = $pythonCandidates | + Where-Object { Get-Command $_.FilePath -ErrorAction SilentlyContinue } | + Select-Object -First 1 + if (!$pythonCommand) { + Write-Error "No Python interpreter found to launch the mock host-checker server." + } + + $server = Start-Process -FilePath $pythonCommand.FilePath -ArgumentList $pythonCommand.Arguments -PassThru -NoNewWindow try { - Start-Sleep -Seconds 2 + $serverReady = $false + $deadline = (Get-Date).AddSeconds(15) + while ((Get-Date) -lt $deadline) { + if ($server.HasExited) { + break + } + + $client = $null + try { + $client = [System.Net.Sockets.TcpClient]::new() + $connectTask = $client.ConnectAsync("127.0.0.1", 18768) + if ($connectTask.Wait(500) -and $client.Connected) { + $serverReady = $true + break + } + } catch { + } finally { + if ($client) { + $client.Dispose() + } + } + + Start-Sleep -Milliseconds 250 + } + + if (!$serverReady) { + Write-Error "Mock host-checker server did not become ready before winPEAS execution." + } + $env:HACKTRICKS_HOST_CHECKER_URL = "http://127.0.0.1:18768/api/host-checker" $output = & $exePath applicationsinfo -vulnpackages notcolor 2>&1 | Out-String