bazel-contrib / bazel-contrib/rules_fuzzing

Implement Python support (Atheris)

Open
#162 4 comments 1 reaction 0 assignees View on GitHub
feature
Dominant language
Starlark
Stars
93
Forks
26
PR merge metrics
No merged PRs in 30d

Description

If there is interest, I could add `py_fuzz_test` backed by Atheris after the release for `java_fuzz_test` is done.

As far as I can tell, this would require the following special steps for local Python fuzzing, everything else would be mostly analogous to the integration of Jazzer:

1. Generalize the existing logic for locating `ubsan_standalone_cxx` to arbitrary sanitizer libraries and extract it into a separate repository rule.
2. Add a rule that prevents a given target from receiving fuzzing instrumentation, even if a fuzzing binary depends on it. This is needed since the native Atheris fuzzer library also contains helper functions for fuzz targets and thus will be depended on by fuzz tests, but should not be instrumented for fuzzing for optimal performance. This is a bit tricky, but can for example be achieved by a transition that undoes the fuzzing_binary_transition.
3. Produce Bazel BUILD files for Atheris. That is actually quite simple (using 1. and 2.), but requires a choice between
a) depending on clang >= 12 and
b) building libFuzzer from source.

OSS-Fuzz support for Python then requires a choice between
a) adding the CPython installation compiled in `base-builder` also to `base-runner` and
b) crafting a packaging rule for `py_binary` backed by `pyinstaller` or a similar tool that can bundle a Python target with a Python runtime (`--build_python_zip` may do the job).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.