diff --git a/CHANGELOG.md b/CHANGELOG.md index 388d1839..24e9bee8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Deprecated ### Removed ### Fixed +- Fix resume scan. [#464](https://github.com/greenbone/ospd/pull/464) + [Unreleased]: https://github.com/greenbone/ospd/compare/v21.4.3...HEAD diff --git a/ospd/scan.py b/ospd/scan.py index dada3f92..8e479729 100644 --- a/ospd/scan.py +++ b/ospd/scan.py @@ -502,7 +502,17 @@ def get_end_time(self, scan_id: str) -> str: def get_host_list(self, scan_id: str) -> Dict: """ Get a scan's host list. """ - return self.scans_table[scan_id]['target'].get('hosts') + target = None + try: + target = self.scans_table[scan_id]['target'].get('hosts') + except KeyError: + LOGGER.warning( + '%s: Scan ID is in the scan table, but it was ' + 'not initialized.', + scan_id, + ) + + return target def get_host_count(self, scan_id: str) -> int: """ Get total host count in the target. """