From b5691a33f6a73abab6481db69626d7a797982281 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 26 Jul 2022 12:18:20 -0400 Subject: [PATCH] Island: Rename _file_storage_service -> _file_repository --- monkey/monkey_island/cc/resources/pba_file_download.py | 6 +++--- monkey/monkey_island/cc/resources/pba_file_upload.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/monkey/monkey_island/cc/resources/pba_file_download.py b/monkey/monkey_island/cc/resources/pba_file_download.py index d8359049a..2a9e053ca 100644 --- a/monkey/monkey_island/cc/resources/pba_file_download.py +++ b/monkey/monkey_island/cc/resources/pba_file_download.py @@ -15,13 +15,13 @@ class PBAFileDownload(AbstractResource): File download endpoint used by monkey to download user's PBA file """ - def __init__(self, file_storage_service: IFileRepository): - self._file_storage_service = file_storage_service + def __init__(self, file_repository: IFileRepository): + self._file_repository = file_repository # Used by monkey. can't secure. def get(self, filename: str): try: - file = self._file_storage_service.open_file(filename) + file = self._file_repository.open_file(filename) # `send_file()` handles the closing of the open file. return send_file(file, mimetype="application/octet-stream") diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index 8a67970c5..404d2ab8c 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -32,10 +32,10 @@ class FileUpload(AbstractResource): def __init__( self, - file_storage_repository: IFileRepository, + file_repository: IFileRepository, agent_configuration_repository: IAgentConfigurationRepository, ): - self._file_storage_service = file_storage_repository + self._file_repository = file_repository self._agent_configuration_repository = agent_configuration_repository # NOTE: None of these methods are thread-safe. Don't forget to fix that when this becomes a @@ -64,7 +64,7 @@ class FileUpload(AbstractResource): filename = agent_configuration.custom_pbas.windows_filename try: - file = self._file_storage_service.open_file(filename) + file = self._file_repository.open_file(filename) # `send_file()` handles the closing of the open file. return send_file(file, mimetype="application/octet-stream") @@ -87,7 +87,7 @@ class FileUpload(AbstractResource): file_storage = next(request.files.values()) # For now, assume there's only one file safe_filename = sanitize_filename(file_storage.filename) - self._file_storage_service.save_file(safe_filename, file_storage.stream) + self._file_repository.save_file(safe_filename, file_storage.stream) try: self._update_config(target_os, safe_filename) except Exception as err: @@ -129,7 +129,7 @@ class FileUpload(AbstractResource): filename = original_agent_configuration.custom_pbas.windows_filename try: - self._file_storage_service.delete_file(filename) + self._file_repository.delete_file(filename) except Exception as err: # Roll back the entire transaction if part of it failed. self._agent_configuration_repository.store_configuration(original_agent_configuration)