diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 8800d382a..817a43333 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -26,6 +26,7 @@ from monkey_island.cc.resources.edge import Edge from monkey_island.cc.resources.environment import Environment from monkey_island.cc.resources.island_configuration import IslandConfiguration from monkey_island.cc.resources.island_logs import IslandLog +from monkey_island.cc.resources.island_mode import IslandMode from monkey_island.cc.resources.local_run import LocalRun from monkey_island.cc.resources.log import Log from monkey_island.cc.resources.monkey import Monkey @@ -132,6 +133,8 @@ def init_api_resources(api): api.add_resource( Telemetry, "/api/telemetry", "/api/telemetry/", "/api/telemetry/" ) + + api.add_resource(IslandMode, "/api/island-mode") api.add_resource(MonkeyConfiguration, "/api/configuration", "/api/configuration/") api.add_resource(IslandConfiguration, "/api/configuration/island", "/api/configuration/island/") api.add_resource(ConfigurationExport, "/api/configuration/export") diff --git a/monkey/monkey_island/cc/resources/island_mode.py b/monkey/monkey_island/cc/resources/island_mode.py new file mode 100644 index 000000000..d0a109564 --- /dev/null +++ b/monkey/monkey_island/cc/resources/island_mode.py @@ -0,0 +1,20 @@ +import json + +import flask_restful +from flask import make_response, request + +from monkey_island.cc.resources.auth.auth import jwt_required +from monkey_island.cc.services.mode import island_mode_service +from monkey_island.cc.services.mode.mode_enum import IslandModeEnum + + +class IslandMode(flask_restful.Resource): + @jwt_required + def post(self): + body = json.loads(request.data) + mode_str = body.get("mode") + mode = IslandModeEnum(mode_str) + island_mode_service.set_mode(mode) + + # TODO return status + return make_response({}) diff --git a/monkey/monkey_island/cc/services/mode/__init__.py b/monkey/monkey_island/cc/services/mode/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/monkey/monkey_island/cc/services/mode/island_mode_service.py b/monkey/monkey_island/cc/services/mode/island_mode_service.py new file mode 100644 index 000000000..86f3e6d09 --- /dev/null +++ b/monkey/monkey_island/cc/services/mode/island_mode_service.py @@ -0,0 +1,5 @@ +from monkey_island.cc.services.mode.mode_enum import IslandModeEnum + + +def set_mode(mode: IslandModeEnum): + pass diff --git a/monkey/monkey_island/cc/services/mode/mode_enum.py b/monkey/monkey_island/cc/services/mode/mode_enum.py new file mode 100644 index 000000000..fce46db97 --- /dev/null +++ b/monkey/monkey_island/cc/services/mode/mode_enum.py @@ -0,0 +1,6 @@ +from enum import Enum + + +class IslandModeEnum(Enum): + RANSOMWARE = "ransomware" + ADVANCED = "advanced"