diff --git a/monkey/monkey_island/cc/resources/clear_simulation_data.py b/monkey/monkey_island/cc/resources/clear_simulation_data.py index c7da0424a..749628319 100644 --- a/monkey/monkey_island/cc/resources/clear_simulation_data.py +++ b/monkey/monkey_island/cc/resources/clear_simulation_data.py @@ -1,5 +1,7 @@ from flask import make_response +from monkey_island.cc.repository import RemovalError +from monkey_island.cc.repository.i_credentials_repository import ICredentialsRepository 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 @@ -8,6 +10,9 @@ from monkey_island.cc.services.database import Database class ClearSimulationData(AbstractResource): urls = ["/api/clear-simulation-data"] + def __init__(self, credentials_repository: ICredentialsRepository): + self._credentials_repository = credentials_repository + @jwt_required def post(self): """ @@ -15,4 +20,11 @@ class ClearSimulationData(AbstractResource): """ Database.reset_db(reset_config=False) + try: + self._credentials_repository.remove_stolen_credentials() + except RemovalError as err: + make_response( + {"error": f"Error encountered while removing stolen credentials: {err}"}, 400 + ) + return make_response({}, 200)