diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index ab09cfea1..4ea4590c7 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -10,7 +10,7 @@ from werkzeug.exceptions import NotFound from common import DIContainer from monkey_island.cc.database import database, mongo -from monkey_island.cc.resources import AgentBinaries, RemoteRun +from monkey_island.cc.resources import AgentBinaries, RemoteRun, ResetAgentConfiguration from monkey_island.cc.resources.AbstractResource import AbstractResource from monkey_island.cc.resources.agent_configuration import AgentConfiguration from monkey_island.cc.resources.agent_controls import StopAgentCheck, StopAllAgents @@ -198,7 +198,7 @@ def init_restful_endpoints(api: FlaskDIWrapper): def init_rpc_endpoints(api: FlaskDIWrapper): - pass + api.add_resource(ResetAgentConfiguration) def init_app(mongo_url: str, container: DIContainer): diff --git a/monkey/monkey_island/cc/resources/__init__.py b/monkey/monkey_island/cc/resources/__init__.py index 31ed641dd..fd830ed86 100644 --- a/monkey/monkey_island/cc/resources/__init__.py +++ b/monkey/monkey_island/cc/resources/__init__.py @@ -1,2 +1,3 @@ from .remote_run import RemoteRun from .agent_binaries import AgentBinaries +from .reset_agent_configuration import ResetAgentConfiguration diff --git a/monkey/monkey_island/cc/resources/reset_agent_configuration.py b/monkey/monkey_island/cc/resources/reset_agent_configuration.py new file mode 100644 index 000000000..274cad592 --- /dev/null +++ b/monkey/monkey_island/cc/resources/reset_agent_configuration.py @@ -0,0 +1,21 @@ +from flask import make_response + +from monkey_island.cc.repository import IAgentConfigurationRepository +from monkey_island.cc.resources.AbstractResource import AbstractResource +from monkey_island.cc.resources.request_authentication import jwt_required + + +class ResetAgentConfiguration(AbstractResource): + urls = ["/api/reset-agent-configuration"] + + def __init__(self, agent_configuration_repository: IAgentConfigurationRepository): + self._agent_configuration_repository = agent_configuration_repository + + @jwt_required + def post(self): + """ + Reset the agent configuration to its default values + """ + self._agent_configuration_repository.reset_to_default() + + return make_response({}, 200)