Skip to content

Commit

Permalink
Change: make get_status of scan more robust
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nichtsfrei committed Aug 9, 2022
1 parent f59e891 commit c10b8c2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ospd/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c10b8c2

Please sign in to comment.