Skip to content

Commit

Permalink
Display the risk_threshold value when enabled #97
Browse files Browse the repository at this point in the history
Including a link to see all vulnerabilities

Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Dec 13, 2024
1 parent 61a47e3 commit 832c5b2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dje/templates/object_details_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h1 class="header-title text-break">
</nav>

<div class="background-white">
<div class="tab-content pt-4 px-0 container" style="height: 100%; min-height: 28.5em;">
<div class="tab-content pt-3 px-0 container" style="height: 100%; min-height: 28.5em;">
{% for tab_name, tab_context in tabsets.items %}
{# IDs are prefixed with "tab_" to avoid autoscroll issue #}
<div class="tab-pane{% if forloop.first %} show active{% endif %}" id="tab_{{ tab_name|slugify }}" role="tabpanel" aria-labelledby="tab_{{ tab_name|slugify }}-tab" tabindex="0">
Expand Down
2 changes: 1 addition & 1 deletion dje/templates/tabs/pagination.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load humanize %}
<div class="row align-items-end">
<div class="col mb-3">
<div class="col mb-2">
<ul class="nav nav-pills">
<li class="nav-item">
<form id="tab-{{ tab_id }}-search-form" class="mt-md-0 me-sm-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
{% load as_icon from dje_tags %}

{% include 'tabs/pagination.html' %}

{% if risk_threshold %}
<small class="d-inline-flex mb-3 px-2 py-1 fw-semibold text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-2">
A risk threshold filter at "{{ risk_threshold }}" is currently applied.
<a class="ms-1" href="?vulnerabilities-bypass_risk_threshold=Yes#vulnerabilities">Click here to see all vulnerabilities.</a>
</small>
{% endif %}

<table class="table table-bordered table-md text-break">
{% include 'includes/object_list_table_header.html' with filter=filterset include_actions=True %}
<tbody>
Expand Down
12 changes: 10 additions & 2 deletions product_portfolio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,11 @@ def tab_vulnerabilities(self):
if not all(display_tab_contions):
return

risk_threshold = product.get_vulnerabilities_risk_threshold()
if self.request.GET.get("vulnerabilities-bypass_risk_threshold"):
risk_threshold = None
else:
risk_threshold = product.get_vulnerabilities_risk_threshold()

vulnerability_count = product.get_vulnerability_qs(risk_threshold=risk_threshold).count()
if not vulnerability_count:
label = 'Vulnerabilities <span class="badge bg-secondary">0</span>'
Expand Down Expand Up @@ -1153,7 +1157,11 @@ class ProductTabVulnerabilitiesView(

def get_context_data(self, **kwargs):
product = self.object
risk_threshold = product.get_vulnerabilities_risk_threshold()

if self.request.GET.get("vulnerabilities-bypass_risk_threshold"):
risk_threshold = None
else:
risk_threshold = product.get_vulnerabilities_risk_threshold()

total_count = product.get_vulnerability_qs(risk_threshold=risk_threshold).count()
vulnerability_qs = (
Expand Down

0 comments on commit 832c5b2

Please sign in to comment.