diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index b18fd7b2f..9f7b22246 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -9,7 +9,8 @@ from werkzeug.utils import secure_filename from monkey_island.cc.resources.auth.auth import jwt_required from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.post_breach_files import ( - PBA_LINUX_FILENAME_PATH, PBA_WINDOWS_FILENAME_PATH, UPLOADS_DIR) + PBA_LINUX_FILENAME_PATH, PBA_UPLOAD_PATH, PBA_WINDOWS_FILENAME_PATH, + UPLOADS_DIR) __author__ = 'VakarisZ' @@ -18,6 +19,9 @@ LOG = logging.getLogger(__name__) LINUX_PBA_TYPE = 'PBAlinux' WINDOWS_PBA_TYPE = 'PBAwindows' +# This path is used by flask, which means that local directory is different from UPLOADS_DIR +FLASK_UPLOAD_PATH = PBA_UPLOAD_PATH[-1] + class FileUpload(flask_restful.Resource): """ @@ -39,7 +43,7 @@ class FileUpload(flask_restful.Resource): filename = ConfigService.get_config_value(copy.deepcopy(PBA_LINUX_FILENAME_PATH)) else: filename = ConfigService.get_config_value(copy.deepcopy(PBA_WINDOWS_FILENAME_PATH)) - return send_from_directory(UPLOADS_DIR, filename) + return send_from_directory(FLASK_UPLOAD_PATH, filename) @jwt_required def post(self, file_type): diff --git a/monkey/monkey_island/cc/services/post_breach_files.py b/monkey/monkey_island/cc/services/post_breach_files.py index e3e6266cb..b198161ad 100644 --- a/monkey/monkey_island/cc/services/post_breach_files.py +++ b/monkey/monkey_island/cc/services/post_breach_files.py @@ -11,7 +11,8 @@ logger = logging.getLogger(__name__) # Where to find file names in config PBA_WINDOWS_FILENAME_PATH = ['monkey', 'post_breach', 'PBA_windows_filename'] PBA_LINUX_FILENAME_PATH = ['monkey', 'post_breach', 'PBA_linux_filename'] -UPLOADS_DIR = Path('monkey_island', 'cc', 'userUploads') +PBA_UPLOAD_PATH = ['monkey_island', 'cc', 'userUploads'] +UPLOADS_DIR = Path(*PBA_UPLOAD_PATH) def remove_PBA_files():