Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

logger = logging.getLogger(__name__)

TIMEOUT = 10
# Set the default timeout for requests (connect, read)
TIMEOUT = (1.0, 10)

CONNECTION_ERROR = "CONNECTION_ERROR"
CONNECTION_TIMEOUT_ERROR = "CONNECTION_TIMEOUT_ERROR"
READ_TIMEOUT_ERROR = "READ_TIMEOUT_ERROR"
TIMEOUT_ERROR = "TIMEOUT_ERROR"
UNKNOWN_ERROR = "UNKNOWN_ERROR"

Expand Down Expand Up @@ -128,6 +131,20 @@ def request_connection(uri: Optional[str] = None,
connection = HTTPSConnectionRequest(uri=uri, http_response=response)
return {"connection": connection, "response": response}

except requests.exceptions.ConnectTimeout as e:
logger.error(f"Connection timeout error {context}: {str(e)}")
if scheme.lower() == "http":
connection = HTTPConnectionRequest(uri=uri, error=CONNECTION_TIMEOUT_ERROR)
elif scheme.lower() == "https":
connection = HTTPSConnectionRequest(uri=uri, error=CONNECTION_TIMEOUT_ERROR)
return {"connection": connection, "response": response}
except requests.exceptions.ReadTimeout as e:
logger.error(f"Read timeout error {context}: {str(e)}")
if scheme.lower() == "http":
connection = HTTPConnectionRequest(uri=uri, error=READ_TIMEOUT_ERROR)
elif scheme.lower() == "https":
connection = HTTPSConnectionRequest(uri=uri, error=READ_TIMEOUT_ERROR)
return {"connection": connection, "response": response}
except requests.exceptions.Timeout as e:
logger.error(f"Timeout error {context}: {str(e)}")
if scheme.lower() == "http":
Expand Down
15 changes: 10 additions & 5 deletions scanners/web-scanner/scan/tls_scanner/tls_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

logger = logging.getLogger()

TIMEOUT = int(os.getenv("SCAN_TIMEOUT", "80"))

CONNECT_TIMEOUT = 1

@dataclass
class AcceptedCipherSuites:
Expand Down Expand Up @@ -184,9 +183,15 @@ def __init__(self, domain: str, ip_address: str = None):

try:
scan_request = ServerScanRequest(
server_location=ServerNetworkLocation(hostname=domain,
ip_address=ip_address),
scan_commands=designated_scans
server_location=ServerNetworkLocation(
hostname=domain,
ip_address=ip_address
),
scan_commands=designated_scans,
network_configuration=ServerNetworkConfiguration(
tls_server_name_indication=domain,
network_timeout=CONNECT_TIMEOUT
)
)
except ServerHostnameCouldNotBeResolved as e:
logger.info(f"Server hostname could not be resolved for domain '{domain}': {str(e)}")
Expand Down