#2059: apply suggestions from PR + adding another test that checks for dos affecting green agent

This commit is contained in:
Czar Echavez
2023-12-13 11:56:25 +00:00
parent f0be77c79b
commit 592e1a3610
4 changed files with 81 additions and 4 deletions

View File

@@ -49,7 +49,7 @@ class DoSBot(DatabaseClient, Application):
port_scan_p_of_success: float = 0.1
"""Probability of port scanning being sucessful."""
dos_intensity: float = 1
dos_intensity: float = 1.0
"""How much of the max sessions will be used by the DoS when attacking."""
def __init__(self, **kwargs):
@@ -92,7 +92,7 @@ class DoSBot(DatabaseClient, Application):
payload: Optional[str] = None,
repeat: bool = False,
port_scan_p_of_success: float = 0.1,
dos_intensity: float = 1,
dos_intensity: float = 1.0,
max_sessions: int = 1000,
):
"""

View File

@@ -143,6 +143,10 @@ class DatabaseService(Service):
status_code = 500 # Default internal server error
if self.operating_state == ServiceOperatingState.RUNNING:
status_code = 503 # service unavailable
if self.health_state_actual == SoftwareHealthState.OVERWHELMED:
self.sys_log.error(
f"{self.name}: Connect request for {connection_id=} declined. Service is at capacity."
)
if self.health_state_actual == SoftwareHealthState.GOOD:
if self.password == password:
status_code = 200 # ok

View File

@@ -58,7 +58,7 @@ class Service(IOSoftware):
if not super()._can_perform_action():
return False
if self.operating_state is not self.operating_state.RUNNING:
if self.operating_state is not ServiceOperatingState.RUNNING:
# service is not running
_LOGGER.error(f"Cannot perform action: {self.name} is {self.operating_state.name}")
return False