Skip to content

Commit cda5c42

Browse files
committed
Update package and vulnerability details pages
Reference: #798 Signed-off-by: John M. Horan <johnmhoran@gmail.com>
1 parent ae871fb commit cda5c42

5 files changed

Lines changed: 68 additions & 307 deletions

File tree

vulnerabilities/templates/navbar.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<a class="navbar-item" href="{% url 'vulnerability_search' %}">
1313
Vulnerabilities
1414
</a>
15-
<a class="navbar-item" href="{% url 'redoc' %}">
16-
API Documentation
15+
<a class="navbar-item" href="https://vulnerablecode.readthedocs.io/en/latest/" target="_blank">
16+
Documentation
1717
</a>
1818
</div>
1919
</div>

vulnerabilities/templates/package_update.html

Lines changed: 23 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,26 @@
8686
</li>
8787
<li data-tab="2">
8888
<a>
89-
<span>Affected By Vulnerabilities</span>
89+
<span>
90+
Affected By Vulnerabilities
91+
{% if impacted_vuln %}
92+
({{impacted_vuln|length}})
93+
{% else %}
94+
(0)
95+
{% endif %}
96+
</span>
9097
</a>
9198
</li>
9299
<li data-tab="3">
93100
<a>
94-
<span>Fixing Vulnerabilities</span>
101+
<span>
102+
Fixing Vulnerabilities
103+
{% if resolved_vuln %}
104+
({{resolved_vuln|length}})
105+
{% else %}
106+
(0)
107+
{% endif %}
108+
</span>
95109
</a>
96110
</li>
97111
</ul>
@@ -106,56 +120,7 @@
106120
{{package.package_url}}
107121
</td>
108122
</tr>
109-
<tr>
110-
<td class="two-col-left">type</td>
111-
<td class="two-col-right">
112-
{{package.type}}
113-
</td>
114-
</tr>
115-
<tr>
116-
<td class="two-col-left">namespace</td>
117-
<td class="two-col-right">
118-
{{package.namespace}}
119-
</td>
120-
</tr>
121-
<tr>
122-
<td class="two-col-left">name</td>
123-
<td class="two-col-right">
124-
{{package.name}}
125-
</td>
126-
</tr>
127-
<tr>
128-
<td class="two-col-left">version</td>
129-
<td class="two-col-right">
130-
{{package.version}}
131-
</td>
132-
</tr>
133-
<tr>
134-
<td class="two-col-left">qualifiers</td>
135-
<td class="two-col-right">
136-
{% for key, value in package.qualifiers.items %}
137-
{{key}} = {{value}}
138-
{% endfor %}
139-
</td>
140-
</tr>
141-
<tr>
142-
<td class="two-col-left">subpath</td>
143-
<td class="two-col-right">
144-
{{package.subpath}}
145-
</td>
146-
</tr>
147-
<tr>
148-
<td class="two-col-left">Affected By Vulnerabilities</td>
149-
<td class="two-col-right">
150-
{{impacted_vuln|length}}
151-
</td>
152-
</tr>
153-
<tr>
154-
<td class="two-col-left">Fixing Vulnerabilities</td>
155-
<td class="two-col-right">
156-
{{resolved_vuln|length}}
157-
</td>
158-
</tr>
123+
159124
{% if debug_ui %}
160125
<tr>
161126
<td class="two-col-left" style="color: #009900;">Packages with no reported unresolved vulnerabilities</td>
@@ -209,14 +174,8 @@
209174

210175
{% else %}
211176
<tr>
212-
<td>
213-
None
214-
</td>
215-
<td>
216-
217-
</td>
218-
<td>
219-
177+
<td colspan="3">
178+
This package does not fix any vulnerabilities.
220179
</td>
221180
</tr>
222181
{% endif %}
@@ -255,14 +214,8 @@
255214

256215
{% else %}
257216
<tr>
258-
<td>
259-
None
260-
</td>
261-
<td>
262-
263-
</td>
264-
<td>
265-
217+
<td colspan="3">
218+
This package does not fix any vulnerabilities.
266219
</td>
267220
</tr>
268221
{% endif %}
@@ -426,9 +379,10 @@
426379
</div>
427380
</div>
428381
{% endif %}
382+
{% endif %}
429383
</section>
430384

431-
{% endif %}
385+
432386
{% endif %}
433387

434388
{% endblock %}

vulnerabilities/templates/vulnerability.html

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,50 @@
8181
</li>
8282
<li data-tab="2">
8383
<a>
84-
<span>References</span>
84+
<span>
85+
References
86+
{% if object_list %}
87+
({{object_list|length}})
88+
{% else %}
89+
(0)
90+
{% endif %}
91+
</span>
8592
</a>
8693
</li>
8794
<li data-tab="3">
8895
<a>
89-
<span>Severity</span>
96+
<span>
97+
Severity
98+
{% if severity_list %}
99+
({{severity_list|length}})
100+
{% else %}
101+
(0)
102+
{% endif %}
103+
</span>
90104
</a>
91105
</li>
92106
<li data-tab="4">
93107
<a>
94-
<span>Affected Packages</span>
108+
<span>
109+
Affected Packages
110+
{% if vulnerability.vulnerable_to %}
111+
({{vulnerability.vulnerable_to|length}})
112+
{% else %}
113+
(0)
114+
{% endif %}
115+
</span>
95116
</a>
96117
</li>
97118
<li data-tab="5">
98119
<a>
99-
<span>Fixed Packages</span>
120+
<span>
121+
Fixed Packages
122+
{% if vulnerability.resolved_to %}
123+
({{vulnerability.resolved_to|length}})
124+
{% else %}
125+
(0)
126+
{% endif %}
127+
</span>
100128
</a>
101129
</li>
102130
</ul>
@@ -144,46 +172,6 @@
144172
{% endif %}
145173
</td>
146174
</tr>
147-
<tr>
148-
<td class="two-col-left">References</td>
149-
<td class="two-col-right">
150-
{% if object_list %}
151-
{{object_list|length}}
152-
{% else %}
153-
0
154-
{% endif %}
155-
</td>
156-
</tr>
157-
<tr>
158-
<td class="two-col-left">Severity</td>
159-
<td class="two-col-right">
160-
{% if severity_list %}
161-
{{severity_list|length}}
162-
{% else %}
163-
0
164-
{% endif %}
165-
</td>
166-
</tr>
167-
<tr>
168-
<td class="two-col-left">Affected Packages</td>
169-
<td class="two-col-right">
170-
{% if vulnerability.vulnerable_to %}
171-
{{vulnerability.vulnerable_to|length}}
172-
{% else %}
173-
0
174-
{% endif %}
175-
</td>
176-
</tr>
177-
<tr>
178-
<td class="two-col-left">Fixed Packages</td>
179-
<td class="two-col-right">
180-
{% if vulnerability.resolved_to %}
181-
{{vulnerability.resolved_to|length}}
182-
{% else %}
183-
0
184-
{% endif %}
185-
</td>
186-
</tr>
187175
</tbody>
188176
</table>
189177

@@ -204,15 +192,15 @@
204192
<td>{{ref.reference_id}}</td>
205193

206194
{% else %}
207-
<td>-</td>
195+
<td></td>
208196

209197
{% endif %}
210198

211199
{% if ref.url %}
212200
<td><a href="{{ ref.url }}">{{ref.url}}</a></td>
213201

214202
{% else %}
215-
<td>-</td>
203+
<td></td>
216204

217205
{% endif %}
218206
</tr>

vulnerabilities/views.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@ def _related_packages(self):
257257
purl = self.get_object()
258258
return list(
259259
models.Package.objects.all()
260-
# We want to ID potential replacement packages -- do we need to also match subpath and qualifiers fields?
261-
# .filter(Q(type=purl.type, namespace=purl.namespace, name=purl.name))
262260
.filter(
263261
Q(
264262
type=purl.type,
@@ -297,7 +295,6 @@ def get_context_data(self, **kwargs):
297295
vulnerability = models.Vulnerability.objects.get(id=self.kwargs["pk"])
298296
context["vulnerability"] = vulnerability
299297
context["aliases"] = vulnerability.aliases.alias()
300-
# TODO: can we get sort the related packages by version here?
301298

302299
vulnerability_list = vulnerability.references.all()
303300
vulnerability_list_count = len(vulnerability_list)

0 commit comments

Comments
 (0)