Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vulnerabilities/data_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def debian_dump(extract_data):
Save data scraped from Debian' security tracker.
"""
for data in extract_data:
vulnerability = Vulnerability.objects.create(
vulnerability = Vulnerability.objects.update_or_create(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think update_or_create returns more than one thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is why this test is failing.

summary=data.get('description', ''),
)
VulnerabilityReference.objects.create(
vulnerability=vulnerability,
reference_id=data.get('vulnerability_id', ''),
reference_id=data.get('vulnerability_id', '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should check if the object was created at the last stage or not.

)
package = Package.objects.create(
name=data.get('package_name', ''),
Expand All @@ -61,7 +61,7 @@ def ubuntu_dump(html):
)
VulnerabilityReference.objects.create(
vulnerability=vulnerability,
reference_id=data.get('cve_id'),
reference_id=data.get('cve_id')
)
package = Package.objects.create(
name=data.get('package_name'),
Expand Down
13 changes: 7 additions & 6 deletions vulnerabilities/tests/test_data/debian.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"urgency": "medium",
"fixed_version": "1.50-1.1"}}},

"CVE-2009-2459":
{"scope": "un-remote",
"debianbug": 537254,
"description": "Multiple unspecified vulnerabilities in mimeTeX.",
"releases":
"CVE-2009-2459":
{"scope": "un-remote",
"debianbug": 537254,
"description": "Multiple unspecified vulnerabilities in mimeTeX.",
"releases":
{"stretch":
{"status": "resolved",
"repositories": {"stretch": "1.74-1"},
Expand Down Expand Up @@ -102,4 +102,5 @@
}
}
}
}
}

4 changes: 3 additions & 1 deletion vulnerabilities/tests/test_data_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ def test_debian_data_dump(self):
self.assertTrue(Vulnerability.objects.get(
summary='Multiple stack-based buffer overflows in mimetex.cgi in mimeTeX'))

self.assertTrue(Vulnerability.objects.get(
self.assertFalse(Vulnerability.objects.get(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not be changing the full meaning of the test.

summary='Multiple unspecified vulnerabilities in mimeTeX.'))
self.assertTrue(Vulnerability.objects.get(
scope='punni'))

self.assertTrue(VulnerabilityReference.objects.get(reference_id='CVE-2009-2458'))

Expand Down