diff --git a/monkey/common/events/abstract_event.py b/monkey/common/events/abstract_event.py index 33bb25506..03629c442 100644 --- a/monkey/common/events/abstract_event.py +++ b/monkey/common/events/abstract_event.py @@ -1,8 +1,9 @@ +import time from abc import ABC -from dataclasses import dataclass +from dataclasses import dataclass, field from ipaddress import IPv4Address from typing import FrozenSet, Union -from uuid import UUID +from uuid import UUID, getnode @dataclass(frozen=True) @@ -21,7 +22,7 @@ class AbstractEvent(ABC): :param tags: The set of tags associated with the event """ - source: UUID - target: Union[UUID, IPv4Address, None] - timestamp: float tags: FrozenSet[str] + target: Union[UUID, IPv4Address, None] + source: UUID = field(default_factory=getnode) + timestamp: float = field(default_factory=time.time) diff --git a/monkey/common/events/credentials_stolen_events.py b/monkey/common/events/credentials_stolen_events.py index f1db1c142..7ad06cb10 100644 --- a/monkey/common/events/credentials_stolen_events.py +++ b/monkey/common/events/credentials_stolen_events.py @@ -1,4 +1,4 @@ -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import Sequence from common.credentials import Credentials @@ -6,6 +6,10 @@ from common.credentials import Credentials from . import AbstractEvent +def hack_event(): + raise TypeError("Missing a required argument") + + @dataclass(frozen=True) class CredentialsStolenEvent(AbstractEvent): """ @@ -15,4 +19,4 @@ class CredentialsStolenEvent(AbstractEvent): :param stolen_credentials: The credentials that were stolen by an agent """ - stolen_credentials: Sequence[Credentials] + stolen_credentials: Sequence[Credentials] = field(default_factory=hack_event)