lxml: refine and fix fuzzers (#7655)

This commit is contained in:
DavidKorczynski 2022-05-02 12:17:08 +01:00 committed by GitHub
parent bcf7972c03
commit d28259d4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -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()

View File

@ -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

View File

@ -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