|
29 | 29 | from vulnerabilities.data_source import DataSource |
30 | 30 | from vulnerabilities.data_source import PackageURL |
31 | 31 | from vulnerabilities.import_runner import ImportRunner |
| 32 | +from vulnerabilities.import_runner import _insert_vulnerabilities_and_references |
32 | 33 |
|
33 | 34 |
|
34 | 35 | class MockDataSource(DataSource): |
@@ -197,12 +198,12 @@ def test_ImportRunner_new_package_version_affected_by_existing_vulnerability(db) |
197 | 198 | assert impacted_package.vulnerability.cve_id == 'MOCK-CVE-2020-1337' |
198 | 199 |
|
199 | 200 |
|
200 | | -def test_ImportRunner_assumed_fixed_package_is_updated_as_impacted(db): |
201 | | - """ |
202 | | - A version of a package existing in the database that was assumed to be fixed was found to still |
203 | | - be affected by a vulnerability that also already existed in the database (i.e. the previously |
204 | | - stored data was corrected). |
205 | | - """ |
| 201 | +# def test_ImportRunner_assumed_fixed_package_is_updated_as_impacted(db): |
| 202 | +# """ |
| 203 | +# A version of a package existing in the database that was assumed to be fixed was found to |
| 204 | +# still be affected by a vulnerability that also already existed in the database (i.e. the |
| 205 | +# previously stored data was corrected). |
| 206 | +# """ |
206 | 207 | # FIXME This case is not supported due to cascading deletes. When the ResolvedPackage is |
207 | 208 | # FIXME deleted, the referenced Package and Vulnerability are also deleted. |
208 | 209 | # |
@@ -317,3 +318,16 @@ def test_ImportRunner_updated_vulnerability(db): |
317 | 318 | vuln_refs = models.VulnerabilityReference.objects.filter(vulnerability=vuln) |
318 | 319 | assert vuln_refs.count() == 1 |
319 | 320 | assert vuln_refs[0].url == 'https://example.com/with/more/info/MOCK-CVE-2020-1337' |
| 321 | + |
| 322 | + |
| 323 | +def test_insert_vulnerabilities_and_references_stores_summary(db): |
| 324 | + advisory = Advisory( |
| 325 | + summary='vulnerability description here', |
| 326 | + cve_id='MOCK-CVE-2020-1337', |
| 327 | + impacted_package_urls=[PackageURL(name='mock-webserver', type='pypi', version='1.2.33a')], |
| 328 | + ) |
| 329 | + |
| 330 | + _insert_vulnerabilities_and_references({advisory}) |
| 331 | + |
| 332 | + vuln = models.Vulnerability.objects.get(cve_id=advisory.cve_id) |
| 333 | + assert vuln.summary == advisory.summary |
0 commit comments