Skip to content

fix(metrics): name assets through the label system on the dashboard and engineer pages - #17121

Merged
Maffooch merged 2 commits into
DefectDojo:devfrom
skywalke34:fix/metrics-asset-labels
Dec 3, 2026
Merged

Maffooch merged 2 commits into
DefectDojo:devfrom
skywalke34:fix/metrics-asset-labels

Conversation

@skywalke34

Copy link
Copy Markdown
Contributor

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:

  • Headings: the dashboard panel heading, its screen-reader title and table caption, and the engineer page heading now use 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.
    • The dashboard heading was "Top {{ count }} Products By Bug Severity" with the live count. It now reads "Top 10 Assets by bug severity", the same as Organization Metrics. I chose this over adding a new count-plus-noun message to every catalog.
  • Column headers: the hard-coded <th>Product</th> (8 on the engineer page, untranslated) and {% trans "Product" %} (1 in the dashboard's screen-reader table) now use ASSET_LABEL.
  • Screen-reader chart description (#top-ten-description):
    • It named products, and it rendered "for the top products" with no number: {{ length }} sat in a {% blocktrans %} without with length=..., so the count was always empty.
    • It also had the typo "x-axiscrepresents".
    • It's replaced with a neutral sentence (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 empty msgstr. The translations are machine-produced; native-speaker review is welcome.
Before After
Dashboard before after
Engineer metrics before after

Test results

  • New unittests/test_metrics_asset_labels.py (3 tests). All 3 fail on current dev and pass with this change:
  • Existing metrics suites still pass (test_metrics_queries, test_view_engineer_metrics, test_product_metrics_closed_count): 24 tests OK in total, 2 pre-existing skips.
  • msgfmt --check passes on all 28 catalogs. Its only output is the pre-existing header-field warnings.
  • Verified live (relabel on): the dashboard and engineer pages show "Top 10 Assets by bug severity" and "Asset" column headers, and the screen-reader description renders the new text.
  • ruff check / ruff format --check (0.16.10) pass.

Documentation

None needed (bug fix).

Checklist

  • Rebased against the latest dev.
  • Submitted against the dev branch.
  • Meaningful PR name.
  • Ruff compliant.
  • Python 3.13 compliant.
  • New feature documentation: n/a, bug fix.
  • Migrations: n/a, no model changes.
  • Unit tests added.
  • Labels and milestone applied.

Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo

…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
@dryrunsecurity

dryrunsecurity Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

DryRun Security

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 dojo/templates/dojo/dashboard-metrics.html (drs_d5ae0760)
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 Maffooch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. 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.
  2. 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 makemessages pass will mark them obsolete. Not a blocker.
  3. 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.

@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 3, 2026
@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 3, 2026
@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
Merged via the queue into DefectDojo:dev with commit 2db47e3 Dec 3, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants