From 32c2d744b5a3f7784f2a22c9555495221660b70c Mon Sep 17 00:00:00 2001
From: Mike Salvatore <mike.s.salvatore@gmail.com>
Date: Tue, 7 Dec 2021 13:21:44 -0500
Subject: [PATCH] Agent: Remove should_monkey_run() performance check

---
 monkey/infection_monkey/control.py | 12 ------------
 monkey/infection_monkey/monkey.py  | 20 --------------------
 2 files changed, 32 deletions(-)

diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py
index 88a8e43fa..9d89854cc 100644
--- a/monkey/infection_monkey/control.py
+++ b/monkey/infection_monkey/control.py
@@ -407,18 +407,6 @@ class ControlClient(object):
         except requests.exceptions.RequestException:
             return False
 
-    @staticmethod
-    def should_monkey_run(vulnerable_port: str) -> bool:
-        if (
-            vulnerable_port
-            and WormConfiguration.get_hop_distance_to_island() > 1
-            and ControlClient.can_island_see_port(vulnerable_port)
-            and WormConfiguration.started_on_island
-        ):
-            return False
-
-        return True
-
     @staticmethod
     def can_island_see_port(port):
         try:
diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py
index 7236af3fd..e63484e70 100644
--- a/monkey/infection_monkey/monkey.py
+++ b/monkey/infection_monkey/monkey.py
@@ -13,7 +13,6 @@ from infection_monkey.control import ControlClient
 from infection_monkey.master.mock_master import MockMaster
 from infection_monkey.model import DELAY_DELETE_CMD
 from infection_monkey.network.firewall import app as firewall
-from infection_monkey.network.tools import is_running_on_island
 from infection_monkey.puppet.mock_puppet import MockPuppet
 from infection_monkey.system_singleton import SystemSingleton
 from infection_monkey.telemetry.attack.t1106_telem import T1106Telem
@@ -144,13 +143,6 @@ class InfectionMonkey:
     def _setup(self):
         logger.debug("Starting the setup phase.")
 
-        if self._should_exit_for_performance():
-            logger.info(
-                "Monkey shouldn't run on current machine to improve perfomance"
-                "(it will be exploited later with more depth)."
-            )
-            return
-
         if firewall.is_enabled():
             firewall.add_firewall_rule()
 
@@ -163,18 +155,6 @@ class InfectionMonkey:
 
         register_signal_handlers(self._master)
 
-    def _should_exit_for_performance(self):
-        """
-        This method implements propagation performance enhancing algorithm that
-        kicks in if the run was started from the Island.
-        Should get replaced by other, better performance enhancement solutions
-        """
-        if is_running_on_island():
-            WormConfiguration.started_on_island = True
-            ControlClient.report_start_on_island()
-
-        return not ControlClient.should_monkey_run(self._opts.vulnerable_port)
-
     def _is_another_monkey_running(self):
         return not self._singleton.try_lock()