forked from p15670423/monkey
Common: Use a temporary hack to define non-defaults from a inherited class event
This commit is contained in:
parent
5f631a78f7
commit
486a7a9225
|
@ -1,8 +1,9 @@
|
||||||
|
import time
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, field
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
from typing import FrozenSet, Union
|
from typing import FrozenSet, Union
|
||||||
from uuid import UUID
|
from uuid import UUID, getnode
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
@ -21,7 +22,7 @@ class AbstractEvent(ABC):
|
||||||
:param tags: The set of tags associated with the event
|
:param tags: The set of tags associated with the event
|
||||||
"""
|
"""
|
||||||
|
|
||||||
source: UUID
|
|
||||||
target: Union[UUID, IPv4Address, None]
|
|
||||||
timestamp: float
|
|
||||||
tags: FrozenSet[str]
|
tags: FrozenSet[str]
|
||||||
|
target: Union[UUID, IPv4Address, None]
|
||||||
|
source: UUID = field(default_factory=getnode)
|
||||||
|
timestamp: float = field(default_factory=time.time)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, field
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from common.credentials import Credentials
|
from common.credentials import Credentials
|
||||||
|
@ -6,6 +6,10 @@ from common.credentials import Credentials
|
||||||
from . import AbstractEvent
|
from . import AbstractEvent
|
||||||
|
|
||||||
|
|
||||||
|
def hack_event():
|
||||||
|
raise TypeError("Missing a required argument")
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class CredentialsStolenEvent(AbstractEvent):
|
class CredentialsStolenEvent(AbstractEvent):
|
||||||
"""
|
"""
|
||||||
|
@ -15,4 +19,4 @@ class CredentialsStolenEvent(AbstractEvent):
|
||||||
:param stolen_credentials: The credentials that were stolen by an agent
|
:param stolen_credentials: The credentials that were stolen by an agent
|
||||||
"""
|
"""
|
||||||
|
|
||||||
stolen_credentials: Sequence[Credentials]
|
stolen_credentials: Sequence[Credentials] = field(default_factory=hack_event)
|
||||||
|
|
Loading…
Reference in New Issue