diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 4ea4590c7..6a8876e21 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -10,7 +10,12 @@ 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, ResetAgentConfiguration +from monkey_island.cc.resources import ( + AgentBinaries, + ClearSimulationData, + 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 @@ -199,6 +204,7 @@ def init_restful_endpoints(api: FlaskDIWrapper): def init_rpc_endpoints(api: FlaskDIWrapper): api.add_resource(ResetAgentConfiguration) + api.add_resource(ClearSimulationData) 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 fd830ed86..7f0385c32 100644 --- a/monkey/monkey_island/cc/resources/__init__.py +++ b/monkey/monkey_island/cc/resources/__init__.py @@ -1,3 +1,4 @@ from .remote_run import RemoteRun from .agent_binaries import AgentBinaries +from .clear_simulation_data import ClearSimulationData from .reset_agent_configuration import ResetAgentConfiguration diff --git a/monkey/monkey_island/cc/resources/clear_simulation_data.py b/monkey/monkey_island/cc/resources/clear_simulation_data.py new file mode 100644 index 000000000..c7da0424a --- /dev/null +++ b/monkey/monkey_island/cc/resources/clear_simulation_data.py @@ -0,0 +1,18 @@ +from flask import make_response + +from monkey_island.cc.resources.AbstractResource import AbstractResource +from monkey_island.cc.resources.request_authentication import jwt_required +from monkey_island.cc.services.database import Database + + +class ClearSimulationData(AbstractResource): + urls = ["/api/clear-simulation-data"] + + @jwt_required + def post(self): + """ + Clear all data collected during the simulation + """ + Database.reset_db(reset_config=False) + + return make_response({}, 200)