forked from p15670423/monkey
Island: Fix typo in AgentRetrievalError
This commit is contained in:
parent
28a07e4fdd
commit
0a8cbbc771
|
@ -1,2 +1,3 @@
|
||||||
from .file_storage import FileRetrievalError, IFileRepository, LocalStorageFileRepository
|
from .file_storage import FileRetrievalError, IFileRepository, LocalStorageFileRepository
|
||||||
from .i_agent_binary_repository import IAgentBinaryRepository, AgentRetrivalError
|
from .i_agent_binary_repository import IAgentBinaryRepository, AgentRetrievalError
|
||||||
|
from .agent_binary_repository import AgentBinaryRepository
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from typing import BinaryIO
|
from typing import BinaryIO
|
||||||
|
|
||||||
from . import AgentRetrivalError, FileRetrivalError, IAgentBinaryRepository, IFileRepository
|
from . import AgentRetrievalError, FileRetrievalError, IAgentBinaryRepository, IFileRepository
|
||||||
|
|
||||||
LINUX_AGENT_FILE_NAME = "monkey-linux-64"
|
LINUX_AGENT_FILE_NAME = "monkey-linux-64"
|
||||||
WINDOWS_AGENT_FILE_NAME = "monkey-windows-64.exe"
|
WINDOWS_AGENT_FILE_NAME = "monkey-windows-64.exe"
|
||||||
|
@ -10,18 +10,18 @@ class AgentBinaryRepository(IAgentBinaryRepository):
|
||||||
def __init__(self, file_repository: IFileRepository):
|
def __init__(self, file_repository: IFileRepository):
|
||||||
self._file_repository = file_repository
|
self._file_repository = file_repository
|
||||||
|
|
||||||
def __get_binary(self, filename) -> BinaryIO:
|
def get_linux_binary(self) -> BinaryIO:
|
||||||
|
return self._get_binary(LINUX_AGENT_FILE_NAME)
|
||||||
|
|
||||||
|
def get_windows_binary(self) -> BinaryIO:
|
||||||
|
return self._get_binary(WINDOWS_AGENT_FILE_NAME)
|
||||||
|
|
||||||
|
def _get_binary(self, filename: str) -> BinaryIO:
|
||||||
try:
|
try:
|
||||||
agent_binary = self._file_repository.open_file(filename)
|
agent_binary = self._file_repository.open_file(filename)
|
||||||
return agent_binary
|
return agent_binary
|
||||||
except FileRetrivalError as err:
|
except FileRetrievalError as err:
|
||||||
raise AgentRetrivalError(
|
raise AgentRetrievalError(
|
||||||
f"An error occurred while retrieving the {filename}"
|
f"An error occurred while retrieving the {filename}"
|
||||||
f" agent binary from {self._file_repository}: {err}"
|
f" agent binary from {self._file_repository}: {err}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_linux_binary(self) -> BinaryIO:
|
|
||||||
self.__get_binary(LINUX_AGENT_FILE_NAME)
|
|
||||||
|
|
||||||
def get_windows_binary(self) -> BinaryIO:
|
|
||||||
self.__get_binary(WINDOWS_AGENT_FILE_NAME)
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import abc
|
||||||
from typing import BinaryIO
|
from typing import BinaryIO
|
||||||
|
|
||||||
|
|
||||||
class AgentRetrivalError(IOError):
|
class AgentRetrievalError(IOError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue