Repository navigation
fix(metrics): name assets through the label system on the dashboard and engineer pages - #17121
Conversation
…nd engineer pages
The Metrics Dashboard's top-ten panel and the Engineer Metrics page hard-coded
"Products" / "product", so they read wrong when products are shown as Assets,
and the engineer page's heading and column headers were not translatable.
- Panel heading, screen-reader title and table caption on the dashboard, and the
engineer page heading, now use ASSET_METRICS_TOP_TEN_BY_SEVERITY_LABEL, the
label the Organization Metrics page already uses (translated in both modes).
- The "Product" column headers (1 on the dashboard, 8 on the engineer page) use
ASSET_LABEL.
- The dashboard chart's screen-reader description no longer names products. It
also rendered "for the top products": {{ length }} sat in a blocktrans
without a `with`, so the count was always empty. It also fixes the
"x-axiscrepresents" typo. The new message is translated in all 27 catalogs.
Authored by T. Walker - DefectDojo
|
This pull request contains critical findings where the user 'skywalke34' modified sensitive HTML template files without being on the allowed authors list. Specifically, the files 'dashboard-metrics.html' and 'view_engineer.html' were flagged for unauthorized changes to configured sensitive codepaths.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in
|
| Vulnerability | Configured Sensitive Codepath Modified by Non-Allowed Author |
|---|---|
| Description | File 'dojo/templates/dojo/dashboard-metrics.html' matches configured sensitive codepath pattern 'dojo/templates/**/*.html' and was modified by 'skywalke34' (commit 10a316a) who is not in the allowed authors list. |
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/templates/dojo/view_engineer.html (drs_d748f990)
| Vulnerability | Configured Sensitive Codepath Modified by Non-Allowed Author |
|---|---|
| Description | File 'dojo/templates/dojo/view_engineer.html' matches configured sensitive codepath pattern 'dojo/templates/**/*.html' and was modified by 'skywalke34' (commit 10a316a) 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.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Maffooch
left a comment
There was a problem hiding this comment.
Review: #17121 fix(metrics): name assets through the label system on the dashboard and engineer pages
Verdict: approve-with-nits
Head SHA reviewed: f791882
Base: dev (milestone 3.6.0, correct)
Profile: code change (templates + 28 .po catalogs + tests)
Summary
The dashboard top-ten panel and the engineer page now use ASSET_METRICS_TOP_TEN_BY_SEVERITY_LABEL and ASSET_LABEL. Both are gettext_lazy (dojo/asset/labels.py:2), so they still translate per request. The broken screen-reader sentence (empty {{ length }}, "x-axiscrepresents") is replaced with a blocktrans trimmed message. That message exists in every catalog, and the msgid matches what the template renders: I compiled de and fr and the translated text appears on the page.
Attempts
| # | What I did | Expected | Got | Result |
|---|---|---|---|---|
| 1 | Reverted both templates and dojo/locale to origin/dev, ran unittests.test_metrics_asset_labels |
fail on dev, pass on PR | dev: both page tests fail plus the catalog test for all 28 languages; PR: 3/3 pass | no break |
| 2 | Same tests with DD_ENABLE_V3_ORGANIZATION_ASSET_RELABEL=False (legacy Product wording) |
still pass | pass (the test branches on the label value) | no break |
| 3 | msgfmt --check-format on all 28 catalogs: dev, PR, and all five PRs merged |
no new errors or duplicate msgids | 0 errors in every case | no break |
| 4 | Compiled de/fr .mo, rendered /metrics?date=5&view=dashboard with Accept-Language |
translated description and heading | de: "Dieses Balkendiagramm ... jeden Eintrag der Rangliste ..." / "Top 10 Assets nach Bug-Schweregrad"; fr equivalents | no break |
| 5 | Live dashboard with 1 asset in the ranking | heading, caption, th and description use labels; no "Product" text | all four use labels, 0 occurrences of "Product(s)" on the page, table has 1 row | no break (see nit 1) |
| 6 | Live /metrics/engineer/1 |
8 Asset headers, no bare Product header, label heading |
8 / 0 / present | no break |
| 7 | Neighbour suites (test_metrics_queries, test_view_engineer_metrics, test_product_metrics_closed_count) on the merged tree |
pass | pass (part of a 42-test run, 2 pre-existing skips) | no break |
| 8 | Checked for other consumers of dashboard-metrics.html / top_ten_products that might lack the labels context |
none broken | only dojo/metrics/views.py:127; labels comes from the global context processor (dojo/context_processors.py:110) |
no break |
Nice to have
- The heading now always says "Top 10" even when fewer rows exist. With one asset in the ranking it read "Top 1 Products By Bug Severity" before and reads "Top 10 Assets by bug severity" now. The PR calls this out and it matches Organization Metrics, so it's fine. Just noting the visible change.
- The replaced msgids ("Top %(length)s Products By Bug Severity", "Top Products By Bug Severity", the old description, "Bug count by severity for top products") stay in the catalogs as dead entries. A later
makemessagespass will mark them obsolete. Not a blocker. - The new translations are machine-produced. The PR says so, and native review is welcome.
Verified hands-on
Own compose stack with seeded data. Rendered both pages live in English, and the dashboard in German and French with compiled catalogs. New tests on the PR, on the reverted tree, and with relabel off. ruff 0.16.10 clean. CI green.
Static only / not reproduced
The other 26 languages were checked only by msgfmt and the catalog test, not rendered. The chart JS (metrics.js) is unchanged and was not exercised beyond the page loading.
Description
The Metrics Dashboard's top-ten panel (
/metrics?view=dashboard) and the Engineer Metrics page (/metrics/engineer/<id>) hard-code "Products" / "product". They read wrong when products are shown as Assets, and the engineer page's text isn't translatable at all. This moves them onto the label system, following the same approach as #17110:ASSET_METRICS_TOP_TEN_BY_SEVERITY_LABEL. That's the label the Organization Metrics page already uses for the same ranking, and it's already translated in both naming modes.<th>Product</th>(8 on the engineer page, untranslated) and{% trans "Product" %}(1 in the dashboard's screen-reader table) now useASSET_LABEL.#top-ten-description):{{ length }}sat in a{% blocktrans %}withoutwith length=..., so the count was always empty.blocktrans trimmed). The new message has a translation in all 27 translated catalogs, adapted from each catalog's existing translation of the old sentence so the terms match. English keeps an emptymsgstr. The translations are machine-produced; native-speaker review is welcome.Test results
unittests/test_metrics_asset_labels.py(3 tests). All 3 fail on currentdevand pass with this change:test_metrics_queries,test_view_engineer_metrics,test_product_metrics_closed_count): 24 tests OK in total, 2 pre-existing skips.msgfmt --checkpasses on all 28 catalogs. Its only output is the pre-existing header-field warnings.ruff check/ruff format --check(0.16.10) pass.Documentation
None needed (bug fix).
Checklist
dev.devbranch.Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo