Skip to content

fix(viewer): harden PDF report rendering - #1192

Open
kusonooyasumi wants to merge 1 commit into
usestrix:mainfrom
kusonooyasumi:fix/pdf-reportlab-hardening
Open

fix(viewer): harden PDF report rendering#1192
kusonooyasumi wants to merge 1 commit into
usestrix:mainfrom
kusonooyasumi:fix/pdf-reportlab-hardening

Conversation

@kusonooyasumi

@kusonooyasumi kusonooyasumi commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace sequential Markdown regexes and forgeable NUL sentinels with CommonMark tokenization that emits only fixed ReportLab formatting tags
  • disable raw HTML, links, images, and autolinks so external report content cannot inject markup or trigger resource loading
  • normalize unsafe controls and lone surrogates, canonicalize finding severities, and reject mixed-timezone duration values
  • fall back to escaped original Markdown if ReportLab rejects generated formatting
  • cover valid nested formatting, malformed emphasis, sentinel collisions, hostile run/finding fields, severity injection, and timestamp edge cases

This builds on and credits the root-cause analysis by @apetcu in #1176, while closing the remaining ReportLab trust-boundary paths found during the broader audit.

Fixes #1171.

Verification

  • uv run pytest tests/test_report_pdf.py tests/test_fenced_code.py tests/test_viewer.py - 73 passed
  • uv run ruff format --check strix/interface/viewer/report_pdf.py tests/test_report_pdf.py
  • uv run ruff check strix/interface/viewer/report_pdf.py tests/test_report_pdf.py
  • uv run mypy strix/interface/viewer/report_pdf.py tests/test_report_pdf.py
  • uv run bandit -r strix/interface/viewer/report_pdf.py -c pyproject.toml
  • uv lock --check
  • real pr-1176-repro run generated a valid PDF
  • full uv run pytest - 1221 passed, 1 unrelated failure in tests/test_pricing.py::test_resolves_common_bare_model_names because the live LiteLLM catalog no longer resolves MiniMax-M3

Prepared with AI assistance; reviewed and tested locally.

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens PDF report generation against unsafe external content and malformed metadata.

  • Replaces regex-based inline Markdown conversion with CommonMark tokenization and fixed ReportLab formatting tags.
  • Normalizes unsafe text, severities, and timestamp error handling.
  • Adds focused tests for hostile content, malformed Markdown, severity values, and timezone edge cases.
  • Adds markdown-it-py as a direct dependency and updates the lockfile.

Confidence Score: 5/5

The PR appears safe to merge with no actionable changed-code defects identified.

The new parser emits only fixed formatting tags or escaped token content, unsafe characters are normalized before ReportLab processing, and the dependency lock remains stable.

Important Files Changed

Filename Overview
strix/interface/viewer/report_pdf.py Reworks Markdown rendering and normalizes untrusted report fields without introducing an actionable changed-code defect.
tests/test_report_pdf.py Adds broad regression coverage for safe inline formatting, hostile fields, malformed input, severity normalization, and mixed timezone values.
pyproject.toml Declares markdown-it-py as a direct runtime dependency.
uv.lock Adds the direct markdown-it-py dependency edge without changing resolved package versions.

Reviews (1): Last reviewed commit: "fix(viewer): harden PDF report rendering" | Re-trigger Greptile

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.

[BUG]PDF report generation fails when finding contains malformed HTML-like text

1 participant