From 628583d38f21cf683886f10f7245585e922dd44e Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 13 Aug 2020 18:53:55 +0300 Subject: [PATCH] Fixed post breach file upload bug --- monkey/monkey_island/cc/resources/pba_file_upload.py | 7 +++++-- monkey/monkey_island/cc/services/post_breach_files.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index b18fd7b2f..5440788e9 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -9,7 +9,7 @@ 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_WINDOWS_FILENAME_PATH, PBA_UPLOAD_PATH, UPLOADS_DIR) __author__ = 'VakarisZ' @@ -18,6 +18,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 +42,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():