Fix scan timeouts and privileged shutdown

This commit is contained in:
2026-08-23 10:44:02 +02:00
parent ff18511ff2
commit c020bd318a
10 changed files with 116 additions and 37 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ class EngineStatus0419Tests(unittest.TestCase):
self.assertIn("découverte rapide Nmap/ARP", source)
self.assertIn("ports Naabu SYN (Admin)", source)
self.assertIn("ports Nmap SYN (Admin)", source)
self.assertIn("REPLI Naabu", source)
self.assertIn("REPLI Nmap", source)
if __name__ == "__main__":
+1
View File
@@ -112,6 +112,7 @@ class StandardBehavior0421Tests(unittest.TestCase):
args = worker._nmap.call_args.args[0]
self.assertIn("-sV", args)
self.assertIn("1000", args)
self.assertGreaterEqual(worker._nmap.call_args.kwargs["timeout_seconds"], 90.0)
class Diagnostics0421Tests(unittest.TestCase):
+24
View File
@@ -138,6 +138,30 @@ class PerformancePipeline0423Tests(unittest.TestCase):
self.assertEqual(cmd[:6], ["nmap", "-sn", "-n", "-T4", "--max-retries", "1"])
self.assertIsNotNone(worker._nmap.call_args.kwargs["timeout_seconds"])
def test_rapid_discovery_has_a_wall_clock_timeout(self):
worker = self.worker()
worker.request.profile = "Rapide"
worker._emit_local_host = Mock(return_value=[])
worker._emit_arp = Mock(return_value=[])
worker._neighbor_hosts = Mock(return_value=[])
worker._set_progress = Mock()
worker._nmap_optional = Mock(return_value=[])
worker._discover_hosts(start_percent=4, end_percent=96)
timeout = worker._nmap_optional.call_args.kwargs["timeout_seconds"]
self.assertIsNotNone(timeout)
self.assertLessEqual(timeout, scanner.RAPID_DISCOVERY_MAX_SECONDS)
def test_admin_rapid_discovery_does_not_repeat_nmap(self):
worker = self.worker(privileged=True)
worker.request.profile = "Rapide"
worker._emit_local_host = Mock(return_value=[])
worker._emit_arp = Mock(return_value=[])
worker._neighbor_hosts = Mock(return_value=[])
worker._set_progress = Mock()
worker._nmap_optional = Mock(return_value=[])
worker._discover_hosts(start_percent=4, end_percent=96)
worker._nmap_optional.assert_called_once()
def test_naabu_failure_does_not_rescan_dead_addresses_with_nmap(self):
worker = self.worker()
live = {f"192.168.10.{i}" for i in range(1, scanner.NAABU_ACTIVE_HOST_THRESHOLD + 1)}