Skip to content

Commit

Permalink
Rework and re-arrange the Vulnerability tab #98
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Nov 22, 2024
1 parent 3510780 commit b3875a3
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 57 deletions.
4 changes: 2 additions & 2 deletions dejacode/static/css/dejacode_bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ table.vulnerabilities-table .column-summary {
width: 155px;
}
#tab_vulnerabilities .column-weighted_severity {
width: 125px;
width: 120px;
}
#tab_vulnerabilities .column-risk_score {
width: 95px;
width: 90px;
}
#tab_vulnerabilities .column-summary {
width: 300px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% load i18n %}
{% include 'tabs/pagination.html' %}
<table class="table table-bordered table-hover table-md text-break">
<table class="table table-bordered table-md text-break">
{% include 'includes/object_list_table_header.html' with filter=filterset include_actions=True %}
<tbody>
{% for vulnerability in page_obj.object_list %}
<tr>
<td>
<td rowspan="{{ vulnerability.affected_packages.count }}">
<strong>
{% if vulnerability.resource_url %}
<a href="{{ vulnerability.resource_url }}" target="_blank">
Expand All @@ -15,69 +15,68 @@
{% else %}
{{ vulnerability.vulnerability_id }}
{% endif %}
{% if vulnerability.summary %}
<span class="float-end" data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="hover focus" data-bs-content="{{ vulnerability.summary }}">
<i class="fa-solid fa-circle-info"></i>
</span>
{% endif %}
</strong>
<div class="mt-2">
{% include 'component_catalog/includes/vulnerability_aliases.html' with aliases=vulnerability.aliases only %}
</div>
</td>
<td>
<ul class="list-unstyled mb-0">
{% for package in vulnerability.affected_packages.all %}
<li>
<a href="{{ package.get_absolute_url }}#vulnerabilities" target="_blank">{{ package }}</a>
{% include 'vulnerabilities/includes/risk_score_badge.html' with risk_score=package.risk_score label='risk' only %}
</li>
{% endfor %}
</ul>
</td>
<td>
<td rowspan="{{ vulnerability.affected_packages.count }}">
{% include 'vulnerabilities/includes/exploitability.html' with instance=vulnerability only %}
</td>
<td>
<td rowspan="{{ vulnerability.affected_packages.count }}">
{{ vulnerability.weighted_severity|default_if_none:"" }}
</td>
<td class="fs-110pct">
<td rowspan="{{ vulnerability.affected_packages.count }}" class="fs-110pct">
{% include 'vulnerabilities/includes/risk_score_badge.html' with risk_score=vulnerability.risk_score only %}
</td>
<td>
{% if vulnerability.summary %}
{% if vulnerability.summary|length > 120 %}
<details>
<summary>{{ vulnerability.summary|slice:":120" }}...</summary>
{{ vulnerability.summary|slice:"120:" }}
</details>
{% else %}
{{ vulnerability.summary }}
{% endif %}
{% endif %}
</td>
<td>
{% if vulnerability.vulnerability_analyses.get %}
{% for package in vulnerability.affected_packages.all %}
{% if not forloop.first %}<tr>{% endif %}
<td>
<ul class="list-unstyled mb-0">
{% if vulnerability.vulnerability_analyses.get.state %}
<li><strong>{{ vulnerability.vulnerability_analyses.get.state|capfirst }}</strong></li>
{% endif %}
{% if vulnerability.vulnerability_analyses.get.justification %}
<li>Justification: {{ vulnerability.vulnerability_analyses.get.justification }}</li>
{% endif %}
{% if vulnerability.vulnerability_analyses.get.responses %}
<li>Responses: {{ vulnerability.vulnerability_analyses.get.responses|join:", " }}</li>
{% endif %}
{% if vulnerability.vulnerability_analyses.get.detail %}
<li>Detail: {{ vulnerability.vulnerability_analyses.get.detail }}</li>
{% endif %}
<li>
<a href="{{ package.get_absolute_url }}#vulnerabilities" target="_blank">{{ package }}</a>
{% include 'vulnerabilities/includes/risk_score_badge.html' with risk_score=package.risk_score label='risk' only %}
</li>
</ul>
{% endif %}
</td>
<td class="p-1">
<span data-bs-toggle="modal" data-bs-target="#vulnerability-analysis-modal" class=""
data-edit-url="{{ product.get_absolute_url }}vulnerability_analysis_ajax_view/?vulnerability_id={{ vulnerability.vulnerability_id }}"
>
<button type="button" data-bs-toggle="tooltip" title="Edit" class="btn btn-link p-0" aria-label="Edit">
<i class="far fa-edit fa-sm"></i>
</button>
</span>
</td>
</td>
<td>
{% if vulnerability.vulnerability_analyses.get %}
<ul class="list-unstyled mb-0">
{% if vulnerability.vulnerability_analyses.get.state %}
<li><strong>{{ vulnerability.vulnerability_analyses.get.get_state_display }}</strong></li>
{% endif %}
{% if vulnerability.vulnerability_analyses.get.detail %}
<li>Detail: {{ vulnerability.vulnerability_analyses.get.detail }}</li>
{% endif %}
</ul>
{% endif %}
</td>
<td>
{% if vulnerability.vulnerability_analyses.get %}
{{ vulnerability.vulnerability_analyses.get.get_justification_display }}
{% endif %}
</td>
<td>
{% if vulnerability.vulnerability_analyses.get.responses %}
{{ vulnerability.vulnerability_analyses.get.responses|join:"<br>" }}
{% endif %}
</td>
<td class="p-1">
<span data-bs-toggle="modal" data-bs-target="#vulnerability-analysis-modal" class=""
data-edit-url="{{ product.get_absolute_url }}vulnerability_analysis_ajax_view/?vulnerability_id={{ vulnerability.vulnerability_id }}"
>
<button type="button" data-bs-toggle="tooltip" title="Edit" class="btn btn-link p-0" aria-label="Edit">
<i class="far fa-edit fa-sm"></i>
</button>
</span>
</td>
{% if not forloop.first %}</tr>{% endif %}
{% endfor %}
</tr>
{% empty %}
<tr>
Expand Down
16 changes: 13 additions & 3 deletions product_portfolio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,17 +1112,27 @@ class ProductTabVulnerabilitiesView(
filterset_class = VulnerabilityFilterSet
table_headers = (
Header("vulnerability_id", _("Vulnerability")),
Header("affected_packages", _("Affected packages"), help_text="Affected product packages"),
Header("exploitability", _("Exploitability"), filter="exploitability"),
Header("weighted_severity", _("Severity"), filter="weighted_severity"),
Header("risk_score", _("Risk"), filter="risk_score"),
Header("summary", _("Summary")),
Header("affected_packages", _("Affected packages"), help_text="Affected product packages"),
Header(
"exploitability",
"vulnerability_analyses__state",
_("Status"),
help_text=_("Exploitability analysis"),
filter="vulnerability_analyses__state",
),
Header(
"vulnerability_analyses__justification",
_("Justification"),
help_text=_("TODO"),
filter="vulnerability_analyses__justification",
),
Header(
"vulnerability_analyses__responses",
_("Responses"),
help_text=_("TODO"),
),
)

def get_context_data(self, **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions vulnerabilities/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class VulnerabilityFilterSet(DataspacedFilterSet):
"weighted_severity",
"risk_score",
"affected_products_count",
"affected_packages",
"affected_packages_count",
"fixed_packages_count",
"created_date",
Expand All @@ -104,6 +105,7 @@ class Meta:
fields = [
"q",
"vulnerability_analyses__state",
"vulnerability_analyses__justification",
"exploitability",
]

Expand All @@ -114,6 +116,7 @@ def __init__(self, *args, **kwargs):
"weighted_severity",
"risk_score",
"vulnerability_analyses__state",
"vulnerability_analyses__justification",
]
for field_name in dropdown_fields:
self.filters[field_name].extra["widget"] = DropDownRightWidget(anchor=self.anchor)

0 comments on commit b3875a3

Please sign in to comment.