Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add details parameter to get_vt_iterator() #215

Merged
merged 4 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[#197](https://github.com/greenbone/ospd-openvas/pull/197)
- Add support for test_alive_hosts_only feature of openvas. [#204](https://github.com/greenbone/ospd-openvas/pull/204)
- Use lock file during feed update to avoid corrupted cache. [#207](https://github.com/greenbone/ospd-openvas/pull/207)
- Add details parameter to get_vt_iterator(). [#215](https://github.com/greenbone/ospd-openvas/pull/215)

### Changed
- Less strict checks for the nvti cache version
Expand Down
8 changes: 4 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def scheduler(self):
"""This method is called periodically to run tasks."""
self.check_feed()

def get_single_vt(self, vt_id, oids):
def get_single_vt(self, vt_id, oids=None):
_vt_params = self.nvti.get_nvt_params(vt_id)
_vt_refs = self.nvti.get_nvt_refs(vt_id)
_custom = self.nvti.get_nvt_metadata(vt_id)
Expand All @@ -476,12 +476,15 @@ def get_single_vt(self, vt_id, oids):
_vt_creation_time = _custom.pop('creation_date')
_vt_modification_time = _custom.pop('last_modification')

_vt_dependencies = list()
if 'dependencies' in _custom:
_deps = _custom.pop('dependencies')
_deps_list = _deps.split(', ')
for dep in _deps_list:
_vt_dependencies.append(oids.get('filename:' + dep))
if oids:
_vt_dependencies = list()
if 'dependencies' in _custom:
_deps = _custom.pop('dependencies')
_deps_list = _deps.split(', ')
for dep in _deps_list:
_vt_dependencies.append(oids.get('filename:' + dep))
else:
_vt_dependencies = None

_summary = None
_impact = None
Expand Down Expand Up @@ -571,15 +574,15 @@ def get_single_vt(self, vt_id, oids):
return vt

def get_vt_iterator(
self, vt_selection: List[str] = None
self, vt_selection: List[str] = None, details: bool = True
) -> Iterator[Tuple[str, Dict]]:
""" Yield the vts from the Redis NVTicache. """
oids = dict(self.nvti.get_oids())
if vt_selection:
vt_id_list = vt_selection
else:
vt_id_list = oids.values()
for vt_id in vt_id_list:

oids = None
if details:
oids = dict(self.nvti.get_oids())

for vt_id in vt_selection:
vt = self.get_single_vt(vt_id, oids)
yield (vt_id, vt)

Expand Down