From c10b8c266034d569267618097951dab1a31317d8 Mon Sep 17 00:00:00 2001 From: Philipp Eder Date: Thu, 14 Jul 2022 12:41:13 +0200 Subject: [PATCH] Change: make get_status of scan more robust In some cases it can happen that a scan_id is not findable since it will not block the execution of ospd-openvas it should not printed as an error with a stacktrace but as a warning. --- ospd/scan.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ospd/scan.py b/ospd/scan.py index 85f746d3..89163189 100644 --- a/ospd/scan.py +++ b/ospd/scan.py @@ -357,12 +357,9 @@ def set_status(self, scan_id: str, status: ScanStatus) -> None: def get_status(self, scan_id: str) -> ScanStatus: """Get scan_id scans's status.""" - status = None - try: - status = self.scans_table[scan_id].get('status') - except KeyError: - logger.error("Scan ID %s not found", scan_id) - + status = self.scans_table.get(scan_id, {}).get('status', None) + if not status: + logger.warning("Scan ID %s not found", scan_id) return status def get_options(self, scan_id: str) -> Dict: