Agent: Refactor puppet and tools to use CONNECTION_TIMEOUT

This commit is contained in:
vakarisz 2022-03-28 17:07:10 +03:00 committed by VakarisZ
parent 1ec5be908d
commit 299a261387
3 changed files with 7 additions and 4 deletions

View File

@ -1,3 +1,4 @@
SHORT_REQUEST_TIMEOUT = 2.5 # Seconds. Use where we expect timeout.
SHORT_REQUEST_TIMEOUT = 2.5 # Seconds. Use where we expect timeout and for small data transactions.
MEDIUM_REQUEST_TIMEOUT = 5 # Seconds. Use where we don't expect timeout.
LONG_REQUEST_TIMEOUT = 15 # Seconds. Use where we don't expect timeout and operate heavy data.
CONNECTION_TIMEOUT = 3 # Seconds. Use for TCP, SSH and other connections that shouldn't take long.

View File

@ -4,9 +4,10 @@ import socket
import struct
import sys
from common.common_consts.timeouts import CONNECTION_TIMEOUT
from infection_monkey.network.info import get_routes
DEFAULT_TIMEOUT = 10
DEFAULT_TIMEOUT = CONNECTION_TIMEOUT
BANNER_READ = 1024
logger = logging.getLogger(__name__)

View File

@ -2,6 +2,7 @@ import logging
import threading
from typing import Dict, List, Sequence
from common.common_consts.timeouts import CONNECTION_TIMEOUT
from infection_monkey import network_scanning
from infection_monkey.i_puppet import (
Credentials,
@ -38,11 +39,11 @@ class Puppet(IPuppet):
def run_pba(self, name: str, options: Dict) -> PostBreachData:
return self._mock_puppet.run_pba(name, options)
def ping(self, host: str, timeout: float = 1) -> PingScanData:
def ping(self, host: str, timeout: float = CONNECTION_TIMEOUT) -> PingScanData:
return network_scanning.ping(host, timeout)
def scan_tcp_ports(
self, host: str, ports: List[int], timeout: float = 3
self, host: str, ports: List[int], timeout: float = CONNECTION_TIMEOUT
) -> Dict[int, PortScanData]:
return network_scanning.scan_tcp_ports(host, ports, timeout)