Skip to content

Commit baa09ce

Browse files
committed
Fix views
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent c3b6d51 commit baa09ce

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

vulnerabilities/templates/advisory_detail.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@
137137
applications, or networks. This metric is determined automatically based on the discovery of known exploits.">
138138
Exploitability</td>
139139
<td class="two-col-right wrap-strings">
140-
{{ advisory.exploitability }}
140+
{% if advisory.exploitability is not None %}
141+
{{ advisory.exploitability }}
142+
{% else %}
143+
{{ "" }}
144+
{% endif %}
141145
</td>
142146
</tr>
143147

@@ -146,7 +150,11 @@
146150
data-tooltip="Weighted severity is the highest value calculated by multiplying each severity by its corresponding weight, divided by 10."
147151
>Weighted Severity</td>
148152
<td class="two-col-right wrap-strings">
149-
{{ advisory.weighted_severity }}
153+
{% if advisory.weighted_severity is not None %}
154+
{{ advisory.weighted_severity }}
155+
{% else %}
156+
{{ "" }}
157+
{% endif %}
150158
</td>
151159
</tr>
152160

@@ -157,7 +165,11 @@
157165
"
158166
>Risk</td>
159167
<td class="two-col-right wrap-strings">
160-
{{ advisory.risk_score }}
168+
{% if advisory.risk_score is not None %}
169+
{{ advisory.risk_score }}
170+
{% else %}
171+
{{ "" }}
172+
{% endif %}
161173
</td>
162174
</tr>
163175
<tr>

vulnerabilities/views.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ def get_context_data(self, **kwargs):
217217
context["package_search_form"] = PackageSearchForm(self.request.GET)
218218

219219
if not package.type in TYPES_WITH_MULTIPLE_IMPORTERS:
220+
affecting_advisories = AdvisoryV2.objects.latest_affecting_advisories_for_purl(
221+
purl=package.purl
222+
)
223+
224+
fixed_by_advisories = AdvisoryV2.objects.latest_fixed_by_advisories_for_purl(
225+
purl=package.purl
226+
)
227+
220228
context["grouped"] = False
221229

222230
affected_by_advisories_url = None
@@ -282,15 +290,14 @@ def get_context_data(self, **kwargs):
282290

283291
return context
284292

285-
affecting_advisories = AdvisoryV2.objects.latest_affecting_advisories_for_purl(
286-
purl=package.purl
287-
)
288-
289-
fixed_by_advisories = AdvisoryV2.objects.latest_fixed_by_advisories_for_purl(
293+
if package.type in TYPES_WITH_MULTIPLE_IMPORTERS:
294+
affecting_advisories = AdvisoryV2.objects.latest_affecting_advisories_for_purl(
290295
purl=package.purl
291-
)
296+
)
292297

293-
if package.type in TYPES_WITH_MULTIPLE_IMPORTERS:
298+
fixed_by_advisories = AdvisoryV2.objects.latest_fixed_by_advisories_for_purl(
299+
purl=package.purl
300+
)
294301
fixed_pkg_details = get_fixed_package_details(package)
295302
context["fixed_package_details"] = fixed_pkg_details
296303
context["grouped"] = True

0 commit comments

Comments
 (0)