| @@ 86-145 (lines=60) @@ | ||
| 83 | for _, values in vthelper.get_vt_iterator(vt_selection=vt): |
|
| 84 | self.assertIs(values, None) |
|
| 85 | ||
| 86 | def test_get_single_vt_severity_cvssv3(self): |
|
| 87 | dummy = DummyDaemon() |
|
| 88 | dummy.nvti.get_nvt_metadata.return_value = { |
|
| 89 | 'category': '3', |
|
| 90 | 'creation_date': '1237458156', |
|
| 91 | 'cvss_base_vector': 'AV:N/AC:L/Au:N/C:N/I:N/A:N', |
|
| 92 | 'severity_vector': 'CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:L/A:L', |
|
| 93 | 'severity_date': '1237458156', |
|
| 94 | 'severity_origin': 'Greenbone', |
|
| 95 | 'excluded_keys': 'Settings/disable_cgi_scanning', |
|
| 96 | 'family': 'Product detection', |
|
| 97 | 'filename': 'mantis_detect.nasl', |
|
| 98 | 'last_modification': '1533906565', |
|
| 99 | 'name': 'Mantis Detection', |
|
| 100 | 'qod_type': 'remote_banner', |
|
| 101 | 'required_ports': 'Services/www, 80', |
|
| 102 | 'solution': 'some solution', |
|
| 103 | 'solution_type': 'WillNotFix', |
|
| 104 | 'solution_method': 'DebianAPTUpgrade', |
|
| 105 | 'impact': 'some impact', |
|
| 106 | 'insight': 'some insight', |
|
| 107 | 'summary': 'some summary', |
|
| 108 | 'affected': 'some affection', |
|
| 109 | 'timeout': '0', |
|
| 110 | 'vt_params': { |
|
| 111 | '1': { |
|
| 112 | 'id': '1', |
|
| 113 | 'default': '', |
|
| 114 | 'description': 'Description', |
|
| 115 | 'name': 'Data length :', |
|
| 116 | 'type': 'entry', |
|
| 117 | }, |
|
| 118 | '2': { |
|
| 119 | 'id': '2', |
|
| 120 | 'default': 'no', |
|
| 121 | 'description': 'Description', |
|
| 122 | 'name': ( # pylint: disable=line-too-long |
|
| 123 | 'Do not randomize the order in which ports are' |
|
| 124 | ' scanned' |
|
| 125 | ), |
|
| 126 | 'type': 'checkbox', |
|
| 127 | }, |
|
| 128 | }, |
|
| 129 | 'refs': { |
|
| 130 | 'bid': [''], |
|
| 131 | 'cve': [''], |
|
| 132 | 'xref': ['URL:http://www.mantisbt.org/'], |
|
| 133 | }, |
|
| 134 | } |
|
| 135 | ||
| 136 | vthelper = VtHelper(dummy.nvti) |
|
| 137 | ||
| 138 | res = vthelper.get_single_vt("1.3.6.1.4.1.25623.1.0.100061") |
|
| 139 | assert_called_once(dummy.nvti.get_nvt_metadata) |
|
| 140 | ||
| 141 | severities = res.get('severities') |
|
| 142 | self.assertEqual( |
|
| 143 | "CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:L/A:L", |
|
| 144 | severities.get('severity_base_vector'), |
|
| 145 | ) |
|
| 146 | self.assertEqual("cvss_base_v3", severities.get('severity_type')) |
|
| 147 | self.assertEqual("Greenbone", severities.get('severity_origin')) |
|
| 148 | self.assertEqual("1237458156", severities.get('severity_date')) |
|
| @@ 150-206 (lines=57) @@ | ||
| 147 | self.assertEqual("Greenbone", severities.get('severity_origin')) |
|
| 148 | self.assertEqual("1237458156", severities.get('severity_date')) |
|
| 149 | ||
| 150 | def test_get_single_vt_severity_cvssv2(self): |
|
| 151 | dummy = DummyDaemon() |
|
| 152 | dummy.nvti.get_nvt_metadata.return_value = { |
|
| 153 | 'category': '3', |
|
| 154 | 'creation_date': '1237458156', |
|
| 155 | 'cvss_base_vector': 'AV:N/AC:L/Au:N/C:N/I:N/A:N', |
|
| 156 | 'excluded_keys': 'Settings/disable_cgi_scanning', |
|
| 157 | 'family': 'Product detection', |
|
| 158 | 'filename': 'mantis_detect.nasl', |
|
| 159 | 'last_modification': '1533906565', |
|
| 160 | 'name': 'Mantis Detection', |
|
| 161 | 'qod_type': 'remote_banner', |
|
| 162 | 'required_ports': 'Services/www, 80', |
|
| 163 | 'solution': 'some solution', |
|
| 164 | 'solution_type': 'WillNotFix', |
|
| 165 | 'solution_method': 'DebianAPTUpgrade', |
|
| 166 | 'impact': 'some impact', |
|
| 167 | 'insight': 'some insight', |
|
| 168 | 'summary': 'some summary', |
|
| 169 | 'affected': 'some affection', |
|
| 170 | 'timeout': '0', |
|
| 171 | 'vt_params': { |
|
| 172 | '1': { |
|
| 173 | 'id': '1', |
|
| 174 | 'default': '', |
|
| 175 | 'description': 'Description', |
|
| 176 | 'name': 'Data length :', |
|
| 177 | 'type': 'entry', |
|
| 178 | }, |
|
| 179 | '2': { |
|
| 180 | 'id': '2', |
|
| 181 | 'default': 'no', |
|
| 182 | 'description': 'Description', |
|
| 183 | 'name': ( # pylint: disable=line-too-long |
|
| 184 | 'Do not randomize the order in which ports are' |
|
| 185 | ' scanned' |
|
| 186 | ), |
|
| 187 | 'type': 'checkbox', |
|
| 188 | }, |
|
| 189 | }, |
|
| 190 | 'refs': { |
|
| 191 | 'bid': [''], |
|
| 192 | 'cve': [''], |
|
| 193 | 'xref': ['URL:http://www.mantisbt.org/'], |
|
| 194 | }, |
|
| 195 | } |
|
| 196 | ||
| 197 | vthelper = VtHelper(dummy.nvti) |
|
| 198 | ||
| 199 | res = vthelper.get_single_vt("1.3.6.1.4.1.25623.1.0.100061") |
|
| 200 | assert_called_once(dummy.nvti.get_nvt_metadata) |
|
| 201 | ||
| 202 | severities = res.get('severities') |
|
| 203 | self.assertEqual( |
|
| 204 | "AV:N/AC:L/Au:N/C:N/I:N/A:N", |
|
| 205 | severities.get('severity_base_vector'), |
|
| 206 | ) |
|
| 207 | self.assertEqual("cvss_base_v2", severities.get('severity_type')) |
|
| 208 | self.assertEqual(None, severities.get('severity_origin')) |
|
| 209 | self.assertEqual("1237458156", severities.get('severity_date')) |
|