From a93638ce029697eb731d99d0f2b0be9413515e85 Mon Sep 17 00:00:00 2001 From: SGills <5122866+sg3-141-592@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:27:05 +0000 Subject: [PATCH] Improving urllib3 utils coverage (#9631) This is an improvement to the urllib3 utils functions fuzzing. This is my first attempt at contributing to oss-fuzz so feedback appreciated on whether this custom mutator approach is ok. - `parse_url` function We now have a custom mutator that drives more url like structures. I originally developed this using Hypothesis, but the quality of fuzzing wasn't good (seems to be a known issue https://github.com/google/atheris/issues/20). Because of this I've used a 3rd party library `exrex` that can generate test data from regular expressions. --- projects/urllib3/fuzz_urlparse.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/urllib3/fuzz_urlparse.py b/projects/urllib3/fuzz_urlparse.py index 81c016453..ef7631bef 100644 --- a/projects/urllib3/fuzz_urlparse.py +++ b/projects/urllib3/fuzz_urlparse.py @@ -23,7 +23,12 @@ def TestOneInput(data): original = fdp.ConsumeUnicode(sys.maxsize) try: - urllib3.util.parse_url(original) + response = urllib3.util.parse_url(original) + response.hostname + response.request_uri + response.authority + response.netloc + response.url except urllib3.exceptions.LocationParseError: None return