@@ -48,29 +48,18 @@ Builds the `mediasoup-worker-test` test unit binary in `Debug` mode at `worker/o
...
@@ -48,29 +48,18 @@ Builds the `mediasoup-worker-test` test unit binary in `Debug` mode at `worker/o
### `fuzzer`
### `fuzzer`
Builds the `mediasoup-worker-fuzzer` target (which uses [libFuzzer](http://llvm.org/docs/LibFuzzer.html)) and generates the `worker/out/mediasoup-worker-fuzzer` binary.
Builds the `mediasoup-worker-fuzzer` target (which uses [libFuzzer](http://llvm.org/docs/LibFuzzer.html)) and generates the `worker/out/Release/mediasoup-worker-fuzzer` binary.
**NOTE:** Linux is required with `fuzzer` capable `clang++`. `CC` environment variable must point to `clang` and `CXX` to `clang++`.
* Linux is required with `fuzzer` capable `clang++`.
*`CC` environment variable must point to `clang`.
*`CXX` environment variable must point to `clang++`.
It's recommended to pass the following fuzzer options:
Read the [Fuzzer](Fuzzer.md) documentation to run the fuzzer binary.
*`-artifact_prefix=fuzzer/reports/`: To tell fuzzer store crash reports in the `fuzzer/reports` folder.
*`-max_len=1400`: We don't need much more input size.
Also, there are corpus folders in `fuzzer/corpora`. If used, it's recommended to use `fuzzer/new-corpus` as first directory, so fuzzer generated test inputs are saved in there.
For memory leak detection, set `LSAN_OPTIONS=verbosity=1:log_threads=1` environment variable.
Runs a container of the Docker image created with `fuzzer-docker-build`. It automatically executes a `bash` session in `/mediasoup/worker` volume to run `make fuzzer` and `make fuzzer-run`, etc.
Runs a container of the Docker image created with `fuzzer-docker-build`. It automatically executes a `bash` session in the `/mediasoup/worker` directory, which is a Docker volume that points to the real `mediasoup/worker` directory (so we can do `make fuzzer`, etc).
Once we have built the `mediasoup-worker-fuzzer` in a Linux environment with `fuzzer` capable `clang` (see `make fuzzer` documentation) we can execute the buffer binary at `worker/out/Release/mediasoup-worker-fuzzer`.
*NOTE:* From now on, we assume we are in the `worker` directory.
*[webrtcH4cKS ~ Lets get better at fuzzing in 2019](https://webrtchacks.com/lets-get-better-at-fuzzing-in-2019-heres-how/)
*[OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me")
## Corpus files
The `fuzzer/corpora` directory has corpus directories taken from Chromium projects. They should be use to feed fuzzer with appropriate input.
However, given how `libFuzzer` works, the first directory given as command line parameter is not just used for reading corpus files, but also to store newly generated ones. So, it's recommended to pass `fuzzer/new-corpus` as first directory. Such a directory is gitignored (for now).
## Crash reports
When the fuzzer detects an issue it generates a crash report file which contains the bytes given as input. Those files can be individually used later (instead of passing corpus directories) to the fuzzer to verify that the issue has been fixed.
The `fuzzer/reports` directory should be used to store those new crash reports. In order to use it, the following option must be given to the fuzzer executable:
```bash
`-artifact_prefix=fuzzer/reports/`
```
## Others
It's recommended to (also) pass the following options to the fuzzer:
*`-max_len=1400`: We don't need much more input size.
For memory leak detection enable the following environment variable:
*`LSAN_OPTIONS=verbosity=1:log_threads=1`
The `fuzzer/fuzzer.cpp` file reads some custom environment variables to decide which kind of checks perform:
*`MS_FUZZ_STUN=1`: Do STUN checks.
*`MS_FUZZ_RTCP=1`: Do RTCP checks.
*`MS_FUZZ_RTP=1`: Do RTP checks.
* If none of them is given, then **all** checks are enabled.