-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
I'm a core developer of Hypothesis, the property-based testing library for Python. Hypothesis is secretly a structured fuzzer, and in March I added support for treating arbitrary property-based tests as fuzz targets.
It would be lovely to apply this toolchain to CPython (see here, and here), write fuzzable tests for pip
, fuzz existing tests for foundational tools like Numpy/Mercurial/PyPy, and so on. The only catch is that it's unclear to me whether, and if so how, Python projects are actually supported in OSS-FUZZ!
For example, to exercise the Python JSON module with python-afl
:
import json, os, sys
import afl
from hypothesis import given, strategies as st
@given(st.recursive(
st.none() | st.booleans() | st.integers() | st.floats(allow_nan=False) | st.text(),
lambda x: st.lists(x) | st.dictionaries(st.text(), x)
))
def test_json_rountrip(x):
assert x == json.loads(json.dumps(x))
if __name__ == "__main__":
fuzz_target = test_json_rountrip.hypothesis.fuzz_one_input
afl.init()
fuzz_target(sys.stdin.buffer)
os._exit(0)
If upstream support in Hypothesis would make OSS-FUZZ integration easier, I would be very happy to add whatever interface we decide on 🙂
Metadata
Metadata
Assignees
Labels
No labels