Repository navigation
fix(metrics): render Metric Counts tables and critical-asset gauges - #17119
Conversation
Drop the leftover Bootstrap 2 .tabs-left/.tabs-right/.tabs-below rules from
metrics.html. Since the Tailwind rebuild, .nav-tabs is a full-width horizontal
strip; floating it left pushed the active tab's .table-responsive pane (which
establishes its own block formatting context) into the leftover width beside
it -- 0px at a 1440px viewport -- so the Metric Counts tables disappeared on
the Organization Metrics pages.
Give each Critical Asset Metrics gauge an id of gauge-<id> instead of the
organization name. The gauge shim in metrics.js looks the container up with
document.querySelector('#' + id), which throws a SyntaxError for names
containing spaces or characters such as & + % #. The throw also aborts the
jQuery .each loop, so no gauge on the page rendered.
Authored by T. Walker - DefectDojo
|
This pull request contains a critical finding where a sensitive template file was modified by an author not on the allowed list. Although the issue is flagged as failing, it is not currently set to block the merge.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in
|
| Vulnerability | Configured Sensitive Codepath Modified by Non-Allowed Author |
|---|---|
| Description | File 'dojo/templates/dojo/metrics.html' matches configured sensitive codepath pattern 'dojo/templates/**/*.html' and was modified by 'skywalke34' (commit 793691f) 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: #17119 fix(metrics): render Metric Counts tables and critical-asset gauges
Verdict: approve-with-nits (merge after the red required check is re-run green)
Head SHA reviewed: 793691f
Profile: code change (template + new unit test)
Base / milestone: dev, 3.6.0 (the earliest open milestone with a future due date, checked via the milestones API)
Gates
- ruff 0.16.10
ruff check .on the PR head: all checks passed. - No model change, so no migration and no makemigrations gate. No
helm/change. - CI:
Unit Tests Completeis red only becausetest-k8s / Kubernetes Deployment (1.34.12, debian)failed withdigest-mismatch: errorwhile pulling the chart, followed byrelease: not found. The 1.35.10 k8s job passed on the same run. The PR changes one template and adds one test, and the skill lists k8s jobs as known flakes. Re-run it. That check is required ondev, so the PR cannot merge until it is green.
New test vs base
unittests.test_metrics_templateon the PR head: 2 tests OK.- With
dojo/templates/dojo/metrics.htmlreverted toorigin/dev: both fail. The gauge test fails with'gauge-4' not found in ['R&D + 100% #14', 'books1', 'ebooks2']and the tab test withlegacy floated-tab class 'tabs-left' still on the page.
Break attempts
- Hostile organization names. Created critical orgs named
"><script>alert(1)</script>and123 & coand rendered/critical_product_metrics. Expected escaped output, unique DOM ids, and safe gauge ids. Got 200, no unescaped script, no duplicate ids on the page, gauge idsgauge-4, gauge-5, gauge-1, gauge-2. No break. - Live gauge rendering on base vs PR. In a browser on a local stack with orgs
R&D + 100% #1and9 Lives: ondevall three gauges are empty and the console showsUncaught SyntaxError: ... '#9 Lives3' is not a valid selector(this reproduces the bug). On the PR all three gauges draw and the console is clean. No break. - Metric Counts layout and tab switching. At 1440px on
devthe tab strip isfloat: left, 1165px wide, and the active pane is 0px wide (reproduces the bug). On the PR I clicked through all 8 tabs: each pane is 1184px wide and its table renders (450 to 781px). No break. - Narrow viewport. On the PR at 375px (mobile emulation), the document width equals the viewport width, so there is no horizontal page scroll from the tab strip. No break.
- Other consumers of the removed CSS or the old id format. Grepped
dojo/fortabs-left,tabs-right,tabs-belowandgaugeloop. The only consumer ismetrics.html, and.gaugeloopis read only by the inline loop atmetrics.html:771, which takes the id from the attribute. The gauge title still comes fromname=, so labels are unchanged. The[x-cloak]rule that sat among the deleted rules is kept. No break. - Interaction with the sibling PRs. Merged #17119, #17120, #17122, #17123, #17124 and #17125 onto
devwith no conflicts. On the combined tree, all six new tests plustest_metrics_queries,test_view_engineer_metricsandtest_product_metrics_closed_countpass: 35 tests, OK, 2 skipped. No break.
Blocking
None in the code. The required check needs a green re-run (see Gates).
Nice-to-haves
unittests/test_metrics_template.py:45checks that the class string is absent. It cannot catch a future CSS rule that floats.nav-tabsagain. That is acceptable for a template unit test.
Verified hands-on
Unit tests on the PR head and with the fix reverted. Browser checks on a local stack (dev vs the combined PR tree) of gauge rendering, console errors, the width of every Metric Counts tab at 1440px, and page width at 375px.
Statically only
Whether the gauge JS uses the id anywhere else (dojo/static/dojo/js/metrics.js _ensureCanvas / JustGage).
Could not reproduce
Nothing outstanding. I did not re-run the k8s job myself.
Description
Two rendering bugs in
dojo/templates/dojo/metrics.htmlthat both date from the Tailwind UI rebuild (#14865).1. Metric Counts tables are squeezed out of view (Organization Metrics,
/metrics/organizationand/metrics/organization/<id>).The template still carried Bootstrap 2's
.tabs-leftsidebar CSS, including.tabs-left > .nav-tabs { float: left }..nav-tabsis now a full-width horizontal flex strip, so the "sidebar" became a ~1,165px float. The active pane has.table-responsive(overflow-x: auto), which makes it a block formatting context that is laid out beside the float rather than under it, so the table only gets the leftover width. At a 1440px viewport that is 0px and the tab content disappears entirely; at other widths it renders as a narrow column on the right. The fix removes the dead.tabs-left/right/belowrules (keeping the[x-cloak]rule that lived among them) and the now-inerttabs-leftclass.2. No gauges render on Critical Asset Metrics (
/critical_asset_metrics).Each gauge container's
idwas the organization's name plus its pk. TheJustGageshim indojo/static/dojo/js/metrics.jsresolves it withdocument.querySelector('#' + id), which throwsSyntaxErrorwhenever the name is not a valid CSS identifier — e.g. it contains&,%or#, or starts with a digit ('#R&D + 100% #110' is not a valid selector). Names with only spaces happen to survive via thegetElementByIdfallback. The uncaught error also aborts the jQuery.eachloop, so every gauge on the page stays empty, not just the one with the awkward name. The fix gives each container the idgauge-<pk>.Test results
unittests/test_metrics_template.py(2 tests): asserts gauge container ids are safe CSS identifiers (using an organization namedR&D + 100% #1) and that the Organization Metrics page no longer carries the floated legacy tab classes. Both tests fail on currentdevand pass with this change.unittests.test_metrics_queries,unittests.test_view_engineer_metrics,unittests.test_product_metrics_closed_count— 23 tests, OK (2 pre-existing skips).ruff check/ruff format --check(0.16.10,ruff.toml) pass on the new test file.Documentation
None needed (bug fix, no behavior or setting change).
Checklist
dev.devbranch.bugfix+uiand milestone3.6.0applied.Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo