diff --git a/monkey/common/types.py b/monkey/common/types.py index a76fd560f..51353d293 100644 --- a/monkey/common/types.py +++ b/monkey/common/types.py @@ -1,8 +1,19 @@ +from ipaddress import IPv4Address from uuid import UUID -from pydantic import PositiveInt +from pydantic import PositiveInt, conint from typing_extensions import TypeAlias +from common.base_models import InfectionMonkeyBaseModel + AgentID: TypeAlias = UUID HardwareID: TypeAlias = PositiveInt MachineID: TypeAlias = PositiveInt + + +class SocketAddress(InfectionMonkeyBaseModel): + ip: IPv4Address + port: conint(ge=1, le=65535) # type: ignore[valid-type] + + def __str__(self): + return f"{self.ip}:{self.port}" diff --git a/vulture_allowlist.py b/vulture_allowlist.py index fdb00914d..ef9613fca 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -8,6 +8,7 @@ from common.agent_configuration.agent_sub_configurations import ( ScanTargetConfiguration, ) from common.credentials import Credentials, LMHash, NTHash +from common.types import SocketAddress from infection_monkey.exploit.log4shell_utils.ldap_server import LDAPServerFactory from monkey_island.cc.event_queue import IslandEventTopic, PyPubSubIslandEventQueue from monkey_island.cc.models import Report @@ -324,3 +325,6 @@ SCANNED EXPLOITED CC CC_TUNNEL + +# TODO: Remove after #2323 +SocketAddress