Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
  • Loading branch information
TG1999 committed Apr 22, 2022
1 parent 2a92099 commit c4b73f5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
3 changes: 2 additions & 1 deletion vulnerabilities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from django.core.validators import MaxValueValidator
from django.core.validators import MinValueValidator
from django.db import models
from django.utils.http import int_to_base36
from packageurl import PackageURL
from packageurl.contrib.django.models import PackageURLMixin

Expand Down Expand Up @@ -68,7 +69,7 @@ class Vulnerability(models.Model):

@property
def vulcoid(self):
return f"VULCOID-{numpy.base_repr(self.id, base=36)}"
return f"VULCOID-{int_to_base36(self.id).upper()}"

@property
def vulnerable_to(self):
Expand Down
52 changes: 38 additions & 14 deletions vulnerabilities/templates/vulnerability.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,51 @@ <h3>Severity</h3>
{% endif %}

{% if vulnerability.vulnerable_to.all %}
<h3> Vulnerable Packages </h3>
<div class="tags is-medium">
{% for package in vulnerability.vulnerable_to.all %}
<span class="tag is-danger is-medium">
<a href ="{% url 'package_view' package.pk %}" class="has-text-white"> {{package.package_url}}</a>
</span>
{% endfor %}
</div>
<h3> Vulnerable Packages </h3>
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
<tr>
<th> Packages </th>
</tr>
{% for package in vulnerability.vulnerable_to.all %}
<tr>
{% if package.package_url %}
<td>
<a href ="{% url 'package_view' package.pk %}"> {{package.package_url}} </a>
</td>

{% else %}
<td>-</td>

{% endif %}
</tr>

{% endfor %}
</table>
{% else %}
<h3> No available vulnerable packages </h3>
<h3> No available Vulnerable packages </h3>
{% endif %}

{% if vulnerability.resolved_to.all %}
<h3> Patched Packages </h3>
<div class="tags is-medium">
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
<tr>
<th> Packages </th>
</tr>
{% for package in vulnerability.resolved_to.all %}
<span class="tag is-success is-medium">
<a href ="{% url 'package_view' package.pk %}" class="has-text-white"> {{package.package_url}} </a>
</span>
<tr>
{% if package.package_url %}
<td>
<a href ="{% url 'package_view' package.pk %}"> {{package.package_url}} </a>
</td>

{% else %}
<td>-</td>

{% endif %}
</tr>

{% endfor %}
</div>
</table>
{% else %}
<h3> No available patched packages </h3>
{% endif %}
Expand Down

0 comments on commit c4b73f5

Please sign in to comment.