mirror of
https://github.com/curl/curl.git
synced 2026-08-10 15:20:54 +03:00
ossfuzz: moving towards the ideal integration
- Start with the basic code from the ossfuzz project. - Rewrite fuzz corpora to be binary files full of Type-Length-Value data, and write a glue layer in the fuzzing function to convert corpora into CURL options. - Have supporting functions to generate corpora from existing tests - Integrate with Makefile.am
This commit is contained in:
parent
222e65fd78
commit
efeb4a3176
19 changed files with 767 additions and 162 deletions
|
|
@ -24,12 +24,15 @@
|
|||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
import os
|
||||
import xml.etree.ElementTree as ET
|
||||
import re
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
REPLY_DATA = re.compile("<reply>\s*<data>(.*?)</data>", re.MULTILINE | re.DOTALL)
|
||||
|
||||
|
||||
class TestData(object):
|
||||
def __init__(self, data_folder):
|
||||
self.data_folder = data_folder
|
||||
|
|
@ -39,15 +42,17 @@ class TestData(object):
|
|||
filename = os.path.join(self.data_folder,
|
||||
"test{0}".format(test_number))
|
||||
|
||||
# The user should handle the exception from failing to find the file.
|
||||
tree = ET.parse(filename)
|
||||
log.debug("Parsing file %s", filename)
|
||||
|
||||
# We need the <reply><data> text.
|
||||
reply = tree.find("reply")
|
||||
data = reply.find("data")
|
||||
with open(filename, "rb") as f:
|
||||
contents = f.read().decode("utf-8")
|
||||
|
||||
# Return the text contents of the data
|
||||
return data.text
|
||||
m = REPLY_DATA.search(contents)
|
||||
if not m:
|
||||
raise Exception("Couldn't find a <reply><data> section")
|
||||
|
||||
# Left-strip the data so we don't get a newline before our data.
|
||||
return m.group(1).lstrip()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue