|
24 | 24 | from vulnerabilities.importers.osv import get_published_date |
25 | 25 | from vulnerabilities.importers.osv import get_references |
26 | 26 | from vulnerabilities.importers.osv import get_severities |
| 27 | +from vulnerabilities.importers.osv import parse_advisory_data |
27 | 28 | from vulnerabilities.severity_systems import SCORING_SYSTEMS |
28 | 29 |
|
29 | 30 |
|
@@ -397,3 +398,44 @@ def test_get_fixed_versions4(self): |
397 | 398 | ) |
398 | 399 |
|
399 | 400 | assert results == [SemverVersion("6.5.4")] |
| 401 | + |
| 402 | + def test_parse_advisory_data_withdrawn_returns_none(self): |
| 403 | + raw_data = { |
| 404 | + "id": "GHSA-w596-4wvx-j9j6", |
| 405 | + "published": "2022-10-16T12:00:23Z", |
| 406 | + "withdrawn": "2025-08-01T20:34:11Z", |
| 407 | + "aliases": ["CVE-2022-42969"], |
| 408 | + "summary": "Withdrawn Advisory: ReDoS in py library", |
| 409 | + "affected": [ |
| 410 | + { |
| 411 | + "package": {"ecosystem": "PyPI", "name": "py"}, |
| 412 | + "ranges": [ |
| 413 | + { |
| 414 | + "type": "ECOSYSTEM", |
| 415 | + "events": [{"introduced": "0"}, {"last_affected": "1.11.0"}], |
| 416 | + } |
| 417 | + ], |
| 418 | + } |
| 419 | + ], |
| 420 | + } |
| 421 | + result = parse_advisory_data( |
| 422 | + raw_data, |
| 423 | + supported_ecosystems=["pypi"], |
| 424 | + advisory_url="https://github.com/github/advisory-database/blob/main/advisories/GHSA-w596-4wvx-j9j6.json", |
| 425 | + ) |
| 426 | + assert result is None |
| 427 | + |
| 428 | + def test_parse_advisory_data_not_withdrawn_returns_advisory(self): |
| 429 | + raw_data = { |
| 430 | + "id": "GHSA-j3f7-7rmc-6wqj", |
| 431 | + "published": "2022-01-10T14:12:00Z", |
| 432 | + "aliases": ["CVE-2022-0001"], |
| 433 | + "summary": "Some valid advisory", |
| 434 | + "affected": [], |
| 435 | + } |
| 436 | + result = parse_advisory_data( |
| 437 | + raw_data, |
| 438 | + supported_ecosystems=["pypi"], |
| 439 | + advisory_url="https://github.com/github/advisory-database/blob/main/advisories/GHSA-j3f7-7rmc-6wqj.json", |
| 440 | + ) |
| 441 | + assert result is not None |
0 commit comments