Skip to content

Commit 3b6a157

Browse files
authored
Merge pull request #215 from jjnicola/vt-details
Add details parameter to get_vt_iterator()
2 parents 22fae66 + 5ceee6f commit 3b6a157

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1717
[#197](https://github.com/greenbone/ospd-openvas/pull/197)
1818
- Add support for test_alive_hosts_only feature of openvas. [#204](https://github.com/greenbone/ospd-openvas/pull/204)
1919
- Use lock file during feed update to avoid corrupted cache. [#207](https://github.com/greenbone/ospd-openvas/pull/207)
20+
- Add details parameter to get_vt_iterator(). [#215](https://github.com/greenbone/ospd-openvas/pull/215)
2021

2122
### Changed
2223
- Less strict checks for the nvti cache version

Pipfile.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ospd_openvas/daemon.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def scheduler(self):
467467
"""This method is called periodically to run tasks."""
468468
self.check_feed()
469469

470-
def get_single_vt(self, vt_id, oids):
470+
def get_single_vt(self, vt_id, oids=None):
471471
_vt_params = self.nvti.get_nvt_params(vt_id)
472472
_vt_refs = self.nvti.get_nvt_refs(vt_id)
473473
_custom = self.nvti.get_nvt_metadata(vt_id)
@@ -476,12 +476,15 @@ def get_single_vt(self, vt_id, oids):
476476
_vt_creation_time = _custom.pop('creation_date')
477477
_vt_modification_time = _custom.pop('last_modification')
478478

479-
_vt_dependencies = list()
480-
if 'dependencies' in _custom:
481-
_deps = _custom.pop('dependencies')
482-
_deps_list = _deps.split(', ')
483-
for dep in _deps_list:
484-
_vt_dependencies.append(oids.get('filename:' + dep))
479+
if oids:
480+
_vt_dependencies = list()
481+
if 'dependencies' in _custom:
482+
_deps = _custom.pop('dependencies')
483+
_deps_list = _deps.split(', ')
484+
for dep in _deps_list:
485+
_vt_dependencies.append(oids.get('filename:' + dep))
486+
else:
487+
_vt_dependencies = None
485488

486489
_summary = None
487490
_impact = None
@@ -571,15 +574,15 @@ def get_single_vt(self, vt_id, oids):
571574
return vt
572575

573576
def get_vt_iterator(
574-
self, vt_selection: List[str] = None
577+
self, vt_selection: List[str] = None, details: bool = True
575578
) -> Iterator[Tuple[str, Dict]]:
576579
""" Yield the vts from the Redis NVTicache. """
577-
oids = dict(self.nvti.get_oids())
578-
if vt_selection:
579-
vt_id_list = vt_selection
580-
else:
581-
vt_id_list = oids.values()
582-
for vt_id in vt_id_list:
580+
581+
oids = None
582+
if details:
583+
oids = dict(self.nvti.get_oids())
584+
585+
for vt_id in vt_selection:
583586
vt = self.get_single_vt(vt_id, oids)
584587
yield (vt_id, vt)
585588

0 commit comments

Comments
 (0)