Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db43d04

Browse files
committed
Python: Add test showing misalignment of xml.etree modeling
1 parent 543454e commit db43d04

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

python/ql/test/library-tests/frameworks/stdlib/XPathExecution.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@
1515
tree.find(match, namespaces=ns) # $ getXPath=match
1616
tree.findall(match, namespaces=ns) # $ getXPath=match
1717
tree.findtext(match, default=None, namespaces=ns) # $ getXPath=match
18+
19+
parser = ET.XMLParser()
20+
parser.feed("<foo>bar</foo>") # $ decodeFormat=XML decodeInput="<foo>bar</foo>" xmlVuln='Billion Laughs' xmlVuln='Quadratic Blowup'
21+
tree = parser.close() # $ decodeOutput=parser.close()
22+
tree.find(match, namespaces=ns) # $ MISSING: getXPath=match

python/ql/test/library-tests/frameworks/stdlib/xml_etree.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
xml.etree.ElementTree.iterparse(StringIO(x)) # $ decodeFormat=XML decodeInput=StringIO(..) xmlVuln='Billion Laughs' xmlVuln='Quadratic Blowup' decodeOutput=xml.etree.ElementTree.iterparse(..) getAPathArgument=StringIO(..)
2323
xml.etree.ElementTree.iterparse(source=StringIO(x)) # $ decodeFormat=XML decodeInput=StringIO(..) xmlVuln='Billion Laughs' xmlVuln='Quadratic Blowup' decodeOutput=xml.etree.ElementTree.iterparse(..) getAPathArgument=StringIO(..)
2424

25+
tree = xml.etree.ElementTree.ElementTree()
26+
tree.parse("file.xml") # $ MISSING: decodeFormat=XML decodeInput="file.xml" xmlVuln='Billion Laughs' xmlVuln='Quadratic Blowup' decodeOutput=tree.parse(..) getAPathArgument="file.xml"
27+
tree.parse(source="file.xml") # $ MISSING: decodeFormat=XML decodeInput="file.xml" xmlVuln='Billion Laughs' xmlVuln='Quadratic Blowup' decodeOutput=tree.parse(..) getAPathArgument="file.xml"
28+
2529

2630
# With parsers (no options available to disable/enable security features)
2731
parser = xml.etree.ElementTree.XMLParser()

0 commit comments

Comments
 (0)