forked from p34709852/monkey
Agent: Rename os -> operating_system in caching_agent_repository
The variable name "os" conflicts with the name of Python's `os` library.
This commit is contained in:
parent
ffd3464d8a
commit
858eb2302c
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue