Repository navigation
fix: reject DTD and entity declarations in JUnit result summaries - #590
Ankit500ak wants to merge 1 commit into
Conversation
yeongseon
left a comment
There was a problem hiding this comment.
Reviewed HEAD 418f68f for #588. Reading the raw JUnit bytes and rejecting NUL, <!DOCTYPE, and <!ENTITY case-insensitively before ET.fromstring is an appropriately fail-closed guard. Malformed or explicitly rejected evidence maps to None, hence INCOMPLETE for exit 0 (not PASS), and the existing exit-code path still yields FAIL for nonzero. The parser keeps ElementTree's normal declared-encoding handling, unlike the competing #589's unconditional UTF-8 text decoding. Code approved; merge only after action_required Actions are actually authorized and all required checks pass on the final head. Consider adding lowercase-declaration, NUL and nonzero-exit regressions as a small test hardening follow-up. Coordinate with #589 (same issue/files) to avoid duplicate merges.
Problem
Issue #588:
scripts/report_results.pyparses JUnit XML withxml.etree.ElementTreedirectly. A result file carrying a DTD or entity declarations (for example a crafted file from an untrusted build) is parsed without any rejection, so a hostile or malformed summary can flow into the reported status.Change
parse_junitnow reads the payload as bytes and returns None when it contains a NUL byte,<!DOCTYPEor<!ENTITY(case-insensitive), before parsing. A rejected file yields an INCOMPLETE/FAIL summary downstream, never a PASS.Tests
test_junit_with_dtd_or_entity_declaration_cannot_pass(internal entity, external entity, bare doctype): parse_junit returns None and the summarized status is INCOMPLETE.ruff checkandruff format --checkclean on the changed files.Not run
Overlap check
Open PRs reviewed (584, 581, 570, 569, 568, 567, 554, 526): none touches scripts/report_results.py.
Docs: not needed - internal result-parsing guard; no user-facing documentation describes JUnit payload handling.
Closes #588