Skip to content

fix: reject DTD and entity declarations in JUnit result summaries - #590

Open
Ankit500ak wants to merge 1 commit into
cubrid-lab:mainfrom
Ankit500ak:fix/junit-dtd-entity-rejection
Open

Ankit500ak wants to merge 1 commit into
cubrid-lab:mainfrom
Ankit500ak:fix/junit-dtd-entity-rejection

Conversation

@Ankit500ak

Copy link
Copy Markdown

Problem

Issue #588: scripts/report_results.py parses JUnit XML with xml.etree.ElementTree directly. 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_junit now reads the payload as bytes and returns None when it contains a NUL byte, <!DOCTYPE or <!ENTITY (case-insensitive), before parsing. A rejected file yields an INCOMPLETE/FAIL summary downstream, never a PASS.
  • This mirrors the guard already used in the sister pycubrid repo's result collector.

Tests

  • Added 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.
  • Before the fix: 3 failed, 69 passed. After: 72 passed.
  • ruff check and ruff format --check clean on the changed files.

Not run

  • The full repository test suite beyond tests/test_report_results.py, and a live MCP server 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

@yeongseon yeongseon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
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.

test: reject DTD or entity declarations in JUnit result summaries

2 participants