From bf5fb10838fb44fef3e76e876fb04db543df8b59 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Sun, 8 Oct 2017 19:23:34 +0300 Subject: [PATCH] Fix CR --- chaos_monkey/monkey.py | 7 ++----- chaos_monkey/network/info.py | 5 +++-- monkey_island/cc/services/config.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/chaos_monkey/monkey.py b/chaos_monkey/monkey.py index a71993f7c..17fc17bdd 100644 --- a/chaos_monkey/monkey.py +++ b/chaos_monkey/monkey.py @@ -81,8 +81,6 @@ class ChaosMonkey(object): if monkey_tunnel: monkey_tunnel.start() - last_exploit_time = None - ControlClient.send_telemetry("state", {'done': False}) self._default_server = WormConfiguration.current_server @@ -180,7 +178,6 @@ class ChaosMonkey(object): if successful_exploiter: self._exploited_machines.add(machine) - last_exploit_time = time.time() ControlClient.send_telemetry('exploit', {'result': True, 'machine': machine.__dict__, 'exploiter': successful_exploiter.__class__.__name__}) @@ -208,8 +205,8 @@ class ChaosMonkey(object): # if host was exploited, before continue to closing the tunnel ensure the exploited host had its chance to # connect to the tunnel - if last_exploit_time and (time.time() - last_exploit_time < WormConfiguration.keep_tunnel_open_time): - time_to_sleep = WormConfiguration.keep_tunnel_open_time - (time.time() - last_exploit_time) + if len(self._exploited_machines) > 0: + time_to_sleep = WormConfiguration.keep_tunnel_open_time LOG.info("Sleeping %d seconds for exploited machines to connect to tunnel", time_to_sleep) time.sleep(time_to_sleep) diff --git a/chaos_monkey/network/info.py b/chaos_monkey/network/info.py index e438f37b3..0c841dc9f 100644 --- a/chaos_monkey/network/info.py +++ b/chaos_monkey/network/info.py @@ -29,6 +29,8 @@ def get_host_subnets(): for network in ipv4_nets: if 'broadcast' in network: network.pop('broadcast') + for attr in network: + network[attr] = network[attr].encode('utf-8').strip() return ipv4_nets @@ -47,8 +49,7 @@ else: def local_ips(): - ipv4_nets = get_host_subnets() - valid_ips = [network['addr'].encode('utf-8').strip() for network in ipv4_nets] + valid_ips = [network['addr'] for network in get_host_subnets()] return valid_ips diff --git a/monkey_island/cc/services/config.py b/monkey_island/cc/services/config.py index 6807d5d86..dc9ce6a9e 100644 --- a/monkey_island/cc/services/config.py +++ b/monkey_island/cc/services/config.py @@ -282,7 +282,7 @@ SCHEMA = { "title": "Keep tunnel open time", "type": "integer", "default": 60, - "description": "Time to keep tunnel open before going down since last exploit (in seconds)" + "description": "Time to keep tunnel open before going down after last exploit (in seconds)" } } },