Merge pull request #2065 from guardicore/1965-modify-clear-simulation-data

Modify /api/clear-simulation-data to clear stolen credentials
This commit is contained in:
Mike Salvatore 2022-07-07 12:56:50 -04:00 committed by GitHub
commit 1ab190cd2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 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,11 +10,15 @@ 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):
"""
Clear all data collected during the simulation
"""
Database.reset_db(reset_config=False)
self._credentials_repository.remove_stolen_credentials()
return make_response({}, 200)