fix: parse downloaded coverage.xml with defusedxml (#50) - #57
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #50
Acceptance criterion (verbatim): "
banditovercollector/jq_collectorreports no B314/B405, either fixed or suppressed with a written reason."Which branch, and who chose it: the criterion allows two outcomes. This takes the fixed one, defusedxml, as recommended in triage and selected by the maintainer. A
# nosecwould have recorded why the stdlib parser was acceptable; this makes it unnecessary.What changed
jq_collector/github.py:from xml.etree import ElementTree→from defusedxml import ElementTree. The API is the same:fromstringandParseErrorare both there, so the parse site and theexceptincoverage_percentare untouched. defusedxml refuses entity declarations and external references with aValueErrorsubclass, which thatexceptalready maps to "malformed report, log and carry on" rather than a failed refresh. The existing_MAX_UNPACKED_BYTEScap still bounds the size.pyproject.toml/uv.lock:defusedxml>=0.7as a runtime dependency, andtypes-defusedxmlin the dev group so mypy keeps checking the call. The image installs fromuv export --locked, so it picks this up with no Dockerfile change.tests/test_coverage.py: one new case in the existing malformed-report parametrization,declares-an-entity. The payload is well-formed and its entity expands to a validline-rate, so the stdlib parser would read it as 100%. I checked that it fails with the old import and passes with this one, so the defence can't be silently reverted.Gates (from
collector/, asci.ymlruns them)ruff check/ruff format --check jq_collector tests: cleanuv run --frozen mypy: no issues in 11 filespytest --cov=jq_collector: 452 passed, 100%; the same on--python 3.11bandit -r jq_collector: no B314/B405. The remaining findings are B404/B603/B607 on the fixed-argumentgitcalls inlocalgit.pyandorigin.py, outside this issue.deptry jq_collector(in the project env): no issuesMerge note: #54 also edits
github.py(type annotations), in hunks that don't touch these lines, so the two should merge cleanly in either order.🤖 Generated with Claude Code