Implement the `EventQueue`
Summary
The EventQueue will manage publisher/subscriber functionality within both the agent and island. Implement the event queue using pypubsub.
Goals
- Publishers and subscribers should be protected from implementation details. That is to say, neither publishers nor subscribers should know we are using pypubsub, and changing the pub/sub implementation should not affect publishers or subscribers in any way.
- Events should be published to the
Eventstopic so that a subscriber could subscribe to receive all events - Events should be published to a topic matching their type so that a subscriber can subscribe for certain types of events
- Events should be published to a topic for each tag so that a subscriber can subscribe to all events with a certain tag
Architectural details
Types vs Tags
Events of the same type are guaranteed to have the same structure (attributes). Tags allow events of different types to be grouped, or events of the same type to be separated. For example, we may send one type of event for OS discovery, and another type for information about the model of the CPU. These events will contain different data and are therefore different types. But both events are considered ATT&CK T1082, System Information Discovery. Another example would be that two different exploiters both send LoginAttempt events. They could give different tags to their events which allow us to easily see which login events come from which exploiter.
IEventQueue
An interface for event queues will allow us to insulate publishers/subscribers from event queue implementation details:
from typing import Callable
from common.events import AbstractEvent
class IEventQueue:
def subscribe_all(self, subscriber: Callable[[AbstractEvent], None):
pass
def subscribe_type(self, type: Type[T], subscriber: Callable[[T], None):
pass
def subscribe_tag(self, tag: str subscriber: Callable[[AbstractEvent], None):
pass
def publish(self, event: AbstractEvent):
pass
Tasks
- [x] Create
IEventQueue(0d) - @shreyamalviya - [ ] Implement
IEventQueueusing pypubsub (0.5d) - @shreyamalviya