From 637978648a2b9e748cbbd7d23d1014c14884c822 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Fri, 23 Sep 2022 11:53:14 +0530 Subject: [PATCH] Island: Remove StopAllAgents resource --- monkey/monkey_island/cc/app.py | 3 +-- .../cc/resources/agent_controls/__init__.py | 1 - .../agent_controls/stop_all_agents.py | 27 ------------------- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 monkey/monkey_island/cc/resources/agent_controls/stop_all_agents.py diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 41d03372b..3d127d985 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -26,7 +26,7 @@ from monkey_island.cc.resources import ( ResetAgentConfiguration, ) from monkey_island.cc.resources.AbstractResource import AbstractResource -from monkey_island.cc.resources.agent_controls import StopAgentCheck, StopAllAgents +from monkey_island.cc.resources.agent_controls import StopAgentCheck from monkey_island.cc.resources.attack.attack_report import AttackReport from monkey_island.cc.resources.auth import Authenticate, Register, RegistrationStatus, init_jwt from monkey_island.cc.resources.blackbox.log_blackbox_endpoint import LogBlackboxEndpoint @@ -199,7 +199,6 @@ def init_restful_endpoints(api: FlaskDIWrapper): api.add_resource(RemoteRun) api.add_resource(Version) api.add_resource(StopAgentCheck) - api.add_resource(StopAllAgents) # Resources used by black box tests # API Spec: Fix all the following endpoints, see comments in the resource classes diff --git a/monkey/monkey_island/cc/resources/agent_controls/__init__.py b/monkey/monkey_island/cc/resources/agent_controls/__init__.py index 211696e4c..4bc6d5b48 100644 --- a/monkey/monkey_island/cc/resources/agent_controls/__init__.py +++ b/monkey/monkey_island/cc/resources/agent_controls/__init__.py @@ -1,2 +1 @@ -from .stop_all_agents import StopAllAgents from .stop_agent_check import StopAgentCheck diff --git a/monkey/monkey_island/cc/resources/agent_controls/stop_all_agents.py b/monkey/monkey_island/cc/resources/agent_controls/stop_all_agents.py deleted file mode 100644 index c3d719bd8..000000000 --- a/monkey/monkey_island/cc/resources/agent_controls/stop_all_agents.py +++ /dev/null @@ -1,27 +0,0 @@ -import json - -from flask import make_response, request - -from monkey_island.cc.resources.AbstractResource import AbstractResource -from monkey_island.cc.resources.request_authentication import jwt_required -from monkey_island.cc.resources.utils.semaphores import agent_killing_mutex -from monkey_island.cc.services.infection_lifecycle import set_stop_all, should_agent_die - - -class StopAllAgents(AbstractResource): - # API Spec: This is an action and there's no "resource"; RPC-style endpoint? - urls = ["/api/monkey-control/stop-all-agents"] - - @jwt_required - def post(self): - with agent_killing_mutex: - data = json.loads(request.data) - if data["kill_time"]: - set_stop_all(data["kill_time"]) - return make_response({}, 200) - else: - return make_response({}, 400) - - # API Spec: This is the exact same thing as what's in StopAgentCheck - def get(self, monkey_guid): - return {"stop_agent": should_agent_die(monkey_guid)}