diff options
author | DavidKorczynski <david@adalogics.com> | 2021-05-08 14:37:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-08 15:37:11 +0200 |
commit | a3741bc3d5b083e6503fc62ac45a48014c5ae6f4 (patch) | |
tree | ca9766d875704e85da59ab65a1d304f70b8353e5 | |
parent | f163e6395668e315c74489183070ce2ed3878e83 (diff) | |
download | python-lxml-a3741bc3d5b083e6503fc62ac45a48014c5ae6f4.tar.gz |
Add initial Atheris fuzzer. (GH-313)
-rw-r--r-- | src/lxml/tests/fuzz_xml_parse.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lxml/tests/fuzz_xml_parse.py b/src/lxml/tests/fuzz_xml_parse.py new file mode 100644 index 00000000..a7c3ef49 --- /dev/null +++ b/src/lxml/tests/fuzz_xml_parse.py @@ -0,0 +1,23 @@ +""" +Fuzzes the lxml.etree.XML function with the Atheris fuzzer. + +The goal is to catch unhandled exceptions and potential +memory corruption issues in auto-generated code. +""" + +import atheris +import sys + +from lxml import etree + +def test_etree_xml(data): + fdp = atheris.FuzzedDataProvider(data) + try: + root = etree.XML(fdp.ConsumeUnicode(sys.maxsize)) + except etree.XMLSyntaxError: + pass + return + +if __name__ == "__main__": + atheris.Setup(sys.argv, test_etree_xml, enable_python_coverage=True) + atheris.Fuzz() |