Repository navigation
fix(metrics): paginate the open findings table on Organization and Asset Tag Counts - #17124
Conversation
…set Tag Counts product_type_counts and product_tag_counts passed every open finding in the organization (or tag) to pt_counts.html, which rendered all of them: 7,376 rows and a 7.2 MB page for one organization on a demo instance. Page the queryset in both views with get_page_items (25 per page, `open` prefix, ordered by numerical_severity, newest first, id as tiebreak), add the shared paging snippet under the table, and continue the "No." column across pages via start_index. The paging links keep the month/year and organization/tag filters. The same page is now ~0.2 s and 91 KB. Authored by T. Walker - DefectDojo
|
This pull request contains critical findings where user 'skywalke34' modified sensitive codepaths in 'dojo/templates/dojo/pt_counts.html' and 'dojo/metrics/views.py' without being on the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in
|
| Vulnerability | Configured Sensitive Codepath Modified by Non-Allowed Author |
|---|---|
| Description | File 'dojo/templates/dojo/pt_counts.html' matches configured sensitive codepath pattern 'dojo/templates/**/*.html' and was modified by 'skywalke34' (commit f56662f) who is not in the allowed authors list. |
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/metrics/views.py (drs_980ff199)
| Vulnerability | Configured Sensitive Codepath Modified by Non-Allowed Author |
|---|---|
| Description | File 'dojo/metrics/views.py' matches configured sensitive codepath pattern 'dojo/metrics/*.py' and was modified by 'skywalke34' (commit f56662f) who is not in the allowed authors list. |
We've notified @mtesauro.
Comment to provide feedback on these findings.
Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]
Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing
All finding details can be found in the DryRun Security Dashboard.
Maffooch
left a comment
There was a problem hiding this comment.
Review: #17124 fix(metrics): paginate the open findings table on Organization and Asset Tag Counts
Verdict: approve-with-nits
Head SHA reviewed: f56662f
Profile: code change (two views + shared template + new unit test)
Base / milestone: dev, 3.6.0 (correct)
Gates
- ruff 0.16.10: all checks passed.
- CI: 40 of 40 pass.
- No model, settings or Helm change.
New test vs base
unittests.test_counts_open_findings_pagingon the PR head: 2 tests OK.- With
dojo/metrics/views.pyandpt_counts.htmlreverted toorigin/dev: both error ('TagulousCastTaggedBaseQuerySet' object has no attribute 'paginator').
Break attempts
- Hostile page params.
openpage=abcandopenpage=999return 200.openpage_size=abcreturns 500 (ValueError) andopenpage_size=0returns 500 (ZeroDivisionError). Ondevthese params are ignored (200). Same root cause as on #17123:dojo/utils.py:912returns 500 forpage_size=abc/0on every paginated page ondev(I reproduced it on/metrics/engineerand/finding/open). Follow-up, not a blocker. - Query count and prefetch on a page. Whole page at page size 25 vs 100: 77 vs 77 (on
dev: 76, the extra one is the paginator count). The existingprefetch_relatedapplies to the page slice, so rows add no N+1. No break. - Filter preservation and numbering. Live on a local stack, Organization Counts for an org with 60 findings: 25 rows, the first "No." cell is
1, and the pager hrefs are?month=12&year=2026&product_type=2&openpage=2. The PR's test also covers Asset Tag Counts and page-2 numbering starting at 26. No break. - Empty organization. A new org with no findings renders 200 with the table header and no pager (
paging_snippet.htmlis gated onpaginator.count > 0). The table wrapper is keyed onpton bothdevand the PR, so nothing changes. No break. - Other template uses of
all_current_in_pt. Inpt_counts.htmlit appears only in the loop and the new include, with no|lengthor count that would now read 25. The heading usespt. No break. - Interaction with #17122 (the same "No." row) and #17125 (the same file): no conflicts. The combined tree passes 35 tests. No break.
Blocking
None.
Nice-to-haves
- Follow-up issue for the shared
get_page_items_and_countsize parsing (see attempt 1). - The page-size dropdown in
paging_snippet.htmluses a fixedid="pageSizeDropdown". That is fine here because each counts page has a single pager.
Verified hands-on
Tests on the PR head and with the fix reverted. My edge-case test on the PR and on dev. Live Organization Counts and Asset Tag Counts on the combined tree.
Statically only
Template uses of the context variable.
Could not reproduce
The 7,376-row timings in the description.
Description
Organization Counts (
/metrics/organization/counts) and Asset Tag Counts (/metrics/asset/tag/counts) end with an " Open Findings" table that lists every open finding in the organization (or tag), all on one page. On a demo instance, for one organization in one month:Both views (
product_type_counts,product_tag_counts) now pageall_current_in_ptwith the existingget_page_itemshelper (25 per page,openprefix), ordered bynumerical_severity, newest first, withidas a stable tiebreak. Before, it was ordered by severity only, which isn't stable across pages. In the sharedpt_counts.html:paging_snippet.html, with a page-size picker, goes under the table.start_index.month/yearandproduct_type/product_tagfilters, since the snippet usesurl_replace.The
tablesorter-bootstrapclass on the table is inert: no script loads tablesorter, and other paginated tables such asview_product_type.htmlcarry it too. So no client-side sort is lost.Test results
unittests/test_counts_open_findings_paging.py(2 tests, one per page). Both fail on currentdev, where the table gets an unpaged queryset, and pass with this change. Each checks:openpage=abc) returns 200.ruff check(0.16.10) passes.Documentation
None needed (bug fix).
Checklist
dev.devbranch.Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo