Island: Rename IslandModeEnum.SET_ISLAND_MODE's subscribers' arguments from 'event' to 'mode'

This commit is contained in:
Shreya Malviya 2022-09-21 18:00:34 +05:30
parent c1e15f8be5
commit add31fe397
3 changed files with 4 additions and 9 deletions

View File

@ -1,5 +1,3 @@
from typing import Any
from common.agent_configuration import AgentConfiguration
from monkey_island.cc.models import IslandMode
from monkey_island.cc.repository import IAgentConfigurationRepository
@ -20,8 +18,7 @@ class set_agent_configuration_per_island_mode:
self._default_agent_configuration = default_agent_configuration
self._default_ransomware_agent_configuration = default_ransomware_agent_configuration
def __call__(self, event: Any = None):
mode = event
def __call__(self, mode: IslandMode):
if mode == IslandMode.RANSOMWARE:
self._agent_configuration_repository.store_configuration(
self._default_ransomware_agent_configuration

View File

@ -1,5 +1,4 @@
from typing import Any
from monkey_island.cc.models import IslandMode
from monkey_island.cc.repository import ISimulationRepository
@ -14,6 +13,5 @@ class set_simulation_mode:
):
self._simulation_repository = simulation_repository
def __call__(self, event: Any = None):
mode = event
def __call__(self, mode: IslandMode):
self._simulation_repository.set_mode(mode)

View File

@ -28,7 +28,7 @@ class IslandMode(AbstractResource):
def put(self):
try:
mode = IslandModeEnum(request.json)
self._island_event_queue.publish(topic=IslandEventTopic.SET_ISLAND_MODE, event=mode)
self._island_event_queue.publish(topic=IslandEventTopic.SET_ISLAND_MODE, mode=mode)
return {}, HTTPStatus.NO_CONTENT
except (AttributeError, json.decoder.JSONDecodeError):
return {}, HTTPStatus.BAD_REQUEST