forked from p15670423/monkey
island: Update config after mode set in island mode resource instead of island mode service
This commit is contained in:
parent
ad24a35acb
commit
736c8008a0
|
@ -5,10 +5,11 @@ import flask_restful
|
||||||
from flask import make_response, request
|
from flask import make_response, request
|
||||||
|
|
||||||
from monkey_island.cc.resources.auth.auth import jwt_required
|
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||||
|
from monkey_island.cc.services.config_manipulator import update_config_on_mode_set
|
||||||
from monkey_island.cc.services.mode.island_mode_service import ModeNotSetError, get_mode, set_mode
|
from monkey_island.cc.services.mode.island_mode_service import ModeNotSetError, get_mode, set_mode
|
||||||
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IslandMode(flask_restful.Resource):
|
class IslandMode(flask_restful.Resource):
|
||||||
|
@ -21,6 +22,12 @@ class IslandMode(flask_restful.Resource):
|
||||||
mode = IslandModeEnum(mode_str)
|
mode = IslandModeEnum(mode_str)
|
||||||
set_mode(mode)
|
set_mode(mode)
|
||||||
|
|
||||||
|
if not update_config_on_mode_set(mode):
|
||||||
|
LOG.error(
|
||||||
|
"Could not apply configuration changes per mode. "
|
||||||
|
"Using default advanced configuration."
|
||||||
|
)
|
||||||
|
|
||||||
return make_response({}, 200)
|
return make_response({}, 200)
|
||||||
except (AttributeError, json.decoder.JSONDecodeError):
|
except (AttributeError, json.decoder.JSONDecodeError):
|
||||||
return make_response({}, 400)
|
return make_response({}, 400)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import logging
|
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_manipulator import update_config_on_mode_set
|
|
||||||
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -11,10 +10,6 @@ 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()
|
||||||
if not update_config_on_mode_set(mode):
|
|
||||||
LOG.error(
|
|
||||||
"Could not apply configuration changes per mode. Using default advanced configuration."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_mode() -> str:
|
def get_mode() -> str:
|
||||||
|
|
Loading…
Reference in New Issue