diff --git a/vulnerabilities/admin.py b/vulnerabilities/admin.py index d2271d1fc..0a5197f94 100644 --- a/vulnerabilities/admin.py +++ b/vulnerabilities/admin.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2017 nexB Inc. and others. All rights reserved. +# Copyright (c) nexB Inc. and others. All rights reserved. # http://nexb.com and https://github.com/nexB/vulnerablecode/ # The VulnerableCode software is licensed under the Apache License version 2.0. # Data generated with VulnerableCode require an acknowledgment. @@ -18,7 +18,7 @@ # OR CONDITIONS OF ANY KIND, either express or implied. No content created from # VulnerableCode should be considered or used as legal advice. Consult an Attorney # for any legal advice. -# VulnerableCode is a free software code scanning tool from nexB Inc. and others. +# VulnerableCode is a free software tool from nexB Inc. and others. # Visit https://github.com/nexB/vulnerablecode/ for support and download. from django.contrib import admin @@ -34,22 +34,24 @@ @admin.register(Vulnerability) class VulnerabilityAdmin(admin.ModelAdmin): - pass + search_fields = ["cve_id"] @admin.register(VulnerabilityReference) class VulnerabilityReferenceAdmin(admin.ModelAdmin): - pass + search_fields = ["vulnerability__cve_id", "reference_id", "url"] @admin.register(Package) class PackageAdmin(admin.ModelAdmin): - pass + list_filter = ("type", "namespace") + search_fields = ["name"] @admin.register(PackageRelatedVulnerability) class PackageRelatedVulnerabilityAdmin(admin.ModelAdmin): - pass + list_filter = ("is_vulnerable", "package__type", "package__namespace") + search_fields = ["vulnerability__cve_id", "package__name"] @admin.register(Importer) diff --git a/vulnerabilities/models.py b/vulnerabilities/models.py index e438cb516..135772185 100644 --- a/vulnerabilities/models.py +++ b/vulnerabilities/models.py @@ -144,6 +144,9 @@ class PackageRelatedVulnerability(models.Model): vulnerability = models.ForeignKey(Vulnerability, on_delete=models.CASCADE) is_vulnerable = models.BooleanField() + def __str__(self): + return f"{self.package.package_url} {self.vulnerability.cve_id}" + class Meta: unique_together = ("package", "vulnerability") verbose_name_plural = "PackageRelatedVulnerabilities"