forked from p15670423/monkey
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.
This commit is contained in:
parent
b883f502ed
commit
4eb7472977
|
@ -24,7 +24,7 @@ class IslandConfiguration(AbstractResource):
|
||||||
# API Spec: Makes more sense to have a PATCH request for this since the resource,
|
# API Spec: Makes more sense to have a PATCH request for this since the resource,
|
||||||
# i.e. the configuration, is being updated.
|
# i.e. the configuration, is being updated.
|
||||||
if "reset" in config_json:
|
if "reset" in config_json:
|
||||||
ConfigService.reset_config()
|
pass
|
||||||
else:
|
else:
|
||||||
if not ConfigService.update_config(config_json, should_encrypt=True):
|
if not ConfigService.update_config(config_json, should_encrypt=True):
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import collections
|
import collections
|
||||||
import copy
|
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
from jsonschema import Draft4Validator, validators
|
from jsonschema import validators
|
||||||
|
|
||||||
from common.config_value_paths import (
|
from common.config_value_paths import (
|
||||||
LM_HASH_LIST_PATH,
|
LM_HASH_LIST_PATH,
|
||||||
|
@ -23,8 +22,6 @@ from monkey_island.cc.server_utils.encryption import (
|
||||||
encrypt_dict,
|
encrypt_dict,
|
||||||
get_datastore_encryptor,
|
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__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -124,10 +121,6 @@ class ConfigService:
|
||||||
|
|
||||||
return flat_config_json
|
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
|
# Not added to interface because it's doable by get_config_field + set_config_field
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_item_to_config_set_if_dont_exist(item_path_array, item_value, should_encrypt):
|
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_LINUX_FILENAME_PATH, linux_filename)
|
||||||
ConfigService.set_config_value(PBA_WINDOWS_FILENAME_PATH, windows_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
|
@staticmethod
|
||||||
def init_config():
|
def init_config():
|
||||||
if ConfigService.get_config(should_decrypt=False) != {}:
|
if ConfigService.get_config(should_decrypt=False) != {}:
|
||||||
return
|
return
|
||||||
ConfigService.reset_config()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def reset_config():
|
|
||||||
PostBreachFilesService.remove_PBA_files()
|
|
||||||
logger.info("Monkey config reset was called")
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extend_config_with_default(validator_class):
|
def _extend_config_with_default(validator_class):
|
||||||
|
|
Loading…
Reference in New Issue