提交 d052fd64 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

fuzzer: simplify Docker stuff

上级 86f353f3
...@@ -52,23 +52,17 @@ Builds the `mediasoup-worker-fuzzer` target (which uses [libFuzzer](http://llvm. ...@@ -52,23 +52,17 @@ Builds the `mediasoup-worker-fuzzer` target (which uses [libFuzzer](http://llvm.
**NOTE:** Linux is required with `fuzzer` capable `clang++`. `CC` environment variable must point to `clang` and `CXX` to `clang++`. **NOTE:** Linux is required with `fuzzer` capable `clang++`. `CC` environment variable must point to `clang` and `CXX` to `clang++`.
It's recommended to pass the following fuzzer options:
### `fuzzer-run` * `-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.
Executes the `worker/out/mediasoup-worker-fuzzer` binary. 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.
* Set `FUZZER_OPTIONS` environment variable to set Fuzzer command line options.
* Set `FUZZER_CORPUS_DIRS` environment variable to set Fuzzer corpus directories.
* Set `LSAN_OPTIONS` environment variable for LSAN options.
It's recommended to set `fuzzer/new-corpus` as first entry in `FUZZER_CORPUS_DIRS` so generated inputs are written there.
Crash reports will be written in the `worker/fuzzer/reports` directory (hardcoded `-artifact_prefix=./fuzzer/reports/` fuzzer option).
Example: Example:
```bash ```bash
$ FUZZER_OPTIONS="-max_len=1800" FUZZER_CORPUS_DIRS="fuzzer/new-corpus fuzzer/corpora/rtp-corpus" make fuzzer-run $ ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus fuzzer/corpora/rtp-corpus fuzzer/corpora/rtcp-corpus fuzzer/corpora/stun-corpus
``` ```
...@@ -86,17 +80,7 @@ $ ./scripts/get-dep.sh clang-fuzzer ...@@ -86,17 +80,7 @@ $ ./scripts/get-dep.sh clang-fuzzer
### `fuzzer-docker-run` ### `fuzzer-docker-run`
Runs a container of the Docker image created with `fuzzer-docker-build` and executes `worker/out/mediasoup-worker-fuzzer` binary. 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.
Some environment variables than `fuzzer-run` are supported (with same constraints). However:
* `FUZZER_CORPUS_DIRS` must be relative to the `worker`. If we want to write generated test inputs in `worker/fuzzer/new-corpus` folder, `fuzzer/new-corpus` must be the first entry in `FUZZER_CORPUS_DIRS`.
Example:
```bash
$ FUZZER_OPTIONS="-max_len=1800" FUZZER_CORPUS_DIRS="fuzzer/new-corpus fuzzer/corpora/stun-corpus fuzzer/corpora/rtp-corpus fuzzer/corpora/rtcp-corpus" make fuzzer-docker-run
```
### `make xcode` ### `make xcode`
......
...@@ -8,40 +8,17 @@ RUN \ ...@@ -8,40 +8,17 @@ RUN \
wget curl subversion screen gcc g++ cmake ninja-build golang autoconf \ wget curl subversion screen gcc g++ cmake ninja-build golang autoconf \
libtool apache2 python-dev pkg-config zlib1g-dev libgcrypt11-dev \ libtool apache2 python-dev pkg-config zlib1g-dev libgcrypt11-dev \
libgss-dev libssl-dev libxml2-dev ragel nasm libarchive-dev make \ libgss-dev libssl-dev libxml2-dev ragel nasm libarchive-dev make \
automake libdbus-1-dev libboost-dev autoconf-archive automake libdbus-1-dev libboost-dev autoconf-archive bash-completion
WORKDIR /mediasoup/worker
# Install clang 7.0.0. # Install clang 7.0.0.
COPY deps/clang-fuzzer/bin /usr/local/bin COPY deps/clang-fuzzer/bin /usr/local/bin
COPY deps/clang-fuzzer/lib/clang /usr/local/lib/clang COPY deps/clang-fuzzer/lib/clang /usr/local/lib/clang
# Copy mediasoup source code. # Make CC and CXX point to clang/clang++ installed above.
COPY src src
COPY include include
COPY deps deps
COPY scripts scripts
COPY fuzzer fuzzer
COPY Makefile Makefile
COPY mediasoup-worker.gyp mediasoup-worker.gyp
COPY common.gypi common.gypi
COPY fips.gypi fips.gypi
# Set environment variables. It's important that CC and CXX point to the
# clang/clang++ installed above.
ENV LANG="C.UTF-8" ENV LANG="C.UTF-8"
ENV CC="clang" ENV CC="clang"
ENV CXX="clang++" ENV CXX="clang++"
# Build the mediasoup-worker-fuzzer target. WORKDIR /mediasoup/worker
RUN \
set -x \
&& make fuzzer
# Eecute the mediasoup-worker-fuzzer binary. CMD ["bash"]
CMD \
set -x \
&& cd /mediasoup/worker \
&& ./out/Release/mediasoup-worker-fuzzer \
${FUZZER_OPTIONS} -artifact_prefix=/reports/ \
${FUZZER_CORPUS_DIRS}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
PYTHON ?= $(shell command -v python2 2> /dev/null || echo python) PYTHON ?= $(shell command -v python2 2> /dev/null || echo python)
.PHONY: \ .PHONY: \
default Release Debug test test-Release test-Debug fuzzer fuzzer-run fuzzer-fake \ default Release Debug test test-Release test-Debug fuzzer \
fuzzer-docker-build fuzzer-docker-run xcode clean clean-all fuzzer-docker-build fuzzer-docker-run xcode clean clean-all
default: default:
...@@ -44,18 +44,6 @@ fuzzer: ...@@ -44,18 +44,6 @@ fuzzer:
$(PYTHON) ./scripts/configure.py -R mediasoup-worker-fuzzer $(PYTHON) ./scripts/configure.py -R mediasoup-worker-fuzzer
$(MAKE) BUILDTYPE=Release -C out $(MAKE) BUILDTYPE=Release -C out
fuzzer-run:
./out/Release/mediasoup-worker-fuzzer \
${FUZZER_OPTIONS} -artifact_prefix=./fuzzer/reports/ \
${FUZZER_CORPUS_DIRS}
# Temporal: Just for making sure that fuzzer/fuzzer.cpp compiles in OSX
# (which does not have fuzzer support).
fuzzer-fake:
$(PYTHON) ./scripts/configure.py -R mediasoup-worker-fuzzer-fake
$(MAKE) BUILDTYPE=Release -C out
./out/Release/mediasoup-worker-fuzzer-fake
fuzzer-docker-build: fuzzer-docker-build:
ifeq ($(DOCKER_NO_CACHE),true) ifeq ($(DOCKER_NO_CACHE),true)
docker build -f Dockerfile.fuzzer --no-cache --tag mediasoup/fuzzer:latest . docker build -f Dockerfile.fuzzer --no-cache --tag mediasoup/fuzzer:latest .
...@@ -66,11 +54,7 @@ endif ...@@ -66,11 +54,7 @@ endif
fuzzer-docker-run: fuzzer-docker-run:
docker run \ docker run \
--init --name=mediasoupFuzzer -it --rm \ --init --name=mediasoupFuzzer -it --rm \
-v $(shell pwd)/fuzzer/new-corpus:/new-corpus \ -v $(shell pwd):/mediasoup/worker \
-v $(shell pwd)/fuzzer/reports:/reports \
-e FUZZER_OPTIONS \
-e FUZZER_CORPUS_DIRS \
-e LSAN_OPTIONS \
mediasoup/fuzzer:latest mediasoup/fuzzer:latest
xcode: xcode:
......
...@@ -327,16 +327,6 @@ ...@@ -327,16 +327,6 @@
'ldflags': [ '-fsanitize=address,fuzzer' ] 'ldflags': [ '-fsanitize=address,fuzzer' ]
}] }]
] ]
},
# Like 'mediasoup-worker-fuzzer' target but without fuzzer (to test in OSX).
{
'target_name': 'mediasoup-worker-fuzzer-fake',
'defines': [ 'MS_LOG_STD', 'MS_FUZZER_FAKE' ],
'sources':
[
# C++ source files
'fuzzer/fuzzer.cpp'
]
} }
] ]
} }
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论