Island: Add agent_event_handlers

This commit is contained in:
Ilija Lazoroski 2022-09-14 17:18:55 +02:00
parent 26fc6fd5b9
commit 5a836daaa7
2 changed files with 17 additions and 0 deletions

View File

@ -1,2 +1,3 @@
from .pywsgi_logging_filter import PyWSGILoggingFilter
from .island_event_handlers import setup_island_event_handlers
from .agent_event_handlers import setup_agent_event_handlers

View File

@ -0,0 +1,16 @@
from common import DIContainer
from common.event_queue import IAgentEventQueue
from monkey_island.cc.agent_event_subscribers import save_event_to_event_repository
from monkey_island.cc.repository import IEventRepository
def setup_agent_event_handlers(container: DIContainer):
_subscribe_and_store_to_event_repository(container)
def _subscribe_and_store_to_event_repository(container: DIContainer):
agent_event_queue = container.resolve(IAgentEventQueue)
event_repository = container.resolve(IEventRepository)
save_event_subscriber = save_event_to_event_repository(event_repository)
agent_event_queue.subscribe_all_events(save_event_subscriber)