Skip to content

Commit cafae07

Browse files
committed
move triage content into the vulnerabilites tab
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 0f7ae37 commit cafae07

7 files changed

Lines changed: 105 additions & 280 deletions

File tree

dejacode/static/css/dejacode_bootstrap.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@ table.vulnerabilities-table .column-summary {
433433
width: 300px;
434434
}
435435
#tab_vulnerabilities .column-vulnerability_analyses__state {
436-
min-width: 125px;
436+
min-width: 100px;
437437
}
438438
#tab_vulnerabilities .column-vulnerability_analyses__justification {
439439
min-width: 130px;
440440
}
441441
#tab_vulnerabilities .column-vulnerability_analyses__responses {
442-
width: 185px;
442+
min-width: 120px;
443443
}
444444
#tab_vulnerabilities .column-vulnerability_analyses__is_reachable {
445445
width: 80px;

product_portfolio/filters.py

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
from vulnerabilities.models import Vulnerability
4545
from vulnerabilities.models import VulnerabilityAnalysisMixin
4646
from vulnerabilities.triage.models import TriageAction
47-
from vulnerabilities.triage.models import TriageRecord
4847

4948

5049
class HasComplianceIssueFilter(django_filters.BooleanFilter):
@@ -368,6 +367,7 @@ class ProductPackageFilterSet(BaseProductRelationFilterSet):
368367
dropdown_fields = [
369368
"is_modified",
370369
"weighted_risk_score",
370+
"triage_action",
371371
"vulnerability_analyses__state",
372372
"vulnerability_analyses__justification",
373373
"responses",
@@ -421,6 +421,12 @@ class ProductPackageFilterSet(BaseProductRelationFilterSet):
421421
("unknown", _("Reachability not known")),
422422
),
423423
)
424+
triage_action = django_filters.ChoiceFilter(
425+
label=_("Triage action"),
426+
choices=TriageAction.choices,
427+
empty_label=_("All actions"),
428+
method="filter_triage_action",
429+
)
424430
compliance_issues = HasComplianceIssueFilter(
425431
field_name="package__usage_policy__compliance_alert",
426432
distinct=True,
@@ -440,6 +446,15 @@ class Meta:
440446
"exploitability",
441447
]
442448

449+
@staticmethod
450+
def filter_triage_action(queryset, name, value):
451+
if not value:
452+
return queryset
453+
return queryset.filter(
454+
triage_records__action=value,
455+
triage_records__ruleset__enabled=True,
456+
).distinct()
457+
443458
def __init__(self, *args, **kwargs):
444459
super().__init__(*args, **kwargs)
445460
self.filters["vulnerability_analyses__state"].extra["null_label"] = "(No values)"
@@ -586,32 +601,3 @@ class Meta:
586601
"is_pinned",
587602
"is_direct",
588603
]
589-
590-
591-
class TriageRecordFilterSet(DataspacedFilterSet):
592-
dropdown_fields = ["action"]
593-
594-
q = SearchFilter(
595-
label=_("Search"),
596-
search_fields=[
597-
"product_package__package__name",
598-
"product_package__package__namespace",
599-
"product_package__package__version",
600-
],
601-
)
602-
action = django_filters.ChoiceFilter(
603-
label=_("Action"),
604-
choices=TriageAction.choices,
605-
empty_label=_("All actions"),
606-
)
607-
sort = DefaultOrderingFilter(
608-
label=_("Sort"),
609-
fields=[
610-
("product_package__package__name", "package"),
611-
("detected_date", "detected_date"),
612-
],
613-
)
614-
615-
class Meta:
616-
model = TriageRecord
617-
fields = ["action"]

product_portfolio/templates/product_portfolio/tabs/tab_packages_vulnerabilities.html

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,36 @@
1919
<strong>
2020
<a href="{{ product_package.package.get_absolute_url }}#vulnerabilities" target="_blank">{{ product_package.package }}</a>
2121
</strong>
22-
{% if product_package.purpose %}
23-
<div class="text-nowrap mt-1">
24-
{{ product_package.purpose.label_with_icon }}
25-
{% if product_package.purpose.exposure_factor %}
26-
<div>
27-
<i class="fas fa-arrow-alt-circle-right"></i>
28-
Exposure factor: {{ product_package.purpose.exposure_factor }}
29-
</div>
22+
<div class="d-flex flex-wrap gap-2 mt-1">
23+
{% with score=product_package.weighted_risk_score %}
24+
{% if score %}
25+
<span class="badge {% if score >= 8.0 %}bg-danger-subtle text-danger-emphasis{% elif score >= 6.0 %}bg-warning-subtle text-warning-emphasis{% elif score >= 3.0 %}bg-info-subtle text-info-emphasis{% else %}bg-secondary-subtle text-secondary-emphasis{% endif %}">
26+
{% trans "Risk" %} {{ score }}
27+
</span>
3028
{% endif %}
31-
<div>
32-
{{ product_package.is_deployed|as_icon }}
33-
{% if product_package.is_deployed %}Deployed{% else %}Not deployed{% endif %}
34-
</div>
35-
</div>
36-
{% endif %}
29+
{% endwith %}
30+
{% if product_package.is_deployed %}
31+
<span class="badge text-bg-light border">{% trans "Deployed" %}</span>
32+
{% endif %}
33+
{% if product_package.purpose %}
34+
<span class="badge text-bg-light border">{{ product_package.purpose.label }}</span>
35+
{% endif %}
36+
</div>
3737
</td>
3838
<td rowspan="{{ product_package.package.vulnerability_count }}">
39-
{% include 'vulnerabilities/includes/risk_score_badge.html' with risk_score=product_package.weighted_risk_score only %}
39+
{% if product_package.triage_record %}
40+
{% with record=product_package.triage_record %}
41+
<span class="badge {{ record.action_badge_class }} d-block text-start">
42+
<i class="fas {{ record.action_icon }} me-1"></i>{{ record.action_label }}
43+
</span>
44+
<div class="small text-body-secondary mt-1 ps-1">
45+
<i class="fas fa-layer-group fa-xs me-1"></i>{{ record.ruleset.name }}
46+
</div>
47+
<div class="small text-body-tertiary mt-1 ps-1">
48+
{% trans "Since:" %} {{ record.detected_date|date:"M j, Y" }}
49+
</div>
50+
{% endwith %}
51+
{% endif %}
4052
</td>
4153
{% for vulnerability in product_package.package.affected_by_vulnerabilities.all %}
4254
{% if not forloop.first %}<tr>{% endif %}
@@ -56,9 +68,19 @@
5668
</span>
5769
{% endif %}
5870
</strong>
59-
<div>
60-
{% include 'vulnerabilities/includes/risk_score_badge.html' with risk_score=vulnerability.risk_score label="Risk:" only %}
61-
{% include 'vulnerabilities/includes/exploitability.html' with instance=vulnerability only %}
71+
<div class="d-flex flex-wrap gap-1 mt-1">
72+
{% with score=vulnerability.risk_score %}
73+
{% if score %}
74+
<span class="badge {% if score >= 8.0 %}bg-danger-subtle text-danger-emphasis{% elif score >= 6.0 %}bg-warning-subtle text-warning-emphasis{% elif score >= 3.0 %}bg-info-subtle text-info-emphasis{% else %}bg-secondary-subtle text-secondary-emphasis{% endif %}">
75+
{% trans "Risk:" %} {{ score }}
76+
</span>
77+
{% endif %}
78+
{% endwith %}
79+
{% if vulnerability.exploitability %}
80+
<span class="badge {% if vulnerability.exploitability == 2.0 %}bg-danger-subtle text-danger-emphasis{% elif vulnerability.exploitability == 1.0 %}bg-warning-subtle text-warning-emphasis{% else %}bg-secondary-subtle text-secondary-emphasis{% endif %}">
81+
{{ vulnerability.get_exploitability_display }}
82+
</span>
83+
{% endif %}
6284
</div>
6385
{% if vulnerability.aliases %}
6486
<div class="mt-2">

product_portfolio/templates/product_portfolio/tabs/tab_triage.html

Lines changed: 0 additions & 75 deletions
This file was deleted.

product_portfolio/urls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from product_portfolio.views import ProductTabDependenciesView
3535
from product_portfolio.views import ProductTabInventoryView
3636
from product_portfolio.views import ProductTabLicensesView
37-
from product_portfolio.views import ProductTabTriageView
3837
from product_portfolio.views import ProductTabVulnerabilitiesView
3938
from product_portfolio.views import ProductTreeComparisonView
4039
from product_portfolio.views import ProductUpdateView
@@ -153,7 +152,6 @@ def product_path(path_segment, view):
153152
*product_path("tab_dependencies", ProductTabDependenciesView.as_view()),
154153
*product_path("tab_licenses", ProductTabLicensesView.as_view()),
155154
*product_path("tab_vulnerabilities", ProductTabVulnerabilitiesView.as_view()),
156-
*product_path("tab_triage", ProductTabTriageView.as_view()),
157155
*product_path("tab_activity", ProductTabActivityView.as_view()),
158156
*product_path("tab_inventory", ProductTabInventoryView.as_view()),
159157
*product_path("tab_compliance", ProductTabComplianceView.as_view()),

0 commit comments

Comments
 (0)