From 96c3a2ed121758bcd8ce101b0cc9efaaedf946bb Mon Sep 17 00:00:00 2001 From: Shreya Date: Tue, 6 Jul 2021 19:45:08 +0530 Subject: [PATCH] agent, island: Replace import path for `expand_path()` everywhere --- monkey/infection_monkey/ransomware/ransomware_payload.py | 2 +- monkey/monkey_island/cc/server_utils/consts.py | 6 +++--- monkey/monkey_island/cc/setup/config_setup.py | 4 ++-- monkey/monkey_island/cc/setup/island_config_options.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/monkey/infection_monkey/ransomware/ransomware_payload.py b/monkey/infection_monkey/ransomware/ransomware_payload.py index f3eece669..a58b50545 100644 --- a/monkey/infection_monkey/ransomware/ransomware_payload.py +++ b/monkey/infection_monkey/ransomware/ransomware_payload.py @@ -4,13 +4,13 @@ from pathlib import Path from pprint import pformat from typing import List, Optional, Tuple +from common.utils.file_utils import expand_path from infection_monkey.ransomware.bitflip_encryptor import BitflipEncryptor from infection_monkey.ransomware.file_selectors import select_production_safe_target_files from infection_monkey.ransomware.targeted_file_extensions import TARGETED_FILE_EXTENSIONS from infection_monkey.telemetry.file_encryption_telem import FileEncryptionTelem from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger from infection_monkey.utils.environment import is_windows_os -from infection_monkey.utils.file_utils import expand_path LOG = logging.getLogger(__name__) diff --git a/monkey/monkey_island/cc/server_utils/consts.py b/monkey/monkey_island/cc/server_utils/consts.py index 13e0c66e4..90ca0252a 100644 --- a/monkey/monkey_island/cc/server_utils/consts.py +++ b/monkey/monkey_island/cc/server_utils/consts.py @@ -1,7 +1,7 @@ import os from pathlib import Path -from monkey_island.cc.server_utils import file_utils +from common.utils.file_utils import expand_path from monkey_island.cc.server_utils.file_utils import is_windows_os __author__ = "itay.mizeretz" @@ -26,7 +26,7 @@ SERVER_CONFIG_FILENAME = "server_config.json" MONKEY_ISLAND_ABS_PATH = _get_monkey_island_abs_path() -DEFAULT_DATA_DIR = file_utils.expand_path(get_default_data_dir()) +DEFAULT_DATA_DIR = expand_path(get_default_data_dir()) DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS = 60 * 5 @@ -37,7 +37,7 @@ MONGO_EXECUTABLE_PATH = ( _MONGO_EXECUTABLE_PATH_WIN if is_windows_os() else _MONGO_EXECUTABLE_PATH_LINUX ) -DEFAULT_SERVER_CONFIG_PATH = file_utils.expand_path( +DEFAULT_SERVER_CONFIG_PATH = expand_path( os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", SERVER_CONFIG_FILENAME) ) diff --git a/monkey/monkey_island/cc/setup/config_setup.py b/monkey/monkey_island/cc/setup/config_setup.py index 657ffaac5..c850bf96f 100644 --- a/monkey/monkey_island/cc/setup/config_setup.py +++ b/monkey/monkey_island/cc/setup/config_setup.py @@ -1,8 +1,8 @@ from typing import Tuple +from common.utils.file_utils import expand_path from monkey_island.cc.arg_parser import IslandCmdArgs from monkey_island.cc.environment import server_config_handler -from monkey_island.cc.server_utils import file_utils from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH from monkey_island.cc.server_utils.file_utils import create_secure_directory from monkey_island.cc.setup.island_config_options import IslandConfigOptions @@ -16,7 +16,7 @@ def setup_data_dir(island_args: IslandCmdArgs) -> Tuple[IslandConfigOptions, str def _setup_config_by_cmd_arg(server_config_path) -> Tuple[IslandConfigOptions, str]: - server_config_path = file_utils.expand_path(server_config_path) + server_config_path = expand_path(server_config_path) config = server_config_handler.load_server_config_from_file(server_config_path) create_secure_directory(config.data_dir) return config, server_config_path diff --git a/monkey/monkey_island/cc/setup/island_config_options.py b/monkey/monkey_island/cc/setup/island_config_options.py index 9704e5f45..66a49306a 100644 --- a/monkey/monkey_island/cc/setup/island_config_options.py +++ b/monkey/monkey_island/cc/setup/island_config_options.py @@ -1,5 +1,6 @@ from __future__ import annotations +from common.utils.file_utils import expand_path from monkey_island.cc.server_utils.consts import ( DEFAULT_CERTIFICATE_PATHS, DEFAULT_CRT_PATH, @@ -8,7 +9,6 @@ from monkey_island.cc.server_utils.consts import ( DEFAULT_LOG_LEVEL, DEFAULT_START_MONGO_DB, ) -from monkey_island.cc.server_utils.file_utils import expand_path class IslandConfigOptions: