From 858eb2302c252a4473e16304197521780f175304 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 24 Jun 2022 07:23:26 -0400 Subject: [PATCH] Agent: Rename os -> operating_system in caching_agent_repository The variable name "os" conflicts with the name of Python's `os` library. --- .../exploit/caching_agent_repository.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/monkey/infection_monkey/exploit/caching_agent_repository.py b/monkey/infection_monkey/exploit/caching_agent_repository.py index 5dd8a603c..499e8401c 100644 --- a/monkey/infection_monkey/exploit/caching_agent_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_repository.py @@ -23,17 +23,20 @@ class CachingAgentRepository(IAgentRepository): self._proxies = proxies self._lock = threading.Lock() - def get_agent_binary(self, os: OperatingSystems, architecture: str = None) -> io.BytesIO: + def get_agent_binary( + self, operating_system: OperatingSystems, architecture: str = None + ) -> io.BytesIO: # If multiple calls to get_agent_binary() are made simultaneously before the result of # _download_binary_from_island() is cached, then multiple requests will be sent to the # island. Add a mutex in front of the call to _download_agent_binary_from_island() so # that only one request per OS will be sent to the island. with self._lock: - return io.BytesIO(self._download_binary_from_island(os)) + return io.BytesIO(self._download_binary_from_island(operating_system)) @lru_cache(maxsize=None) - def _download_binary_from_island(self, os: OperatingSystems) -> bytes: - os_name = os.name.lower() + def _download_binary_from_island(self, operating_system: OperatingSystems) -> bytes: + os_name = operating_system.name.lower() + response = requests.get( # noqa: DUO123 f"{self._island_url}/api/agent-binaries/{os_name}", verify=False,