From 9495027678278f28a73eac86d8035cdb86ee96a3 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 5 Apr 2022 17:56:12 +0530 Subject: [PATCH] Agent: Catch exception when running plugins in master --- monkey/infection_monkey/master/automated_master.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/master/automated_master.py b/monkey/infection_monkey/master/automated_master.py index 0ef31129c..5586e808c 100644 --- a/monkey/infection_monkey/master/automated_master.py +++ b/monkey/infection_monkey/master/automated_master.py @@ -225,8 +225,10 @@ class AutomatedMaster(IMaster): interrupted_message = f"Received a stop signal, skipping remaining {plugin_type}s" for p in interruptible_iter(plugins, self._stop, interrupted_message): - # TODO: Catch exceptions to prevent thread from crashing - callback(p) + try: + callback(p) + except Exception as ex: + logger.debug(f"Exception encountered when running {plugin_type} {p}: {str(ex)}") logger.info(f"Finished running {plugin_type}s")