From edc4acaf3b996ef79310265d5e6c8214c7cc3d4e Mon Sep 17 00:00:00 2001 From: Dicken Date: Sun, 26 Jul 2026 11:36:03 +0200 Subject: [PATCH] round53: Timeout-Berechnung fuer masscan/httpx auf ganze Zahl runden (execFile lehnte Kommawerte ab) --- apps/backend/src/scanner/httpx.ts | 5 ++++- apps/backend/src/scanner/masscan.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/backend/src/scanner/httpx.ts b/apps/backend/src/scanner/httpx.ts index a727b9b..85c9820 100644 --- a/apps/backend/src/scanner/httpx.ts +++ b/apps/backend/src/scanner/httpx.ts @@ -76,7 +76,10 @@ function computeTimeoutMs(targetCount: number, threads: number, perProbeTimeoutS const perProbeSeconds = perProbeTimeoutSec * (1 + retries); const estimatedSeconds = (targetCount / threads) * perProbeSeconds; const withMargin = estimatedSeconds * 1.5 + 10; - return Math.min(Math.max(withMargin * 1000, 30_000), 10 * 60_000); + // Math.round() analog zu masscan.ts: auch wenn Node's setTimeout() Floats + // technisch toleriert, bleibt der Wert so konsistent nachvollziehbar + // (ganze Sekunden in den Log-/Fehlermeldungen weiter oben). + return Math.round(Math.min(Math.max(withMargin * 1000, 30_000), 10 * 60_000)); } /** diff --git a/apps/backend/src/scanner/masscan.ts b/apps/backend/src/scanner/masscan.ts index a16c8fc..ac3fff4 100644 --- a/apps/backend/src/scanner/masscan.ts +++ b/apps/backend/src/scanner/masscan.ts @@ -97,7 +97,11 @@ function computeTimeoutMs(hostCount: number, portRange: string, rate: number): n const totalProbes = hostCount * countPortsInRange(portRange); const estimatedSeconds = totalProbes / rate; const withMargin = estimatedSeconds * 2 + 15; - return Math.min(Math.max(withMargin * 1000, 60_000), 15 * 60_000); + // Math.round() ist Pflicht: execFile()s "timeout"-Option verlangt eine + // ganze Zahl (Node validiert das strikt) - estimatedSeconds ist aus einer + // Division entstanden und damit fast immer eine Kommazahl, die sonst mit + // "The value of "timeout" is out of range" abgelehnt wird. + return Math.round(Math.min(Math.max(withMargin * 1000, 60_000), 15 * 60_000)); } /**