From 76e89fd517381df453037d29b52bc5f5a7fc77fb Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 6 Nov 2024 09:48:34 +1000 Subject: [PATCH] Add timeout config option for nessus scan --- config/config-template-nessus.yaml | 1 + scanners/nessus/nessus_none.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config/config-template-nessus.yaml b/config/config-template-nessus.yaml index 1b4ed1c7..39d5997f 100644 --- a/config/config-template-nessus.yaml +++ b/config/config-template-nessus.yaml @@ -37,5 +37,6 @@ scanners: name: test-scan # name of new scan to create folder: test-folder # name of folder in to contain scan policy: "py-test" # policy used for scan + # timeout: 600 # timeout in seconds to complete scan targets: - 127.0.0.1 diff --git a/scanners/nessus/nessus_none.py b/scanners/nessus/nessus_none.py index 43f5cc4d..6405cf0b 100644 --- a/scanners/nessus/nessus_none.py +++ b/scanners/nessus/nessus_none.py @@ -27,6 +27,7 @@ class NessusScanConfig: policy: str targets: List[str] folder: str = field(default="rapidast") + timeout: int = field(default=600) # seconds def targets_as_str(self) -> str: return " ".join(self.targets) @@ -61,7 +62,6 @@ def __init__(self, config: RapidastConfigModel, ident: str = "nessus"): # XXX self.config is already a dict with raw config values self.cfg = dacite.from_dict(data_class=NessusConfig, data=nessus_config_section) self._sleep_interval: int = 10 - self._timeout: int = 300 self._connect() def _connect(self): @@ -122,8 +122,8 @@ def run(self): # Wait for the scan to complete start = time.time() while self.nessus_client.get_scan_status(self.scan_id)["status"] not in END_STATUSES: - if time.time() - start > self._timeout: - logging.error(f"Timeout {self._timeout}s reached waiting for scan to complete") + if time.time() - start > self.cfg.scan.timeout: + logging.error(f"Timeout {self.cfg.scan.timeout}s reached waiting for scan to complete") self.state = State.ERROR break