forked from p15670423/monkey
island: Return and log if config update was not successful on mode set
This commit is contained in:
parent
fab7738174
commit
9c48c115be
|
@ -249,14 +249,14 @@ class ConfigService:
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_config_on_mode_set(mode: IslandModeEnum) -> None:
|
def update_config_on_mode_set(mode: IslandModeEnum) -> bool:
|
||||||
config = ConfigService.get_config()
|
config = ConfigService.get_config()
|
||||||
ConfigService.update_config_per_mode(mode, config, True)
|
return ConfigService.update_config_per_mode(mode, config, True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_config_per_mode(mode: IslandModeEnum, config: Dict, should_encrypt: bool) -> None:
|
def update_config_per_mode(mode: IslandModeEnum, config: Dict, should_encrypt: bool) -> bool:
|
||||||
config = ConfigService._set_default_config_values_per_mode(mode, config)
|
config = ConfigService._set_default_config_values_per_mode(mode, config)
|
||||||
ConfigService.update_config(config_json=config, should_encrypt=True)
|
return ConfigService.update_config(config_json=config, should_encrypt=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _set_default_config_values_per_mode(mode: IslandModeEnum, config: Dict) -> Dict:
|
def _set_default_config_values_per_mode(mode: IslandModeEnum, config: Dict) -> Dict:
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
from monkey_island.cc.models.island_mode_model import IslandMode
|
from monkey_island.cc.models.island_mode_model import IslandMode
|
||||||
from monkey_island.cc.services.config import ConfigService
|
from monkey_island.cc.services.config import ConfigService
|
||||||
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def set_mode(mode: IslandModeEnum):
|
def set_mode(mode: IslandModeEnum):
|
||||||
island_mode_model = IslandMode()
|
island_mode_model = IslandMode()
|
||||||
island_mode_model.mode = mode.value
|
island_mode_model.mode = mode.value
|
||||||
island_mode_model.save()
|
island_mode_model.save()
|
||||||
ConfigService.update_config_on_mode_set(mode)
|
if not ConfigService.update_config_on_mode_set(mode):
|
||||||
|
LOG.error(
|
||||||
|
"Could not apply configuration changes per mode. Using default advanced configuration."
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue