Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/TestScripts/testBazelReporter.py
diff options
context:
space:
mode:
authorLeitwolf112026-11-15 22:29:48 +0300
committerLeitwolf112026-11-15 22:29:48 +0300
commit79f624d693b4fc3167c239c3eca47c858799333f (patch)
treed42816753aa7f421e92dceba4e4e2b264b1a4773 /tests/TestScripts/testBazelReporter.py
parent6750f61c28be2861280078328e164e88bc1dfe44 (diff)
downloadcatch3-79f624d693b4fc3167c239c3eca47c858799333f.tar.gz
Bound three string and XML reads that analysis flagged
- On macOS, the path from _NSGetExecutablePath is cut at its first NUL found inside the buffer, in place of strlen, which reads until a NUL wherever it is. - The table test measures its C strings with std::string_view. - The Bazel reporter test reads the JUnit report and rejects a document type before parsing it, so no entity, external or internal, is ever expanded. Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
Diffstat (limited to 'tests/TestScripts/testBazelReporter.py')
-rw-r--r--tests/TestScripts/testBazelReporter.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/TestScripts/testBazelReporter.py b/tests/TestScripts/testBazelReporter.py
index 62600a39..f91e7b0f 100644
--- a/tests/TestScripts/testBazelReporter.py
+++ b/tests/TestScripts/testBazelReporter.py
@@ -56,7 +56,14 @@ if ret.returncode != 42:
exit(1)
try:
- tree = ET.parse(xml_out_path)
+ with open(xml_out_path, 'r', encoding='utf-8') as report:
+ text = report.read()
+ # A JUnit report has no document type, so it declares no entities: one
+ # that does is rejected before parsing, and no entity is ever expanded.
+ if '<!DOCTYPE' in text or '<!ENTITY' in text:
+ print("The report declares a document type: '{}'".format(xml_out_path))
+ exit(2)
+ tree = ET.ElementTree(ET.fromstring(text))
except ET.ParseError as ex:
print("Invalid XML: '{}'".format(ex))
raise