forked from p15670423/monkey
island: Decouple PostBreachFilesService from environment_singleton
This commit is contained in:
parent
a7f2e023b8
commit
ee19eed596
|
@ -26,6 +26,7 @@ from monkey_island.cc.resources.monkey_download import MonkeyDownload # noqa: E
|
||||||
from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402
|
from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402
|
||||||
from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH # noqa: E402
|
from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH # noqa: E402
|
||||||
from monkey_island.cc.server_utils.encryptor import initialize_encryptor # noqa: E402
|
from monkey_island.cc.server_utils.encryptor import initialize_encryptor # noqa: E402
|
||||||
|
from monkey_island.cc.services.initialize import initialize_services # noqa: E402
|
||||||
from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402
|
from monkey_island.cc.services.reporting.exporter_init import populate_exporter_list # noqa: E402
|
||||||
from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402
|
from monkey_island.cc.services.utils.network_utils import local_ip_addresses # noqa: E402
|
||||||
from monkey_island.cc.setup import setup # noqa: E402
|
from monkey_island.cc.setup import setup # noqa: E402
|
||||||
|
@ -39,6 +40,7 @@ def main(should_setup_only=False, server_config_filename=DEFAULT_SERVER_CONFIG_P
|
||||||
data_dir = env_singleton.env.get_config().data_dir_abs_path
|
data_dir = env_singleton.env.get_config().data_dir_abs_path
|
||||||
env_singleton.initialize_from_file(server_config_filename)
|
env_singleton.initialize_from_file(server_config_filename)
|
||||||
initialize_encryptor(data_dir)
|
initialize_encryptor(data_dir)
|
||||||
|
initialize_services(data_dir)
|
||||||
|
|
||||||
mongo_url = os.environ.get("MONGO_URL", env_singleton.env.get_mongo_url())
|
mongo_url = os.environ.get("MONGO_URL", env_singleton.env.get_mongo_url())
|
||||||
bootloader_server_thread = Thread(
|
bootloader_server_thread = Thread(
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
from monkey_island.cc.services.post_breach_files import PostBreachFilesService
|
||||||
|
|
||||||
|
|
||||||
|
def initialize_services(data_dir):
|
||||||
|
initialize_post_breach_file_service(data_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def initialize_post_breach_file_service(data_dir):
|
||||||
|
PostBreachFilesService.DATA_DIR = data_dir
|
|
@ -5,8 +5,6 @@ import monkey_island.cc.services.config
|
||||||
|
|
||||||
__author__ = "VakarisZ"
|
__author__ = "VakarisZ"
|
||||||
|
|
||||||
import monkey_island.cc.environment.environment_singleton as env_singleton
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Where to find file names in config
|
# Where to find file names in config
|
||||||
|
@ -15,6 +13,8 @@ PBA_LINUX_FILENAME_PATH = ["monkey", "post_breach", "PBA_linux_filename"]
|
||||||
|
|
||||||
|
|
||||||
class PostBreachFilesService:
|
class PostBreachFilesService:
|
||||||
|
DATA_DIR = None
|
||||||
|
|
||||||
@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():
|
||||||
|
@ -31,7 +31,7 @@ class PostBreachFilesService:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _remove_file(file_name):
|
def _remove_file(file_name):
|
||||||
file_path = os.path.join(env_singleton.env.get_config().data_dir_abs_path, file_name)
|
file_path = os.path.join(PostBreachFilesService.DATA_DIR, file_name)
|
||||||
try:
|
try:
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
Loading…
Reference in New Issue