Agent: Move enum to string conversion to _download_binary_from_island()

This commit is contained in:
Mike Salvatore 2022-06-24 07:22:07 -04:00
parent e1d5d25e9c
commit ffd3464d8a
1 changed files with 4 additions and 3 deletions

View File

@ -29,12 +29,13 @@ class CachingAgentRepository(IAgentRepository):
# island. Add a mutex in front of the call to _download_agent_binary_from_island() so # 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. # that only one request per OS will be sent to the island.
with self._lock: with self._lock:
return io.BytesIO(self._download_binary_from_island(os.value)) return io.BytesIO(self._download_binary_from_island(os))
@lru_cache(maxsize=None) @lru_cache(maxsize=None)
def _download_binary_from_island(self, os: str) -> bytes: def _download_binary_from_island(self, os: OperatingSystems) -> bytes:
os_name = os.name.lower()
response = requests.get( # noqa: DUO123 response = requests.get( # noqa: DUO123
f"{self._island_url}/api/agent-binaries/{os}", f"{self._island_url}/api/agent-binaries/{os_name}",
verify=False, verify=False,
proxies=self._proxies, proxies=self._proxies,
timeout=MEDIUM_REQUEST_TIMEOUT, timeout=MEDIUM_REQUEST_TIMEOUT,