From 4eb7472977cb91407d7a639867a129d2e7714637 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 28 Jun 2022 20:12:55 -0700 Subject: [PATCH] Island: Remove functions from ConfigService that used the old config schema This breaks some stuff: the IslandConfiguration resource, the reset config functionality, and probably some other things. However, this isn't too much of a concern since all of this will be reimplemented in the coming weeks. It's just really broken for now. --- .../cc/resources/island_configuration.py | 2 +- monkey/monkey_island/cc/services/config.py | 37 +------------------ 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/monkey/monkey_island/cc/resources/island_configuration.py b/monkey/monkey_island/cc/resources/island_configuration.py index 38f08ff1b..411960f53 100644 --- a/monkey/monkey_island/cc/resources/island_configuration.py +++ b/monkey/monkey_island/cc/resources/island_configuration.py @@ -24,7 +24,7 @@ class IslandConfiguration(AbstractResource): # API Spec: Makes more sense to have a PATCH request for this since the resource, # i.e. the configuration, is being updated. if "reset" in config_json: - ConfigService.reset_config() + pass else: if not ConfigService.update_config(config_json, should_encrypt=True): abort(400) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 99f5a589c..5a80f7486 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -1,10 +1,9 @@ import collections -import copy import functools import logging from typing import Dict, List -from jsonschema import Draft4Validator, validators +from jsonschema import validators from common.config_value_paths import ( LM_HASH_LIST_PATH, @@ -23,8 +22,6 @@ from monkey_island.cc.server_utils.encryption import ( encrypt_dict, get_datastore_encryptor, ) -from monkey_island.cc.services.config_schema.config_schema import SCHEMA -from monkey_island.cc.services.post_breach_files import PostBreachFilesService logger = logging.getLogger(__name__) @@ -124,10 +121,6 @@ class ConfigService: return flat_config_json - @staticmethod - def get_config_schema(): - return SCHEMA - # Not added to interface because it's doable by get_config_field + set_config_field @staticmethod def add_item_to_config_set_if_dont_exist(item_path_array, item_value, should_encrypt): @@ -216,38 +209,10 @@ class ConfigService: ConfigService.set_config_value(PBA_LINUX_FILENAME_PATH, linux_filename) ConfigService.set_config_value(PBA_WINDOWS_FILENAME_PATH, windows_filename) - @staticmethod - def init_default_config(): - if ConfigService.default_config is None: - default_validating_draft4_validator = ConfigService._extend_config_with_default( - Draft4Validator - ) - config = {} - default_validating_draft4_validator(SCHEMA).validate(config) - ConfigService.default_config = config - - @staticmethod - def get_default_config(should_encrypt=False): - ConfigService.init_default_config() - config = copy.deepcopy(ConfigService.default_config) - - if should_encrypt: - ConfigService.encrypt_config(config) - - logger.info("Default config was called") - - return config - @staticmethod def init_config(): if ConfigService.get_config(should_decrypt=False) != {}: return - ConfigService.reset_config() - - @staticmethod - def reset_config(): - PostBreachFilesService.remove_PBA_files() - logger.info("Monkey config reset was called") @staticmethod def _extend_config_with_default(validator_class):