Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ Each release links to full notes on the
no longer split an entity such as `&`
([#422](https://github.com/awslabs/stickler/issues/422))

- **The HTML report's Executive Summary escapes its `Documents` count.** A
`document_count` assigned to a `ProcessEvaluation` after construction, or set
through `model_construct`, is not validated as an `int`, so a string assigned
there was written into the page unescaped. Document data does not reach this
value.

- List reporting ([#332](https://github.com/awslabs/stickler/issues/332)):
`non_matches` and `field_comparisons` reuse the pairings, scores, and
threshold decisions made during list scoring. Rejected pairs produce indexed
Expand Down
2 changes: 1 addition & 1 deletion src/stickler/reporting/html/section_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate_executive_summary(self, config: ReportConfig) -> str:
html_string += f"""
<div class="summary-grid">
<div class="metric-card">
<div class="metric-value">{doc_count}</div>
<div class="metric-value">{html.escape(str(doc_count))}</div>
<div class="metric-label">Documents</div>
</div>
"""
Expand Down
16 changes: 15 additions & 1 deletion tests/reporting/html/test_section_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,21 @@ def test_generate_executive_summary_missing_document_count(self, mock_extract_me
result = self.section_generator.generate_executive_summary(config)

assert '<div class="metric-value">1</div>' in result # Default value


def test_executive_summary_escapes_the_document_count(self):
"""A document_count assigned after construction is not validated, so it is escaped."""
results = ProcessEvaluation(document_count=3, metrics={})
results.document_count = '<img src=x onerror=alert(1)>'
generator = SectionGenerator(results, self.mock_viz_engine)

result = generator.generate_executive_summary(ReportConfig())

assert '<img src=x onerror=alert(1)>' not in result
assert (
'<div class="metric-value">&lt;img src=x onerror=alert(1)&gt;</div>'
in result
)

@patch('stickler.reporting.html.utils.data_extractors.DataExtractor.extract_field_metrics')
def test_generate_field_analysis(self, mock_extract_field_metrics):
"""Test field analysis generation."""
Expand Down
Loading