Skip to content

Fix HTML report reference group sorting - #2479

Closed
rajsshah86 wants to merge 1 commit into
OpenSCAP:mainfrom
rajsshah86:fix/html-reference-group-sort
Closed

rajsshah86 wants to merge 1 commit into
OpenSCAP:mainfrom
rajsshah86:fix/html-reference-group-sort

Conversation

@rajsshah86

Copy link
Copy Markdown

Summary

Fixes #2478.

HTML report reference groups can remain out of numeric order when numeric and textual IDs are mixed. The existing comparator checks the first operand twice and can return NaN. Simply correcting that typo is not sufficient: mixing numeric and lexical token comparisons still yields non-transitive ordering for references such as AU-9(3), AU-12(c), and AU-12 b.

  • Use numeric-aware string collation with a lexical tie-breaker for distinct labels that compare numerically equal (such as 01 and 1).
  • Preserve existing severity/result sorting and default-grouping reset behavior.
  • Regenerate xsl/xccdf-resources.xsl with the existing YUI compressor build script so generated reports contain the fix.
  • Add dependency-free Node.js regression tests covering source and generated JavaScript. Register them with CTest when Node.js is available; otherwise emit an explicit configuration message.

Validation

  • Confirmed the regression tests fail on the original source and on the original generated bundle.
  • node tests/report/sort_groups.js passes for both source and bundle, covering 27 reference-grouping keys, mixed numeric/text permutations, dotted references, NIST formats, leading zeros, empty/single/duplicate values, severity/result permutations, and default reset behavior.
  • Additional local validation: 3,240 shuffled/reversed/rotated-order checks across 27 reference groupings, covering both source and bundle. No private report data is included in this PR.
  • JavaScript syntax checks, xmllint --noout xsl/xccdf-resources.xsl, and git diff --check pass.
  • Full native OpenSCAP build/CTest suite not run locally; this is a report-side JavaScript change.

This changes presentation ordering only, not evaluation results.

Use numeric-aware collation with a deterministic tie-breaker for mixed reference IDs. Regenerate the bundled report resources and cover all grouping modes with optional Node.js regression tests.

Fixes OpenSCAP#2478

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Security Rating on New Code (required ≥ A)
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@rajsshah86 rajsshah86 closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML report reference groups sort incorrectly with mixed numeric and text IDs

1 participant