From 6d156b8fee02e924bf9b4299b3f73e093b5922a6 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 23 Jun 2022 16:54:27 -0400 Subject: [PATCH] Island: Return config timeouts in seconds The old config scheme stored timeouts as milliseconds, whereas the new one uses seconds. Seconds are more convenient because most python methods expecting timeouts are expecting floating-point seconds. --- monkey/infection_monkey/master/automated_master.py | 4 ++-- monkey/monkey_island/cc/services/config.py | 4 ++-- .../tests/unit_tests/monkey_island/cc/services/test_config.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/monkey/infection_monkey/master/automated_master.py b/monkey/infection_monkey/master/automated_master.py index de55ef904..eeb0b48d7 100644 --- a/monkey/infection_monkey/master/automated_master.py +++ b/monkey/infection_monkey/master/automated_master.py @@ -23,8 +23,8 @@ from .option_parsing import custom_pba_is_enabled CHECK_ISLAND_FOR_STOP_COMMAND_INTERVAL_SEC = 5 CHECK_FOR_TERMINATE_INTERVAL_SEC = CHECK_ISLAND_FOR_STOP_COMMAND_INTERVAL_SEC / 5 SHUTDOWN_TIMEOUT = 5 -NUM_SCAN_THREADS = 16 -NUM_EXPLOIT_THREADS = 6 +NUM_SCAN_THREADS = 1 +NUM_EXPLOIT_THREADS = 1 CHECK_FOR_STOP_AGENT_COUNT = 5 CHECK_FOR_CONFIG_COUNT = 3 diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 69db1c2e1..1a8c7d006 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -460,7 +460,7 @@ class ConfigService: formatted_tcp_scan_config = {} - formatted_tcp_scan_config["timeout"] = config[flat_tcp_timeout_field] + formatted_tcp_scan_config["timeout"] = config[flat_tcp_timeout_field] / 1000 ports = ConfigService._union_tcp_and_http_ports( config[flat_tcp_ports_field], config[flat_http_ports_field] @@ -484,7 +484,7 @@ class ConfigService: flat_ping_timeout_field = "ping_scan_timeout" formatted_icmp_scan_config = {} - formatted_icmp_scan_config["timeout"] = config[flat_ping_timeout_field] + formatted_icmp_scan_config["timeout"] = config[flat_ping_timeout_field] / 1000 config.pop(flat_ping_timeout_field, None) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py index 85f3f4823..f170b0865 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py @@ -99,7 +99,7 @@ def test_format_config_for_agent__propagation(): def test_format_config_for_agent__network_scan(): expected_network_scan_config = { "tcp": { - "timeout": 3000, + "timeout": 3.0, "ports": [ 22, 80, @@ -117,7 +117,7 @@ def test_format_config_for_agent__network_scan(): ], }, "icmp": { - "timeout": 1000, + "timeout": 1.0, }, "targets": { "blocked_ips": ["192.168.1.1", "192.168.1.100"],