forked from p15670423/monkey
Agent: Add and use HTTPIslandAPIClient.get_agent_binary()
This commit is contained in:
parent
9da1ad4c46
commit
1355c038b5
|
@ -2,10 +2,7 @@ import io
|
|||
import threading
|
||||
from functools import lru_cache
|
||||
|
||||
import requests
|
||||
|
||||
from common import OperatingSystem
|
||||
from common.common_consts.timeouts import MEDIUM_REQUEST_TIMEOUT
|
||||
from infection_monkey.island_api_client import IIslandAPIClient
|
||||
|
||||
from . import IAgentBinaryRepository
|
||||
|
@ -36,13 +33,4 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository):
|
|||
@lru_cache(maxsize=None)
|
||||
def _download_binary_from_island(self, operating_system: OperatingSystem) -> bytes:
|
||||
os_name = operating_system.value
|
||||
|
||||
response = requests.get( # noqa: DUO123
|
||||
f"{self._island_url}/api/agent-binaries/{os_name}",
|
||||
verify=False,
|
||||
timeout=MEDIUM_REQUEST_TIMEOUT,
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
return response.content
|
||||
return self._island_api_client.get_agent_binary(os_name)
|
||||
|
|
|
@ -76,3 +76,14 @@ class HTTPIslandAPIClient(IIslandAPIClient):
|
|||
response.raise_for_status()
|
||||
|
||||
return response.content
|
||||
|
||||
@handle_island_errors
|
||||
def get_agent_binary(self, os_name: str):
|
||||
response = requests.get( # noqa: DUO123
|
||||
f"{self._api_url}/api/agent-binaries/{os_name}",
|
||||
verify=False,
|
||||
timeout=MEDIUM_REQUEST_TIMEOUT,
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
return response.content
|
||||
|
|
Loading…
Reference in New Issue