Skip to content

Commit fbb895a

Browse files
committed
Add url property to Alias model and implement
Reference: #856 Reference: #860 - Added Alias URLs to vulnerability search results and details templates. - Added external link icons to Alias URLs. - Added about info to navbar. - Still need contact info and something re obtaining API key. Signed-off-by: John M. Horan <[email protected]>
1 parent cec8915 commit fbb895a

File tree

6 files changed

+74
-15
lines changed

6 files changed

+74
-15
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 4.0.6 on 2022-08-23 19:15
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('vulnerabilities', '0018_alter_alias_options'),
10+
]
11+
12+
operations = [
13+
migrations.AlterModelOptions(
14+
name='vulnerabilityreference',
15+
options={'ordering': ['reference_id', 'url']},
16+
),
17+
]

vulnerabilities/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class Meta:
124124
"url",
125125
"reference_id",
126126
)
127+
ordering = ["reference_id", "url"]
127128

128129
def __str__(self):
129130
reference_id = f" {self.reference_id}" if self.reference_id else ""
@@ -355,6 +356,18 @@ class Alias(models.Model):
355356
related_name="aliases",
356357
)
357358

359+
@property
360+
def url(self):
361+
"""
362+
Create a URL for the alias.
363+
"""
364+
alias: str = self.alias
365+
if alias.startswith("CVE"):
366+
return f"https://nvd.nist.gov/vuln/detail/{alias}"
367+
368+
if alias.startswith("GHSA"):
369+
return f"https://github.com/advisories/{alias}"
370+
358371
class Meta:
359372
ordering = ["alias"]
360373

vulnerabilities/templates/navbar.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,32 @@
2121
<div class="navbar-item navbar-item is-cursor-help">
2222
<div class="dropdown is-right is-hoverable ">
2323
<div class="dropdown-trigger has-text-grey-light">
24-
v{{ VULNERABLECODE_VERSION }}
24+
About
2525
</div>
2626
<div class="dropdown-menu navbar-hover-div" role="menu">
2727
<div class="dropdown-content">
28-
<div class="dropdown-item">
29-
Related information can be provided here.
28+
<div class="dropdown-item about-hover-div">
29+
A free and open vulnerabilities database and the packages they impact. And the tools to aggregate and correlate these vulnerabilities.
30+
<ul>
31+
<li>
32+
Sponsored by NLnet <a href="https://nlnet.nl/project/vulnerabilitydatabase/">https://nlnet.nl/project/vulnerabilitydatabase/</a> for <a href="https://www.aboutcode.org/">https://www.aboutcode.org/</a>
33+
</li>
34+
<li>
35+
Chat at <a href="https://gitter.im/aboutcode-org/vulnerablecode">https://gitter.im/aboutcode-org/vulnerablecode</a>
36+
</li>
37+
<li>
38+
Docs at <a href=https://vulnerablecode.readthedocs.org/>https://vulnerablecode.readthedocs.org/</a>
39+
</li>
40+
</ul>
3041
</div>
3142
</div>
3243
</div>
3344
</div>
3445
</div>
46+
<div class="navbar-item navbar-item is-cursor-help">
47+
<div class="dropdown-trigger has-text-grey-light">
48+
v{{ VULNERABLECODE_VERSION }}
49+
</div>
50+
</div>
3551
</div>
3652
</nav>

vulnerabilities/templates/vulnerabilities.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,15 @@
118118
<a href="{% url 'vulnerability_view' vulnerability.pk %}?vuln_id={{ vulnerability.vulnerability_id }}" target="_self">{{ vulnerability.vulnerability_id }}</a>
119119
</td>
120120
<td>
121-
<ul>
122-
{% for alias in vulnerability.alias %}
123-
<li>
124-
{{ alias }}
125-
</li>
126-
{% endfor %}
127-
</ul>
128-
{% if vulnerability.alias|length > 3 %}
129-
<button class="button is-small is-fullwidth show-clipped">Show {{ vulnerability.alias|length }} Aliases</button>
130-
{% endif %}
121+
{% for alias in vulnerability.alias %}
122+
{% if alias.url %}
123+
<a href={{ alias.url }} target="_blank">{{ alias }}<i class="fa fa-external-link fa_link_custom"></i></a>
124+
<br />
125+
{% else %}
126+
{{ alias }}
127+
<br />
128+
{% endif %}
129+
{% endfor %}
131130
</td>
132131
<td>{{ vulnerability.vulnerable_package_count }}</td>
133132
<td>{{ vulnerability.patched_package_count }}</td>

vulnerabilities/templates/vulnerability.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@
165165
<td class="two-col-right">
166166
{% if aliases %}
167167
{% for alias in aliases %}
168-
<p>
168+
{% if alias.url %}
169+
<a href={{ alias.url }} target="_blank">{{ alias }}<i class="fa fa-external-link fa_link_custom"></i></a>
170+
<br />
171+
{% else %}
169172
{{ alias }}
170-
</p>
173+
<br />
174+
{% endif %}
171175
{% endfor %}
172176
{% else %}
173177

vulnerablecode/static/css/custom.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,14 @@ a.small_page_button {
334334
border: 0;
335335
border-radius: 6px;
336336
box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0px 0 1px rgb(10 10 10 / 2%);
337+
}
338+
339+
.about-hover-div {
340+
width: 500px;
341+
}
342+
343+
.fa_link_custom {
344+
font-size: 10px !important;
345+
vertical-align: super;
346+
margin-left: 2px;
337347
}

0 commit comments

Comments
 (0)