island: Create custom PBA directory on PostBreachFilesService init
This commit is contained in:
parent
be0f7ac881
commit
ca65330e86
|
@ -28,10 +28,6 @@ class FileUpload(flask_restful.Resource):
|
||||||
File upload endpoint used to exchange files with filepond component on the front-end
|
File upload endpoint used to exchange files with filepond component on the front-end
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
# Create all directories on the way if they don't exist
|
|
||||||
Path(env_singleton.env.get_config().data_dir_abs_path).mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
@jwt_required
|
@jwt_required
|
||||||
def get(self, file_type):
|
def get(self, file_type):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -9,6 +9,8 @@ import monkey_island.cc.environment.environment_singleton as env_singleton
|
||||||
from monkey_island.cc.database import mongo
|
from monkey_island.cc.database import mongo
|
||||||
from monkey_island.cc.server_utils.encryptor import get_encryptor
|
from monkey_island.cc.server_utils.encryptor import get_encryptor
|
||||||
from monkey_island.cc.services.config_schema.config_schema import SCHEMA
|
from monkey_island.cc.services.config_schema.config_schema import SCHEMA
|
||||||
|
|
||||||
|
# TODO: Remove circular dependency between ConfigService and PostBreachFilesService.
|
||||||
from monkey_island.cc.services.post_breach_files import PostBreachFilesService
|
from monkey_island.cc.services.post_breach_files import PostBreachFilesService
|
||||||
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
|
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,4 @@ def initialize_services(data_dir):
|
||||||
|
|
||||||
|
|
||||||
def initialize_post_breach_file_service(data_dir):
|
def initialize_post_breach_file_service(data_dir):
|
||||||
PostBreachFilesService.DATA_DIR = data_dir
|
PostBreachFilesService.initialize(data_dir)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# TODO: Remove circular dependency between ConfigService and PostBreachFilesService.
|
||||||
import monkey_island.cc.services.config
|
import monkey_island.cc.services.config
|
||||||
|
|
||||||
__author__ = "VakarisZ"
|
__author__ = "VakarisZ"
|
||||||
|
@ -16,6 +18,14 @@ class PostBreachFilesService:
|
||||||
DATA_DIR = None
|
DATA_DIR = None
|
||||||
CUSTOM_PBA_DIRNAME = "custom_pbas"
|
CUSTOM_PBA_DIRNAME = "custom_pbas"
|
||||||
|
|
||||||
|
# TODO: A number of these services should be instance objects instead of
|
||||||
|
# static/singleton hybrids. At the moment, this requires invasive refactoring that's
|
||||||
|
# not a priority.
|
||||||
|
@classmethod
|
||||||
|
def initialize(cls, data_dir):
|
||||||
|
cls.DATA_DIR = data_dir
|
||||||
|
Path(cls.get_custom_pba_directory()).mkdir(mode=0o0700, parents=True, exist_ok=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def remove_PBA_files():
|
def remove_PBA_files():
|
||||||
if monkey_island.cc.services.config.ConfigService.get_config():
|
if monkey_island.cc.services.config.ConfigService.get_config():
|
||||||
|
|
Loading…
Reference in New Issue