oss-fuzz/infra/base-images/base-builder-new
jonathanmetzman 17e2f96e6a
[infra] Add a script for building all base-images with "-testing" (#6248)
suffix and pushing them to gcr.io/oss-fuzz-base.

This is useful for testing changes to images.
I used it to test changes I made for #6180.
This does not support msan as that image is being removed.

Also lint.
2021-08-19 20:05:32 -07:00
..
test_data New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
Dockerfile New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
README.md New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
bazel_build_fuzz_tests New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
bisect_clang.py New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
bisect_clang_new_test.py [infra] Add a script for building all base-images with "-testing" (#6248) 2021-08-19 20:05:32 -07:00
compile New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
compile_afl New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
compile_dataflow New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
compile_honggfuzz New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
compile_libfuzzer New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
debug_afl New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
detect_repo.py New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
detect_repo_new_test.py [infra] Add a script for building all base-images with "-testing" (#6248) 2021-08-19 20:05:32 -07:00
install_swift.sh New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
llvmsymbol.diff New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
ossfuzz_coverage_runner.go New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
precompile_afl New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
precompile_honggfuzz New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
srcmap New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00
write_labels.py New base builder without lang specific installation + swift base (#5986) 2021-08-20 09:52:44 +10:00

README.md

base-builder-new

Abstract new base image for project builders.

Every project image supports multiple commands that can be invoked through docker after the image is built:

docker run --rm -ti gcr.io/oss-fuzz/$project <command> <arguments...>

Supported Commands

Command Description
compile (default) build all fuzz targets
/bin/bash drop into shell, execute compile script to start build.

Build Configuration

A single build image can build same set of fuzzers in many configurations. The configuration is picked through one or more environment variables.

Env Variable Description
$SANITIZER ("address") Specifies predefined sanitizer configuration to use. address or memory or undefined.
$SANITIZER_FLAGS Specify compiler sanitizer flags directly. Overrides $SANITIZER.
$COVERAGE_FLAGS Specify compiler flags to use for fuzzer feedback coverage.
$BUILD_UID User id to use while building fuzzers.

Examples

  • building sqlite3 fuzzer with UBSan (SANITIZER=undefined):
docker run --rm -ti -e SANITIZER=undefined gcr.io/oss-fuzz/sqlite3

Image Files Layout

Location Env Description
/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
/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.

While files layout is fixed within a container, the environment variables are provided to be able to write retargetable scripts.

Compiler Flags

You must use special compiler flags to build your project and fuzz targets. 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.

Most well-crafted build scripts will automatically use these variables. If not, pass them manually to the build tool.

Child Image Interface

Sources

Child image has to checkout all sources that it needs to compile fuzz targets into $SRC directory. When the image is executed, a directory could be mounted on top of these with local checkouts using docker run -v $HOME/my_project:/src/my_project ....

Other Required Files

Following files have to be added by child images:

File Location Description
$SRC/build.sh build script to build the project and its fuzz targets