Repository navigation
fix(453): escape :.3f/:1f cells after formatting - #456
Conversation
A numeric subclass whose __format__ returns markup could land in the field-performance table/chart and the confusion-matrix percentage cells. Escape the formatted string at each of the five sites. Gauge stays unescaped: int(score * 100) forces a plain int.
digalaviz
left a comment
There was a problem hiding this comment.
Reviewed at 063037f. Approving: all five sites named in #453 are escaped after formatting, and
removing any one escape fails a test. For ordinary values (float, int, numpy types, Decimal,
bool, NaN, infinities, zero, negatives) the table, chart, heatmap and full report render exactly as
on dev. The module docstring explains why the gauge is excluded, as #453 asks.
Merge order with #464: this PR conflicts with #464 in visualization_engine.py and
test_visualization_engine.py. In the source file, #464 escapes the confusion-matrix value and this
PR escapes the percentage on the adjacent line: keep both escaped lines. In the test file, each side
adds a class at the end: keep both classes. Taking either side whole drops the other side's escape
together with the test that guards it. Either order works; the second to land needs that resolution.
Non-blocking:
- The table test gives the hostile value to all three cells, so its positive assertion holds when any
one cell is escaped. A value in one cell at a time would pin each cell. - The payload contains no
&or", so escaping only<would also pass. - The docstring is not an f-string, so
{{value:.Nf}}renders with doubled braces. - Both changed files lose their final newline.
Security Scan ResultsASH Security Scan Report
Scan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies:
Top 3 HotspotsFiles with the highest number of security findings:
Detailed FindingsShow 5 actionable findingsFinding 1: SECRET-HEX-HIGH-ENTROPY-STRING
Description: Code Snippet: Finding 2: B108
Description: Code Snippet: Finding 3: B307
Description: Code Snippet: Finding 4: B307
Description: Code Snippet: Finding 5: B102
Description: Code Snippet: Report generated by Automated Security Helper (ASH) at 2026-10-30T14:38:19+00:00 |
The Documents card interpolated document_count into the page unescaped. ProcessEvaluation validates the field as an int at construction, but not on assignment or through model_construct, so a caller that assigns it, or builds the model with model_construct, could put markup into the report. Document data does not reach it: the bulk evaluator sets an int, and a results dict falls back to 1. The value now goes through html.escape like the other cells, and a test assigns markup after construction and asserts it is escaped. It has the same in-process-caller reachability as #453; #456 escapes the visualization_engine.py cells, not this one.
|
Thank you for this fix, which closed #453. |
Summary
Fixes #453.
Numeric cells that use
:.3f/:.1fwere interpolated without escaping, so a caller-supplied numeric subclass whose__format__returns markup could land in the page. Escape the formatted string at each of the five sites named in the issue:generate_performance_gaugeis intentionally left alone:int(score * 100)forces a plainint, so subclass__format__/__str__/__mul__cannot reach the template (noted in the module docstring).Test plan
HF(float)for table/chart; hostile__truediv__+__mul__+__format__for heatmap percentage)0.912/0.750/100.0%Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.