Skip to content

Commit fd1d529

Browse files
committed
Fix: qod-type is in advisory not meta-data
Instead of asking meta-data and always fallback to package use the defined value within advisory.
1 parent c77098b commit fd1d529

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

ospd_openvas/notus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def __to_ospd(
169169
'Checks if a vulnerable package version is present on the target'
170170
' host.'
171171
)
172-
result['qod_type'] = meta_data.get('qod_type', 'package')
172+
result['qod_type'] = advisory.get('qod_type', 'package')
173173
severity = advisory.get('severity', {})
174174
cvss = severity.get("cvss_v3", None)
175175
if not cvss:

tests/test_notus.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,36 @@ def test_notus_reload(self, mock_openvasdb):
9898
do_not_load_into_redis.reload_cache()
9999
self.assertEqual(mock_openvasdb.set_single_item.call_count, 0)
100100

101+
def test_notus_qod_type(self):
102+
path_mock = mock.MagicMock()
103+
adv_path = mock.MagicMock()
104+
adv_path.name = "hi"
105+
adv_path.stem = "family"
106+
path_mock.glob.return_value = [adv_path]
107+
adv_path.read_bytes.return_value = b'''
108+
{
109+
"family": "family",
110+
"advisories": [
111+
{
112+
"oid": "12",
113+
"qod_type": "package_unreliable",
114+
"severity": {
115+
"origin": "NVD",
116+
"date": 1505784960,
117+
"cvss_v2": "AV:N/AC:M/Au:N/C:C/I:C/A:C",
118+
"cvss_v3": null
119+
}
120+
}
121+
]
122+
}'''
123+
cache_fake = CacheFake()
124+
notus = Notus(path_mock, cache_fake)
125+
notus._verifier = lambda _: True # pylint: disable=protected-access
126+
notus.reload_cache()
127+
nm = notus.get_nvt_metadata("12")
128+
assert nm
129+
self.assertEqual("package_unreliable", nm.get("qod_type", ""))
130+
101131
def test_notus_cvss_v2_v3_none(self):
102132
path_mock = mock.MagicMock()
103133
adv_path = mock.MagicMock()
@@ -107,7 +137,6 @@ def test_notus_cvss_v2_v3_none(self):
107137
adv_path.read_bytes.return_value = b'''
108138
{
109139
"family": "family",
110-
"qod_type": "remote_app",
111140
"advisories": [
112141
{
113142
"oid": "12",

0 commit comments

Comments
 (0)