diff --git a/monkey/monkey_island/cc/resources/agent_signals.py b/monkey/monkey_island/cc/resources/agent_signals.py index e67478175..f6ce22f71 100644 --- a/monkey/monkey_island/cc/resources/agent_signals.py +++ b/monkey/monkey_island/cc/resources/agent_signals.py @@ -1,10 +1,6 @@ import logging from http import HTTPStatus -from json import JSONDecodeError -from flask import request - -from monkey_island.cc.event_queue import IIslandEventQueue, IslandEventTopic from monkey_island.cc.resources.AbstractResource import AbstractResource from monkey_island.cc.services import AgentSignalsService @@ -12,33 +8,14 @@ logger = logging.getLogger(__name__) class AgentSignals(AbstractResource): - urls = ["/api/agent-signals/terminate-all", "/api/agent-signals/"] + urls = ["/api/agent-signals/"] def __init__( self, - island_event_queue: IIslandEventQueue, agent_signals_service: AgentSignalsService, ): - self._island_event_queue = island_event_queue self._agent_signals_service = agent_signals_service - def post(self): - try: - terminate_timestamp = request.json["terminate_time"] - if terminate_timestamp is None: - raise ValueError("Terminate signal's timestamp is empty") - elif terminate_timestamp <= 0: - raise ValueError("Terminate signal's timestamp is not a positive integer") - - self._island_event_queue.publish( - IslandEventTopic.TERMINATE_AGENTS, timestamp=terminate_timestamp - ) - - except (JSONDecodeError, TypeError, ValueError, KeyError) as err: - return {"error": err}, HTTPStatus.BAD_REQUEST - - return {}, HTTPStatus.NO_CONTENT - def get(self, agent_id: str): agent_signals = self._agent_signals_service.get_signals(agent_id) return agent_signals.dict(simplify=True), HTTPStatus.OK