From e79a29f7aabaa989322f06d497cde0efa7841b29 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 2 Aug 2022 13:15:33 -0400 Subject: [PATCH] Common: Add AbstractEvent --- monkey/common/events/__init__.py | 1 + monkey/common/events/abstract_event.py | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 monkey/common/events/__init__.py create mode 100644 monkey/common/events/abstract_event.py diff --git a/monkey/common/events/__init__.py b/monkey/common/events/__init__.py new file mode 100644 index 000000000..230e6635f --- /dev/null +++ b/monkey/common/events/__init__.py @@ -0,0 +1 @@ +from abstract_event import AbstractEvent diff --git a/monkey/common/events/abstract_event.py b/monkey/common/events/abstract_event.py new file mode 100644 index 000000000..33bb25506 --- /dev/null +++ b/monkey/common/events/abstract_event.py @@ -0,0 +1,27 @@ +from abc import ABC +from dataclasses import dataclass +from ipaddress import IPv4Address +from typing import FrozenSet, Union +from uuid import UUID + + +@dataclass(frozen=True) +class AbstractEvent(ABC): + """ + An event that was initiated or observed by an agent + + Agents perform actions and collect data. These actions and data are represented as "events". + Subtypes of `AbstractEvent` will have additional properties that provide context and information + about the event. + + Attributes: + :param source: The UUID of the agent that observed the event + :param target: The target of the event (if not the local system) + :param timestamp: The time that the event occurred (seconds since the Unix epoch) + :param tags: The set of tags associated with the event + """ + + source: UUID + target: Union[UUID, IPv4Address, None] + timestamp: float + tags: FrozenSet[str]