From 875eba393cff8e34855d95a6946fcaa5e814b0a6 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 16 Aug 2017 16:36:51 +0300 Subject: [PATCH] Fix config erasing of creds --- chaos_monkey/monkey.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/chaos_monkey/monkey.py b/chaos_monkey/monkey.py index e61249a87..e3af0e012 100644 --- a/chaos_monkey/monkey.py +++ b/chaos_monkey/monkey.py @@ -111,16 +111,7 @@ class ChaosMonkey(object): ControlClient.keepalive() ControlClient.load_control_config() - # TODO: this is temporary until we change server to support changing of config. - for user in list(additional_creds): - if user not in WormConfiguration.exploit_user_list: - WormConfiguration.exploit_user_list.append(user) - - creds = additional_creds[user] - if creds.has_key('password'): - password = creds['password'] - if password not in WormConfiguration.exploit_password_list: - WormConfiguration.exploit_password_list.append(password) + self.update_config_creds(additional_creds) LOG.debug("Users to try: %s" % str(WormConfiguration.exploit_user_list)) LOG.debug("Passwords to try: %s" % str(WormConfiguration.exploit_password_list)) @@ -142,6 +133,9 @@ class ChaosMonkey(object): if ControlClient.check_for_stop(): break + # TODO: Consider removing later + self.update_config_creds(additional_creds) + is_empty = False for finger in self._fingerprint: LOG.info("Trying to get OS fingerprint from %r with module %s", @@ -260,4 +254,16 @@ class ChaosMonkey(object): except Exception, exc: LOG.error("Exception in self delete: %s", exc) + def update_config_creds(self, additional_creds): + # TODO: this is temporary until we change server to support changing of config. + for user in list(additional_creds): + if user not in WormConfiguration.exploit_user_list: + WormConfiguration.exploit_user_list.append(user) + + creds = additional_creds[user] + if creds.has_key('password'): + password = creds['password'] + if password not in WormConfiguration.exploit_password_list: + WormConfiguration.exploit_password_list.append(password) + LOG.info("Monkey is shutting down")