island: Fix stuff in `config_manipulator.py` after testing

This commit is contained in:
Shreya 2021-07-20 16:26:32 +05:30
parent 42b558674e
commit af86cb088f
1 changed files with 7 additions and 5 deletions

View File

@ -9,16 +9,18 @@ from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
def update_config_on_mode_set(mode: IslandModeEnum) -> bool: def update_config_on_mode_set(mode: IslandModeEnum) -> bool:
config = config_service.ConfigService.get_config() config = config_service.ConfigService.get_config()
return update_config_per_mode(mode, config, True) return update_config_per_mode(mode.value, config, True)
def update_config_per_mode(mode: IslandModeEnum, config: Dict, should_encrypt: bool) -> bool: def update_config_per_mode(mode: str, config: Dict, should_encrypt: bool) -> bool:
config = _set_default_config_values_per_mode(mode, config) config = _set_default_config_values_per_mode(mode, config)
return config_service.ConfigService.update_config(config_json=config, should_encrypt=True) return config_service.ConfigService.update_config(
config_json=config, should_encrypt=should_encrypt
)
def _set_default_config_values_per_mode(mode: IslandModeEnum, config: Dict) -> Dict: def _set_default_config_values_per_mode(mode: str, config: Dict) -> Dict:
config_filter = FILTER_PER_MODE[mode.value] config_filter = FILTER_PER_MODE[mode]
config = _apply_config_filter(config, config_filter) config = _apply_config_filter(config, config_filter)
return config return config