Island: Remove stolen credentials when clearing simulation data

This commit is contained in:
Shreya Malviya 2022-07-06 22:14:44 -07:00
parent 833513e383
commit e34bb760e3
1 changed files with 12 additions and 0 deletions

View File

@ -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)