agent, island: Replace import path for `expand_path()` everywhere

This commit is contained in:
Shreya 2021-07-06 19:45:08 +05:30
parent d0a94e6223
commit 96c3a2ed12
4 changed files with 7 additions and 7 deletions

View File

@ -4,13 +4,13 @@ from pathlib import Path
from pprint import pformat from pprint import pformat
from typing import List, Optional, Tuple 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.bitflip_encryptor import BitflipEncryptor
from infection_monkey.ransomware.file_selectors import select_production_safe_target_files 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.ransomware.targeted_file_extensions import TARGETED_FILE_EXTENSIONS
from infection_monkey.telemetry.file_encryption_telem import FileEncryptionTelem from infection_monkey.telemetry.file_encryption_telem import FileEncryptionTelem
from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger
from infection_monkey.utils.environment import is_windows_os from infection_monkey.utils.environment import is_windows_os
from infection_monkey.utils.file_utils import expand_path
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -1,7 +1,7 @@
import os import os
from pathlib import Path 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 from monkey_island.cc.server_utils.file_utils import is_windows_os
__author__ = "itay.mizeretz" __author__ = "itay.mizeretz"
@ -26,7 +26,7 @@ SERVER_CONFIG_FILENAME = "server_config.json"
MONKEY_ISLAND_ABS_PATH = _get_monkey_island_abs_path() 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 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 _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) os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", SERVER_CONFIG_FILENAME)
) )

View File

@ -1,8 +1,8 @@
from typing import Tuple from typing import Tuple
from common.utils.file_utils import expand_path
from monkey_island.cc.arg_parser import IslandCmdArgs from monkey_island.cc.arg_parser import IslandCmdArgs
from monkey_island.cc.environment import server_config_handler 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.consts import DEFAULT_SERVER_CONFIG_PATH
from monkey_island.cc.server_utils.file_utils import create_secure_directory from monkey_island.cc.server_utils.file_utils import create_secure_directory
from monkey_island.cc.setup.island_config_options import IslandConfigOptions 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]: 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) config = server_config_handler.load_server_config_from_file(server_config_path)
create_secure_directory(config.data_dir) create_secure_directory(config.data_dir)
return config, server_config_path return config, server_config_path

View File

@ -1,5 +1,6 @@
from __future__ import annotations from __future__ import annotations
from common.utils.file_utils import expand_path
from monkey_island.cc.server_utils.consts import ( from monkey_island.cc.server_utils.consts import (
DEFAULT_CERTIFICATE_PATHS, DEFAULT_CERTIFICATE_PATHS,
DEFAULT_CRT_PATH, DEFAULT_CRT_PATH,
@ -8,7 +9,6 @@ from monkey_island.cc.server_utils.consts import (
DEFAULT_LOG_LEVEL, DEFAULT_LOG_LEVEL,
DEFAULT_START_MONGO_DB, DEFAULT_START_MONGO_DB,
) )
from monkey_island.cc.server_utils.file_utils import expand_path
class IslandConfigOptions: class IslandConfigOptions: