From fd2143a4df4e5ae4694b1990984bef652fd3a93d Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 7 Mar 2022 10:24:22 -0500 Subject: [PATCH] Agent: Re-raise exceptions in HostExploiter The AutomatedMaster can't process the exceptions if the HostExploiter swallows them. The HostExploiter can log and re-raise the exceptions so they can be processed by the AutomatedMaster. --- monkey/infection_monkey/exploit/HostExploiter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/monkey/infection_monkey/exploit/HostExploiter.py b/monkey/infection_monkey/exploit/HostExploiter.py index 69924b61a..0f698c926 100644 --- a/monkey/infection_monkey/exploit/HostExploiter.py +++ b/monkey/infection_monkey/exploit/HostExploiter.py @@ -82,16 +82,16 @@ class HostExploiter: self.options = options self.pre_exploit() - result = None try: - result = self._exploit_host() + return self._exploit_host() except FailedExploitationError as e: logger.debug(f"Exploiter failed: {e}.") - except Exception: + raise e + except Exception as e: logger.error("Exception in exploit_host", exc_info=True) + raise e finally: self.post_exploit() - return result def pre_exploit(self): self.exploit_result = ExploiterResultData(