From cfe31f8dee3c5d7323d160382769cf294e746eef Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Fri, 23 Sep 2022 13:41:09 +0530 Subject: [PATCH] Island: Use terminate signal's timestamp directly instead of creating an AgentSignals object in AgentSignals resource --- monkey/monkey_island/cc/resources/agent_signals.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/monkey/monkey_island/cc/resources/agent_signals.py b/monkey/monkey_island/cc/resources/agent_signals.py index e55a489d4..b2abba820 100644 --- a/monkey/monkey_island/cc/resources/agent_signals.py +++ b/monkey/monkey_island/cc/resources/agent_signals.py @@ -5,7 +5,6 @@ from json import JSONDecodeError from flask import request from monkey_island.cc.event_queue import IIslandEventQueue, IslandEventTopic -from monkey_island.cc.models import AgentSignals as Signals from monkey_island.cc.resources.AbstractResource import AbstractResource logger = logging.getLogger(__name__) @@ -22,11 +21,14 @@ class AgentSignals(AbstractResource): def post(self): try: - signal = Signals(**request.json) - - if signal.terminate is None: + terminate_timestamp = request.json["kill_time"] + if terminate_timestamp is None: raise ValueError("Terminate signal's timestamp is empty") - self._island_event_queue.publish(IslandEventTopic.TERMINATE_AGENTS, signal=signal) + + self._island_event_queue.publish( + IslandEventTopic.TERMINATE_AGENTS, timestamp=terminate_timestamp + ) + except (JSONDecodeError, TypeError, ValueError) as err: return {"error": err}, HTTPStatus.BAD_REQUEST