2016-12-29 21:39:41 +00:00
# base-builder
2020-02-06 19:11:24 +00:00
> Abstract base image for project builders.
2016-10-07 18:34:42 +00:00
2016-11-30 16:26:02 +00:00
Every project image supports multiple commands that can be invoked through docker after the image is built:
2016-10-26 15:28:38 +00:00
2016-11-22 20:02:26 +00:00
< pre >
2017-03-16 02:10:01 +00:00
docker run --rm -ti gcr.io/oss-fuzz/< b > < i > $project< / i > < / b > < i > < command> < / i > < i > < arguments...> < / i >
2016-11-22 20:02:26 +00:00
< / pre >
2016-11-29 19:22:48 +00:00
2016-11-11 23:25:37 +00:00
# Supported Commands
2016-10-07 18:34:42 +00:00
2016-10-26 15:28:38 +00:00
| Command | Description |
|---------|-------------|
2016-11-30 16:26:02 +00:00
| `compile` (default) | build all fuzz targets
2016-10-26 15:28:38 +00:00
| `/bin/bash` | drop into shell, execute `compile` script to start build.
2016-10-07 18:34:42 +00:00
2016-12-02 18:58:51 +00:00
# Build Configuration
2016-12-29 21:39:41 +00:00
A single build image can build same set of fuzzers in many configurations.
The configuration is picked through one or more environment variables.
2016-12-22 18:48:28 +00:00
2016-12-02 18:58:51 +00:00
| Env Variable | Description
| ------------- | --------
2017-02-03 02:48:11 +00:00
| `$SANITIZER ("address")` | Specifies predefined sanitizer configuration to use. `address` or `memory` or `undefined` .
2016-12-05 17:44:57 +00:00
| `$SANITIZER_FLAGS` | Specify compiler sanitizer flags directly. Overrides `$SANITIZER` .
2016-12-13 18:37:03 +00:00
| `$COVERAGE_FLAGS` | Specify compiler flags to use for fuzzer feedback coverage.
2016-12-21 23:01:44 +00:00
| `$BUILD_UID` | User id to use while building fuzzers.
2016-12-02 18:58:51 +00:00
2016-12-22 18:48:28 +00:00
## Examples
2016-12-02 18:58:51 +00:00
- *building sqlite3 fuzzer with UBSan (`SANITIZER=undefined`):*
2017-12-22 17:09:40 +00:00
< pre >
2017-03-16 02:10:01 +00:00
docker run --rm -ti -e < i > SANITIZER< / i > =< i > undefined< / i > gcr.io/oss-fuzz/sqlite3
2017-12-22 17:09:40 +00:00
< / pre >
2016-12-02 18:58:51 +00:00
2016-10-13 21:02:19 +00:00
# Image Files Layout
2016-12-02 19:02:18 +00:00
| Location|Env| Description |
2016-12-02 19:02:02 +00:00
|---------| -------- | ---------- |
| `/out/` | `$OUT` | Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives). |
| `/src/` | `$SRC` | Directory to checkout source files |
| `/work/` | `$WORK` | Directory for storing intermediate files |
2020-02-06 19:11:24 +00:00
| `/usr/lib/libFuzzingEngine.a` | `$LIB_FUZZING_ENGINE` | Location of prebuilt fuzzing engine library (e.g. libFuzzer) that needs to be linked with all fuzz targets.
2016-10-13 21:02:19 +00:00
2016-12-07 19:41:08 +00:00
While files layout is fixed within a container, the environment variables are
2016-11-18 19:16:38 +00:00
provided to be able to write retargetable scripts.
## Compiler Flags
2016-10-13 21:02:19 +00:00
2016-11-30 16:26:02 +00:00
You *must* use special compiler flags to build your project and fuzz targets.
2016-10-13 21:02:19 +00:00
These flags are provided in following environment variables:
| Env Variable | Description
| ------------- | --------
| `$CC` | The C compiler binary.
| `$CXX` , `$CCC` | The C++ compiler binary.
| `$CFLAGS` | C compiler flags.
| `$CXXFLAGS` | C++ compiler flags.
2016-11-30 16:26:02 +00:00
Most well-crafted build scripts will automatically use these variables. If not,
pass them manually to the build tool.
2016-10-13 21:02:19 +00:00
2016-11-18 19:16:38 +00:00
2016-10-07 18:34:42 +00:00
# Child Image Interface
2016-10-18 22:37:23 +00:00
## Sources
2016-10-07 18:34:42 +00:00
2016-11-30 16:26:02 +00:00
Child image has to checkout all sources that it needs to compile fuzz targets into
2016-12-07 19:35:53 +00:00
`$SRC` directory. When the image is executed, a directory could be mounted on top
2016-11-30 16:26:02 +00:00
of these with local checkouts using
2016-11-29 19:22:48 +00:00
`docker run -v $HOME/my_project:/src/my_project ...` .
2016-10-07 18:34:42 +00:00
2016-10-18 22:37:23 +00:00
## Other Required Files
2016-10-10 20:21:45 +00:00
2016-10-18 22:37:23 +00:00
Following files have to be added by child images:
2016-10-10 20:21:45 +00:00
2016-10-18 22:37:23 +00:00
| File Location | Description |
| ------------- | ----------- |
2016-11-30 16:26:02 +00:00
| `$SRC/build.sh` | build script to build the project and its fuzz targets |