oss-fuzz/projects/example/my-api-repo/README.md

30 lines
2.4 KiB
Markdown
Raw Normal View History

2019-08-07 14:37:16 +00:00
Example of [OSS-Fuzz ideal integration](https://google.github.io/oss-fuzz/advanced-topics/ideal-integration/).
2017-05-13 20:24:17 +00:00
2019-08-07 14:37:16 +00:00
This directory contains an example software project that has most of the traits of [ideal](https://google.github.io/oss-fuzz/advanced-topics/ideal-integration/) support for fuzzing.
2017-05-14 00:38:56 +00:00
2017-05-15 22:22:14 +00:00
## Files in my-api-repo
Imagine that these files reside in your project's repository:
2017-05-16 01:43:49 +00:00
* [my_api.h](my_api.h): and [my_api.cpp](my_api.cpp) implement the API we want to test/fuzz. The function `DoStuff()` inside [my_api.cpp](my_api.cpp) contains a bug. (Find it!)
* [do_stuff_unittest.cpp](do_stuff_unittest.cpp): is a unit test for `DoStuff()`. Unit tests are not necessary for fuzzing but are generally a good practice.
2017-05-16 00:47:13 +00:00
* [do_stuff_fuzzer.cpp](do_stuff_fuzzer.cpp): is a [fuzz target](http://libfuzzer.info/#fuzz-target) for `DoStuff()`.
* [do_stuff_test_data](do_stuff_test_data): corpus directory for [do_stuff_fuzzer.cpp](do_stuff_fuzzer.cpp).
2019-08-07 14:37:16 +00:00
* [do_stuff_fuzzer.dict](do_stuff_fuzzer.dict): a [fuzzing dictionary file](https://google.github.io/oss-fuzz/getting-started/new-project-guide#dictionaries) for `DoStuff()`. Optional, but may improve fuzzing in many cases.
2017-05-16 00:47:13 +00:00
* [Makefile](Makefile): is a build file (the same can be done with other build systems):
2017-05-15 22:10:30 +00:00
* accepts external compiler flags via `$CC`, `$CXX`, `$CFLAGS`, `$CXXFLAGS`
2017-06-01 15:44:52 +00:00
* accepts external fuzzing engine via `$LIB_FUZZING_ENGINE`, by default uses [standalone_fuzz_target_runner.cpp](standalone_fuzz_target_runner.cpp)
2017-05-15 22:10:30 +00:00
* builds the fuzz target(s) and their corpus archive(s)
2017-05-15 22:13:33 +00:00
* `make check` executes [do_stuff_fuzzer.cpp](do_stuff_fuzzer.cpp) on [`do_stuff_test_data/*`](do_stuff_test_data), thus ensures that the fuzz target is up to date and uses it as a regression test.
* [standalone_fuzz_target_runner.cpp](standalone_fuzz_target_runner.cpp): is a simple standalone runner for fuzz targets. You may use it to execute a fuzz target on given files w/o having to link in libFuzzer or other fuzzing engine.
2017-05-15 22:10:30 +00:00
2017-05-16 01:43:27 +00:00
## Files in OSS-Fuzz repository
2017-05-15 22:22:14 +00:00
* [oss-fuzz/projects/example](..)
* [Dockerfile](../Dockerfile): sets up the build environment
* [build.sh](../build.sh): builds the fuzz target(s). The smaller this file the better (most of the logic should be inside the project's build system).
2017-05-15 22:22:14 +00:00
* [project.yaml](../project.yaml): short project description and contact info.
2017-05-15 22:10:30 +00:00
2017-05-15 22:22:14 +00:00
## Example bug
2017-05-15 22:10:30 +00:00
Example bug report filed automatically: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1562
2017-05-15 22:22:14 +00:00