mirror of https://github.com/google/oss-fuzz.git
lxml: refine and fix fuzzers (#7655)
This commit is contained in:
parent
bcf7972c03
commit
d28259d4c7
|
@ -16,24 +16,24 @@
|
|||
|
||||
import atheris
|
||||
import sys
|
||||
import io
|
||||
|
||||
with atheris.instrument_imports():
|
||||
from lxml import etree as et
|
||||
import io
|
||||
from lxml import etree as et
|
||||
|
||||
|
||||
def TestOneInput(data):
|
||||
"""Targets Schematron. Currently validates, but we should add more APIs"""
|
||||
try:
|
||||
schema_raw = et.parse(io.BytesIO(data))
|
||||
valid_tree = et.parse(io.BytesIO('<AAA><BBB/><CCC/></AAA>'))
|
||||
valid_tree = et.parse(io.BytesIO(b'<AAA><BBB/><CCC/></AAA>'))
|
||||
|
||||
schema = etree.Schematron(schema_raw)
|
||||
schema = et.Schematron(schema_raw)
|
||||
schame.validate(valid_tree)
|
||||
except et.LxmlError:
|
||||
None
|
||||
|
||||
def main():
|
||||
atheris.instrument_all()
|
||||
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
|
||||
atheris.Fuzz()
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ def TestOneInput(data):
|
|||
"""Targets XML schema validation. More APIs should be added"""
|
||||
try:
|
||||
schema_raw = et.parse(io.BytesIO(data))
|
||||
valid_tree = et.parse(io.BytesIO('<a><b></b></a>'))
|
||||
valid_tree = et.parse(io.BytesIO(b'<a><b></b></a>'))
|
||||
|
||||
schema = etree.XMLSchema(schema_raw)
|
||||
schema = et.XMLSchema(schema_raw)
|
||||
schame.validate(valid_tree)
|
||||
except et.LxmlError:
|
||||
None
|
||||
|
|
|
@ -25,9 +25,9 @@ def TestOneInput(data):
|
|||
"""Targets XSLT. More APIs on the st object should be added"""
|
||||
try:
|
||||
style = et.parse(io.BytesIO(data))
|
||||
valid_tree = et.parse(io.BytesIO('<a><b>B</b><c>C</c></a>'))
|
||||
valid_tree = et.parse(io.BytesIO(b'<a><b>B</b><c>C</c></a>'))
|
||||
|
||||
st = etree.XSLT(style)
|
||||
st = et.XSLT(style)
|
||||
res = st(valid_tree)
|
||||
except et.LxmlError:
|
||||
None
|
||||
|
|
Loading…
Reference in New Issue