Skip to content

Commit

Permalink
lxml: refine and fix fuzzers (google#7655)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidKorczynski authored May 2, 2022
1 parent bcf7972 commit d28259d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions projects/lxml/fuzz_schematron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions projects/lxml/fuzz_xmlschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions projects/lxml/fuzz_xslt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d28259d

Please sign in to comment.