Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Don't access scan info directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed May 19, 2020
1 parent 54fe4da commit 4eb3089
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add [pontos](https://github.com/greenbone/pontos) as dev dependency for
managing the version information in ospd [#254](https://github.com/greenbone/ospd/pull/254)
- Add more info about scan progress with progress attribute in get_scans cmd. [#266](https://github.com/greenbone/ospd/pull/266)
- Add method to get complete target info [#275](https://github.com/greenbone/ospd/pull/275)

### Changes
- Modify __init__() method and use new syntax for super(). [#186](https://github.com/greenbone/ospd/pull/186)
Expand Down
4 changes: 1 addition & 3 deletions ospd/ospd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,9 +1188,7 @@ def run(self) -> None:
def start_pending_scans(self):
for scan_id in self.scan_collection.ids_iterator():
if self.get_scan_status(scan_id) == ScanStatus.PENDING:
scan_target = self.scan_collection.scans_table[scan_id].get(
'target'
)
scan_target = self.scan_collection.get_target(scan_id)
scan_func = self.start_scan
scan_process = create_process(
func=scan_func, args=(scan_id, scan_target)
Expand Down
8 changes: 7 additions & 1 deletion ospd/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from collections import OrderedDict
from enum import Enum
from typing import List, Any, Dict, Iterator, Optional, Iterable
from typing import List, Any, Dict, Iterator, Optional, Iterable, Union

from ospd.network import target_str_to_list

Expand Down Expand Up @@ -378,6 +378,12 @@ def get_target_options(self, scan_id: str):
"""
return self.scans_table[scan_id]['target'].get('options')

def get_target(
self, scan_id: str
) -> Dict[str, Union[str, Dict[str, Union[str, Dict]]]]:
""" Get the complete target info"""
return self.scans_table[scan_id].get('target')

def get_vts(self, scan_id: str) -> Dict:
""" Get a scan's vts. """
scan_info = self.scans_table[scan_id]
Expand Down

0 comments on commit 4eb3089

Please sign in to comment.