diff --git a/monkey/monkey_island/cc/setup/config_setup.py b/monkey/monkey_island/cc/setup/config_setup.py index 77652ddba..dee694b68 100644 --- a/monkey/monkey_island/cc/setup/config_setup.py +++ b/monkey/monkey_island/cc/setup/config_setup.py @@ -11,29 +11,29 @@ logger = getLogger(__name__) def get_server_config(island_args: IslandCmdArgs) -> IslandConfigOptions: - config = IslandConfigOptions({}) + config = IslandConfigOptions() - update_config_from_file(config, PACKAGE_CONFIG_PATH) + _update_config_from_file(config, PACKAGE_CONFIG_PATH) - update_config_from_file(config, USER_CONFIG_PATH) + _update_config_from_file(config, USER_CONFIG_PATH) if island_args.server_config_path: path_to_config = expand_path(island_args.server_config_path) - update_config_from_file(config, path_to_config) + _update_config_from_file(config, path_to_config) return config -def update_config_from_file(config: IslandConfigOptions, config_path: Path): +def _update_config_from_file(config: IslandConfigOptions, config_path: Path): try: - config_from_file = load_server_config_from_file(config_path) + config_from_file = _load_server_config_from_file(config_path) config.update(config_from_file) logger.info(f"Server config updated from {config_path}") except OSError: logger.info(f"Server config not found in path {config_path}") -def load_server_config_from_file(server_config_path) -> IslandConfigOptions: +def _load_server_config_from_file(server_config_path) -> IslandConfigOptions: with open(server_config_path, "r") as f: config_content = f.read() config = json.loads(config_content) diff --git a/monkey/monkey_island/cc/setup/island_config_options.py b/monkey/monkey_island/cc/setup/island_config_options.py index 12b141923..a9cf66785 100644 --- a/monkey/monkey_island/cc/setup/island_config_options.py +++ b/monkey/monkey_island/cc/setup/island_config_options.py @@ -12,7 +12,9 @@ from monkey_island.cc.server_utils.consts import ( class IslandConfigOptions: - def __init__(self, config_contents: dict): + def __init__(self, config_contents: dict = None): + if not config_contents: + config_contents = {} self.data_dir = expand_path(config_contents.get("data_dir", DEFAULT_DATA_DIR)) self.log_level = config_contents.get("log_level", DEFAULT_LOG_LEVEL)