Skip to content

Commit 65a7644

Browse files
committed
Add test for importer crash #1541
Reference: #1541 Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 53b84d1 commit 65a7644

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

vulnerabilities/tests/test_import_runner.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,66 @@ def test_process_advisories_idempotency_with_different_importer_names():
107107
assert advisory_datas == ADVISORY_DATAS
108108

109109

110+
@pytest.mark.django_db(transaction=True)
111+
def test_process_advisories_can_import_advisories_with_severities_and_no_date():
112+
# was failing with " django.core.exceptions.ValidationError: ['“None” value has an invalid format.
113+
# It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']"
114+
115+
advisory = {
116+
"aliases": ["CVE-2024-31079"],
117+
"summary": "Stack overflow and use-after-free in HTTP/3",
118+
"affected_packages": [
119+
{
120+
"package": {
121+
"type": "nginx",
122+
"namespace": "",
123+
"name": "nginx",
124+
"version": "",
125+
"qualifiers": "",
126+
"subpath": "",
127+
},
128+
"affected_version_range": "vers:nginx/>=1.25.0|<=1.25.5|1.26.0",
129+
"fixed_version": "1.27.0",
130+
},
131+
{
132+
"package": {
133+
"type": "nginx",
134+
"namespace": "",
135+
"name": "nginx",
136+
"version": "",
137+
"qualifiers": "",
138+
"subpath": "",
139+
},
140+
"affected_version_range": "vers:nginx/>=1.25.0|<=1.25.5|1.26.0",
141+
"fixed_version": "1.26.1",
142+
},
143+
],
144+
"references": [
145+
{
146+
"reference_id": "",
147+
"reference_type": "",
148+
"url": "https://mailman.nginx.org/pipermail/nginx-announce/2024/GMY32CSHFH6VFTN76HJNX7WNEX4RLHF6.html",
149+
"severities": [
150+
{"system": "generic_textual", "value": "medium", "scoring_elements": ""}
151+
],
152+
},
153+
{
154+
"reference_id": "CVE-2024-31079",
155+
"reference_type": "",
156+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-31079",
157+
"severities": [],
158+
},
159+
],
160+
"date_published": None,
161+
"weaknesses": [],
162+
"url": "https://nginx.org/en/security_advisories.html",
163+
}
164+
ad = AdvisoryData.from_dict(advisory)
165+
ImportRunner(DummyImporter).process_advisories([ad], "test_importer_date")
166+
advisory_aliases = list(models.Advisory.objects.all().values("aliases"))
167+
assert advisory_aliases == [{"aliases": ["CVE-2024-31079"]}]
168+
169+
110170
def test_advisory_summary_clean_up():
111171
adv = AdvisoryData(
112172
summary="The X509Extension in pyOpenSSL before 0.13.1 does not properly handle a '\x00' character in a domain name in the Subject Alternative Name field of an X.509 certificate, which allows man-in-the-middle attackers to spoof arbitrary SSL servers via a crafted certificate issued by a legitimate Certification Authority."

0 commit comments

Comments
 (0)