Agent: Fix type hints

This commit is contained in:
Kekoa Kaaikala 2022-08-30 13:44:32 +00:00
parent fedfe4e45d
commit 70a9251c5b
3 changed files with 9 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import itertools import itertools
import socket import socket
import struct import struct
from collections import namedtuple from dataclasses import dataclass
from ipaddress import IPv4Interface from ipaddress import IPv4Interface
from random import randint # noqa: DUO102 from random import randint # noqa: DUO102
from typing import List from typing import List
@ -18,9 +18,11 @@ SIOCGIFNETMASK = 0x891B # get network PA mask
RTF_UP = 0x0001 # Route usable RTF_UP = 0x0001 # Route usable
RTF_REJECT = 0x0200 RTF_REJECT = 0x0200
# TODO: We can probably replace both of these namedtuples with classes in Python's ipaddress
# library: https://docs.python.org/3/library/ipaddress.html @dataclass
NetworkAddress = namedtuple("NetworkAddress", ("ip", "domain")) class NetworkAddress:
ip: str
domain: str
def get_local_network_interfaces() -> List[IPv4Interface]: def get_local_network_interfaces() -> List[IPv4Interface]:

View File

@ -2,7 +2,7 @@ import itertools
import logging import logging
import socket import socket
from ipaddress import IPv4Interface from ipaddress import IPv4Interface
from typing import Any, Dict, List from typing import Dict, List
from common.network.network_range import InvalidNetworkRangeError, NetworkRange from common.network.network_range import InvalidNetworkRangeError, NetworkRange
from infection_monkey.network import NetworkAddress from infection_monkey.network import NetworkAddress
@ -40,7 +40,7 @@ def compile_scan_target_list(
def _remove_redundant_targets(targets: List[NetworkAddress]) -> List[NetworkAddress]: def _remove_redundant_targets(targets: List[NetworkAddress]) -> List[NetworkAddress]:
reverse_dns: Dict[Any, Any] = {} reverse_dns: Dict[str, str] = {}
for target in targets: for target in targets:
domain_name = target.domain domain_name = target.domain
ip = target.ip ip = target.ip

View File

@ -218,6 +218,7 @@ stop_time
parent_id parent_id
cc_server cc_server
hardware_id hardware_id
network_interfaces
connections connections
# TODO DELETE AFTER RESOURCE REFACTORING # TODO DELETE AFTER RESOURCE REFACTORING