Common: Add SocketAddress type

This commit is contained in:
Ilija Lazoroski 2022-09-23 14:56:02 +02:00 committed by Mike Salvatore
parent 1716a2dddd
commit 49e434d754
2 changed files with 16 additions and 1 deletions

View File

@ -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}"

View File

@ -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