Skip to content
Merged
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
14 changes: 8 additions & 6 deletions vulnerabilities/admin.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand All @@ -34,22 +34,24 @@

@admin.register(Vulnerability)
class VulnerabilityAdmin(admin.ModelAdmin):
pass
search_fields = ["cve_id"]
Copy link
Member

Choose a reason for hiding this comment

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

I really want to get #259 merged ASAP



@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)
Expand Down
3 changes: 3 additions & 0 deletions vulnerabilities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down