Skip to content

Commit a7134ca

Browse files
committed
Python: Port xml.dom tests
1 parent faebaee commit a7134ca

File tree

2 files changed

+19
-43
lines changed
  • python/ql/test/experimental

2 files changed

+19
-43
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from io import StringIO
2+
import xml.dom.minidom
3+
import xml.dom.pulldom
4+
import xml.sax
5+
6+
x = "some xml"
7+
8+
# minidom
9+
xml.dom.minidom.parse(StringIO(x)) # $ input=StringIO(..) vuln='Billion Laughs' vuln='Quadratic Blowup'
10+
xml.dom.minidom.parseString(x) # $ input=x vuln='Billion Laughs' vuln='Quadratic Blowup'
11+
12+
# pulldom
13+
xml.dom.pulldom.parse(StringIO(x))['START_DOCUMENT'][1] # $ input=StringIO(..) vuln='Billion Laughs' vuln='Quadratic Blowup'
14+
xml.dom.pulldom.parseString(x)['START_DOCUMENT'][1] # $ input=x vuln='Billion Laughs' vuln='Quadratic Blowup'
15+
16+
# These are based on SAX parses, and you can specify your own, so you can expose yourself to XXE (yay/)
17+
parser = xml.sax.make_parser()
18+
parser.setFeature(xml.sax.handler.feature_external_ges, True)
19+
xml.dom.minidom.parse(StringIO(x), parser=parser) # $ input=StringIO(..) vuln='Billion Laughs' vuln='DTD retrieval' vuln='Quadratic Blowup' vuln='XXE'

python/ql/test/experimental/query-tests/Security/CWE-611/xml_dom.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)