oss-fuzz/infra/base-images/base-builder
DavidKorczynski 51e01dcebc
infra: add script to capture replayable commands (#12608)
Giving
https://github.com/google/oss-fuzz/pull/12592#issuecomment-2415803665 a
go using `bashlex`

Will place a script in `/out/replay-build-script.sh` with the script
that can be used for replaying.

This is still poc and will need some adjustments, e.g. we need some more
handling on the bash script's ast to reason about loops.

---------

Signed-off-by: David Korczynski <david@adalogics.com>
Co-authored-by: Oliver Chang <ochang@google.com>
2024-11-06 13:00:19 +11:00
..
jcc Remove flags that may escalate warnings to errors (#12116) 2024-06-26 10:44:17 +10:00
sanitizers/pysecsan Log errors when no targets are specified for `download_corpora` (#10014) 2023-04-03 06:01:59 +00:00
test_data
Dockerfile infra: add script to capture replayable commands (#12608) 2024-11-06 13:00:19 +11:00
README.md
bash_parser.py infra: add script to capture replayable commands (#12608) 2024-11-06 13:00:19 +11:00
bazel.bazelrc Get rid of :introspector images. Build introspector in main images (#8868) 2022-10-27 08:27:12 -04:00
bazel_build_fuzz_tests infra: bazel_build_fuzz_tests: avoid change of OUT ownership (#12414) 2024-08-28 16:02:21 +01:00
bisect_clang.py
bisect_clang_test.py
cargo rust coverage: broader definition for remaps (#6595) 2021-10-19 15:50:08 -05:00
compile infra: add script to capture replayable commands (#12608) 2024-11-06 13:00:19 +11:00
compile_afl switch to AFL++'s new pcguard instrumentation (#10427) 2023-06-14 16:02:42 -04:00
compile_centipede Revert "Update Centipede" (#12160) 2024-07-04 16:37:37 +01:00
compile_fuzztests.sh infra: enable fuzztest compile script to build non-fuzztest fuzzers (#9733) 2023-02-20 01:37:52 -08:00
compile_go_fuzzer infra: have timeout per fuzz target for coverage (#7831) 2022-07-07 17:00:39 +02:00
compile_honggfuzz infra: add support for netdriver fuzzing with honggfuzz (#7351) 2022-09-12 11:58:12 +10:00
compile_javascript_fuzzer Do not install Jazzer.js in the compile_javascript_fuzzer script (#10381) 2023-05-30 17:08:41 +10:00
compile_libfuzzer infra: Roll OUR_LLVM_REVISION (#11714) 2024-04-30 09:29:51 +10:00
compile_native_go_fuzzer Fix broken Go coverage reports (#10948) 2023-09-13 14:04:44 -04:00
compile_python_fuzzer pysecsan: refine and add as option in compile_python_fuzzer (#9169) 2023-03-08 12:10:01 -08:00
debug_afl
detect_repo.py
detect_repo_test.py
install_deps.sh Don't install git via ppa (#8470) 2022-09-13 08:37:38 +01:00
install_go.sh Upgrade to Go 1.22 (#11677) 2024-05-06 12:56:20 -04:00
install_java.sh Jazzer Pro (#12375) 2024-08-27 10:57:51 +10:00
install_javascript.sh Update Node.js setup for JavaScript projects (#10941) 2023-09-12 18:09:41 -04:00
install_python.sh infra: Upgrade setuptools to version explicitly required by pyinstaller (#11743) 2024-05-02 11:01:22 -04:00
install_ruby.sh Adding Ruby Support into OSS-Fuzz via Ruzzy (#12034) 2024-07-02 08:33:01 -04:00
install_rust.sh Add `--locked` to installation of `cargo fuzz` (#12178) 2024-07-11 12:43:46 +10:00
install_swift.sh infra: update swift to 5.8.1 (#10922) 2023-09-13 14:05:34 -04:00
llvmsymbol.diff
ossfuzz_coverage_runner.go
precompile_afl
precompile_centipede Revert "Update Centipede" (#12160) 2024-07-04 16:37:37 +01:00
precompile_honggfuzz
python_coverage_helper.py infra: enable argument passing to compile_python_fuzzer (#7628) 2022-04-28 09:38:43 +01:00
srcmap
write_labels.py handle wildcard label applying to all fuzz targets in a project (#7359) 2022-03-04 14:59:08 +11:00

README.md

base-builder

Abstract 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