From 71029cb7f9ebdf49da694968e04362b40c5bd598 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 11 May 2021 08:51:48 -0400 Subject: [PATCH] island: Decouple FileUpload resource from environment_singleton --- monkey/monkey_island/cc/resources/pba_file_upload.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index 01cae595e..046e79efb 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -7,12 +7,12 @@ import flask_restful from flask import Response, request, send_from_directory from werkzeug.utils import secure_filename -import monkey_island.cc.environment.environment_singleton as env_singleton 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, + PostBreachFilesService, ) __author__ = "VakarisZ" @@ -40,7 +40,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(env_singleton.env.get_config().data_dir_abs_path, filename) + return send_from_directory(PostBreachFilesService.get_custom_pba_directory(), filename) @jwt_required def post(self, file_type): @@ -64,7 +64,7 @@ class FileUpload(flask_restful.Resource): """ filename = secure_filename(request_.files["filepond"].filename) file_path = ( - Path(env_singleton.env.get_config().data_dir_abs_path).joinpath(filename).absolute() + Path(PostBreachFilesService.get_custom_pba_directory()).joinpath(filename).absolute() ) request_.files["filepond"].save(str(file_path)) ConfigService.set_config_value( @@ -84,7 +84,7 @@ class FileUpload(flask_restful.Resource): ) filename = ConfigService.get_config_value(filename_path) if filename: - file_path = Path(env_singleton.env.get_config().data_dir_abs_path).joinpath(filename) + file_path = Path(PostBreachFilesService.get_custom_pba_directory()).joinpath(filename) FileUpload._delete_file(file_path) ConfigService.set_config_value(filename_path, "")