-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for reference_type (#1518)
* Revert "Revert "Add support for reference_type (#1502)" (#1517)" This reverts commit 6727786. Signed-off-by: ziadhany <[email protected]> * Fix cargo test Signed-off-by: ziadhany <[email protected]> * Fix test by adding reference_type to ordering list Signed-off-by: ziadhany <[email protected]> * Regen apache_kafka test fixture Signed-off-by: Keshav Priyadarshi <[email protected]> --------- Signed-off-by: ziadhany <[email protected]> Signed-off-by: Keshav Priyadarshi <[email protected]> Co-authored-by: ziadhany <[email protected]> Co-authored-by: Keshav Priyadarshi <[email protected]>
- Loading branch information
1 parent
574d06e
commit 84a35db
Showing
98 changed files
with
5,707 additions
and
1,458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
vulnerabilities/migrations/0058_alter_vulnerabilityreference_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 4.1.13 on 2024-08-01 22:03 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("vulnerabilities", "0057_kev"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="vulnerabilityreference", | ||
options={"ordering": ["reference_id", "url", "reference_type"]}, | ||
), | ||
migrations.AddField( | ||
model_name="vulnerabilityreference", | ||
name="reference_type", | ||
field=models.CharField( | ||
blank=True, | ||
choices=[ | ||
("advisory", "Advisory"), | ||
("exploit", "Exploit"), | ||
("mailing_list", "Mailing List"), | ||
("bug", "Bug"), | ||
("other", "Other"), | ||
], | ||
max_length=20, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
|
||
from vulnerabilities.api import MinimalPackageSerializer | ||
from vulnerabilities.api import PackageSerializer | ||
from vulnerabilities.api import VulnerabilityReferenceSerializer | ||
from vulnerabilities.models import Alias | ||
from vulnerabilities.models import ApiUser | ||
from vulnerabilities.models import Package | ||
|
@@ -161,6 +162,9 @@ def setUp(self): | |
namespace="ubuntu", | ||
qualifiers={"distro": "jessie"}, | ||
) | ||
self.ref = VulnerabilityReference.objects.create( | ||
reference_type="advisory", reference_id="CVE-xxx-xxx", url="https://example.com" | ||
) | ||
self.user = ApiUser.objects.create_api_user(username="[email protected]") | ||
self.auth = f"Token {self.user.auth_token.key}" | ||
self.client = APIClient(enforce_csrf_checks=True) | ||
|
@@ -181,6 +185,16 @@ def test_package_serializer(self): | |
purls = {r["purl"] for r in response} | ||
self.assertIn("pkg:deb/ubuntu/[email protected]?distro=jessie", purls) | ||
|
||
def test_vulnerability_reference_serializer(self): | ||
response = VulnerabilityReferenceSerializer(instance=self.ref).data | ||
assert response == { | ||
"reference_url": "https://example.com", | ||
"reference_id": "CVE-xxx-xxx", | ||
"reference_type": "advisory", | ||
"scores": [], | ||
"url": "https://example.com", | ||
} | ||
|
||
|
||
class APITestCaseVulnerability(TransactionTestCase): | ||
def setUp(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.