Island: Add /api/reset-agent-configuration RPC endpoint

This commit is contained in:
Mike Salvatore 2022-06-30 12:33:13 -04:00
parent 03ec893e97
commit 6d4920e47f
3 changed files with 24 additions and 2 deletions

View File

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

View File

@ -1,2 +1,3 @@
from .remote_run import RemoteRun
from .agent_binaries import AgentBinaries
from .reset_agent_configuration import ResetAgentConfiguration

View File

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