Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix numerical sorting in the old UI for Active/Verified findings #10045

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dojo/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ class ProductFilter(DojoFilter):
('origin', 'origin'),
('external_audience', 'external_audience'),
('internet_accessible', 'internet_accessible'),
('findings_count', 'findings_count')
),
field_labels={
'name': 'Product Name',
Expand All @@ -1193,6 +1194,7 @@ class ProductFilter(DojoFilter):
'origin': 'Origin ',
'external_audience': 'External Audience ',
'internet_accessible': 'Internet Accessible ',
'findings_count': 'Findings Count ',
}

)
Expand Down
4 changes: 4 additions & 0 deletions dojo/product/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def product(request):
# see https://code.djangoproject.com/ticket/23771 and https://code.djangoproject.com/ticket/25375
name_words = prods.values_list('name', flat=True)

prods = prods.annotate(
findings_count=Count('engagement__test__finding', filter=Q(engagement__test__finding__active=True))
)

prod_filter = ProductFilter(request.GET, queryset=prods, user=request.user)

prod_list = get_page_items(request, prod_filter.qs, 25)
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h3 class="has-filters">
{% if system_settings.enable_github %}
<th class="text-center">GitHub</th>
{% endif %}
<th class="text-center"> Active (Verified) Findings</th>
<th class="text-center">{% dojo_sort request 'Active (Verified) Findings' 'findings_count' %}</th>
<th class="text-center"> Vulnerable Hosts / Endpoints</th>
<th> Contact</th>
{% comment %} The display field is translated in the function. No need to translate here as well{% endcomment %}
Expand Down
Loading