Skip to content

fix(metrics): right-align numeric column headers to match their values - #17122

Merged
Maffooch merged 1 commit into
DefectDojo:devfrom
skywalke34:fix/metrics-numeric-header-alignment
Dec 3, 2026
Merged

Maffooch merged 1 commit into
DefectDojo:devfrom
skywalke34:fix/metrics-numeric-header-alignment

Conversation

@skywalke34

Copy link
Copy Markdown
Contributor

Description

The metrics tables right-align their numeric cells (<td class="text-end">), but the matching <th> cells have no alignment class, and .table th is left-aligned. Each header therefore sits at the opposite edge of its column from its numbers. Narrow tables hide it; on wide tables every number reads as belonging to the next column. On Simple Metrics, for example, "3485" (Total) sits under "Critical", and "33" (Critical) sits under "High". This predates the Tailwind rebuild: the i18n change only renamed text-right to text-end.

The fix adds text-end to the 108 headers whose column is right-aligned in simple_metrics.html, pt_counts.html (Organization and Asset Tag Counts) and metrics.html (Organization Metrics). Text columns (Asset, Month, Title, ...) are unchanged. The diff touches only class attributes.

Before After
Simple Metrics before after
Organization Counts, trend table before after

Test results

  • New unittests/test_metrics_numeric_header_alignment.py (3 tests). It parses every table on Simple Metrics, Organization Counts and Organization Metrics with lxml and requires that each header above a text-end column also has text-end. It also asserts that at least one numeric column was checked, so an empty page can't pass vacuously. All 3 fail on current dev and pass with this change.
  • Existing metrics suites still pass: 24 tests OK in total, 2 pre-existing skips.
  • Verified live at 1440px and 1640px: headers line up with their values on both pages.
  • 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

Numeric cells in the metrics tables carry text-end, but their <th> cells
did not, and `.table th` is left-aligned. Each header therefore sat at the
opposite edge of the column from its numbers; on wide tables (Simple
Metrics, Organization/Asset Tag Counts) every value read as belonging to
the next column. Add text-end to the 108 headers whose column is
right-aligned in simple_metrics.html, pt_counts.html and metrics.html.
Text columns (Asset, Month, Title, ...) are unchanged.

Authored by T. Walker - DefectDojo
@dryrunsecurity

dryrunsecurity Bot commented Dec 1, 2026

Copy link
Copy Markdown

DryRun Security

This pull request contains critical security findings because the user 'skywalke34' modified sensitive HTML template files without being on the allowed authors list. Specifically, the files metrics.html, pt_counts.html, and simple_metrics.html were flagged for unauthorized modification.

🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/templates/dojo/metrics.html (drs_5893abef)
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 60f14e6) who is not in the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/templates/dojo/pt_counts.html (drs_9681b62f)
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 60f14e6) who is not in the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/templates/dojo/simple_metrics.html (drs_f795450d)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/templates/dojo/simple_metrics.html' matches configured sensitive codepath pattern 'dojo/templates/**/*.html' and was modified by 'skywalke34' (commit 60f14e6) 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 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: #17122 fix(metrics): right-align numeric column headers to match their values

Verdict: approve
Head SHA reviewed: 60f14e6
Profile: code change (template classes + 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_metrics_numeric_header_alignment on the PR head: 3 tests OK.
  • With metrics.html, pt_counts.html and simple_metrics.html reverted to origin/dev: all 3 fail, each listing the misaligned headers.

Break attempts

  1. Diff is only class attributes. I stripped class="text-end" and class="nowrap text-end" from the PR's three templates and diffed against origin/dev: identical. I counted 108 added text-end headers, which matches the description. No break.
  2. Over-alignment (the reverse of the PR's test). On rendered pages I checked every header/cell pair in both directions, for up to 3 body rows per table: a header marked text-end above a cell that is not, and a text-end cell under a header that is not. Pages: Simple Metrics (24 pairs), Organization Counts (66), Asset Tag Counts (66, a page the PR's test does not render), Organization Metrics (226), a single Organization's metrics page (226), and Critical Asset Metrics (no tables). On the PR: zero mismatches in either direction. On dev: every numeric header is flagged. No break.
  3. Shared template, second view. pt_counts.html also renders Asset Tag Counts. Covered in attempt 2 and clean. No break.
  4. Interaction with #17124, which edits the same "No." row in pt_counts.html. git merge-tree shows no conflict, and the combined tree passes all six new tests plus the existing metrics suites (35 OK, 2 skipped). No break.
  5. Visual check. Browser on the combined tree at 1440px: Organization Counts headers sit over their numbers. No break.

Blocking

None.

Nice-to-haves

  • misaligned_headers in the new test skips tables whose header and first-row cell counts differ, and it only reads the first body row. That is fine for these templates, but a future table that uses colspan would be silently skipped. The checked > 0 guard keeps the test from passing on an empty page.

Verified hands-on

Tests on the PR head and with the fix reverted. My two-way alignment check on six rendered pages on the PR and on dev. Browser view of Organization Counts.

Statically only

Tables that rendered no rows with the test data. The diff is class-only, so those can only gain a right-aligned header.

Could not reproduce

Nothing outstanding.

@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
Merged via the queue into DefectDojo:dev with commit 45d4850 Dec 3, 2026
40 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