Skip to content

Commit c10b8c2

Browse files
committed
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.
1 parent f59e891 commit c10b8c2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ospd/scan.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,9 @@ def set_status(self, scan_id: str, status: ScanStatus) -> None:
357357

358358
def get_status(self, scan_id: str) -> ScanStatus:
359359
"""Get scan_id scans's status."""
360-
status = None
361-
try:
362-
status = self.scans_table[scan_id].get('status')
363-
except KeyError:
364-
logger.error("Scan ID %s not found", scan_id)
365-
360+
status = self.scans_table.get(scan_id, {}).get('status', None)
361+
if not status:
362+
logger.warning("Scan ID %s not found", scan_id)
366363
return status
367364

368365
def get_options(self, scan_id: str) -> Dict:

0 commit comments

Comments
 (0)