2021-09-01 20:36:17 +00:00
|
|
|
# Copyright 2021 Google LLC
|
2016-07-20 21:58:10 +00:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2017-03-22 19:12:51 +00:00
|
|
|
FROM gcr.io/oss-fuzz-base/base-clang
|
2020-05-25 00:39:43 +00:00
|
|
|
|
2020-06-08 00:27:40 +00:00
|
|
|
RUN dpkg --add-architecture i386 && \
|
|
|
|
apt-get update && \
|
2020-05-25 00:39:43 +00:00
|
|
|
apt-get install -y software-properties-common && \
|
|
|
|
add-apt-repository ppa:git-core/ppa && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -y \
|
|
|
|
binutils-dev \
|
2021-01-14 22:41:34 +00:00
|
|
|
build-essential \
|
2020-05-25 00:39:43 +00:00
|
|
|
curl \
|
|
|
|
git \
|
|
|
|
jq \
|
|
|
|
libc6-dev-i386 \
|
2020-11-19 18:43:21 +00:00
|
|
|
patchelf \
|
2021-03-31 19:45:00 +00:00
|
|
|
rsync \
|
2020-05-25 00:39:43 +00:00
|
|
|
subversion \
|
|
|
|
zip
|
2016-07-20 21:58:10 +00:00
|
|
|
|
2021-01-14 23:11:59 +00:00
|
|
|
# Build and install latest Python 3 (3.8.3).
|
|
|
|
ENV PYTHON_VERSION 3.8.3
|
|
|
|
RUN export PYTHON_DEPS="\
|
|
|
|
zlib1g-dev \
|
|
|
|
libncurses5-dev \
|
|
|
|
libgdbm-dev \
|
|
|
|
libnss3-dev \
|
|
|
|
libssl-dev \
|
|
|
|
libsqlite3-dev \
|
|
|
|
libreadline-dev \
|
|
|
|
libffi-dev \
|
|
|
|
libbz2-dev \
|
|
|
|
liblzma-dev" && \
|
|
|
|
unset CFLAGS CXXFLAGS && \
|
|
|
|
apt-get install -y $PYTHON_DEPS && \
|
2021-01-21 06:18:03 +00:00
|
|
|
cd /tmp && \
|
2021-01-14 23:11:59 +00:00
|
|
|
curl -O https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz && \
|
|
|
|
tar -xvf Python-$PYTHON_VERSION.tar.xz && \
|
|
|
|
cd Python-$PYTHON_VERSION && \
|
|
|
|
./configure --enable-optimizations --enable-shared && \
|
|
|
|
make -j install && \
|
|
|
|
ldconfig && \
|
2021-01-20 13:33:01 +00:00
|
|
|
ln -s /usr/bin/python3 /usr/bin/python && \
|
2021-01-14 23:11:59 +00:00
|
|
|
cd .. && \
|
|
|
|
rm -r /tmp/Python-$PYTHON_VERSION.tar.xz /tmp/Python-$PYTHON_VERSION && \
|
2021-03-21 14:02:30 +00:00
|
|
|
rm -rf /usr/local/lib/python3.8/test && \
|
|
|
|
apt-get remove -y $PYTHON_DEPS # https://github.com/google/oss-fuzz/issues/3888
|
2021-01-14 23:11:59 +00:00
|
|
|
|
2021-09-01 20:36:17 +00:00
|
|
|
# Install six for Bazel rules.
|
2021-03-09 20:08:09 +00:00
|
|
|
RUN unset CFLAGS CXXFLAGS && pip3 install -v --no-cache-dir \
|
2021-09-01 20:36:17 +00:00
|
|
|
six==1.15.0 && rm -rf /tmp/*
|
2020-05-17 23:45:54 +00:00
|
|
|
|
2021-01-20 13:33:01 +00:00
|
|
|
# Install Bazel through Bazelisk, which automatically fetches the latest Bazel version.
|
2021-06-28 13:33:38 +00:00
|
|
|
ENV BAZELISK_VERSION 1.9.0
|
2021-01-20 13:33:01 +00:00
|
|
|
RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v$BAZELISK_VERSION/bazelisk-linux-amd64 -o /usr/local/bin/bazel && \
|
|
|
|
chmod +x /usr/local/bin/bazel
|
|
|
|
|
2016-12-13 19:07:48 +00:00
|
|
|
# Default build flags for various sanitizers.
|
2017-03-06 18:05:31 +00:00
|
|
|
ENV SANITIZER_FLAGS_address "-fsanitize=address -fsanitize-address-use-after-scope"
|
2017-10-27 21:13:11 +00:00
|
|
|
|
2018-08-07 17:04:25 +00:00
|
|
|
# Set of '-fsanitize' flags matches '-fno-sanitize-recover' + 'unsigned-integer-overflow'.
|
2019-12-13 14:48:16 +00:00
|
|
|
ENV SANITIZER_FLAGS_undefined "-fsanitize=array-bounds,bool,builtin,enum,float-divide-by-zero,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unsigned-integer-overflow,unreachable,vla-bound,vptr -fno-sanitize-recover=array-bounds,bool,builtin,enum,float-divide-by-zero,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
|
2019-04-09 14:25:14 +00:00
|
|
|
|
2017-01-03 22:10:50 +00:00
|
|
|
ENV SANITIZER_FLAGS_memory "-fsanitize=memory -fsanitize-memory-track-origins"
|
2018-08-20 17:56:51 +00:00
|
|
|
|
2019-06-12 18:08:15 +00:00
|
|
|
ENV SANITIZER_FLAGS_dataflow "-fsanitize=dataflow"
|
2019-04-09 14:25:14 +00:00
|
|
|
|
2021-03-02 17:20:40 +00:00
|
|
|
ENV SANITIZER_FLAGS_thread "-fsanitize=thread"
|
|
|
|
|
2018-10-01 13:43:21 +00:00
|
|
|
# Do not use any sanitizers in the coverage build.
|
|
|
|
ENV SANITIZER_FLAGS_coverage ""
|
2016-12-02 18:58:51 +00:00
|
|
|
|
2018-08-15 22:36:37 +00:00
|
|
|
# We use unsigned-integer-overflow as an additional coverage signal and have to
|
|
|
|
# suppress error messages. See https://github.com/google/oss-fuzz/issues/910.
|
|
|
|
ENV UBSAN_OPTIONS="silence_unsigned_overflow=1"
|
|
|
|
|
2020-03-18 20:12:58 +00:00
|
|
|
# To suppress warnings from binaries running during compilation.
|
|
|
|
ENV DFSAN_OPTIONS='warn_unimplemented=0'
|
|
|
|
|
2018-10-01 13:43:21 +00:00
|
|
|
# Default build flags for coverage feedback.
|
2017-11-14 15:32:06 +00:00
|
|
|
ENV COVERAGE_FLAGS="-fsanitize=fuzzer-no-link"
|
2016-12-13 19:07:48 +00:00
|
|
|
|
2018-10-01 13:43:21 +00:00
|
|
|
# Use '-Wno-unused-command-line-argument' to suppress "warning: -ldl: 'linker' input unused"
|
|
|
|
# messages which are treated as errors by some projects.
|
2018-10-22 14:24:42 +00:00
|
|
|
ENV COVERAGE_FLAGS_coverage "-fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument"
|
2017-10-13 22:23:44 +00:00
|
|
|
|
2019-06-12 18:08:15 +00:00
|
|
|
# Coverage isntrumentation flags for dataflow builds.
|
2020-01-16 05:40:58 +00:00
|
|
|
ENV COVERAGE_FLAGS_dataflow="-fsanitize-coverage=trace-pc-guard,pc-table,bb,trace-cmp"
|
2019-06-12 18:08:15 +00:00
|
|
|
|
2019-05-13 22:01:25 +00:00
|
|
|
# Default sanitizer, fuzzing engine and architecture to use.
|
2016-12-02 18:58:51 +00:00
|
|
|
ENV SANITIZER="address"
|
2016-12-07 06:18:45 +00:00
|
|
|
ENV FUZZING_ENGINE="libfuzzer"
|
2019-05-13 22:01:25 +00:00
|
|
|
ENV ARCHITECTURE="x86_64"
|
2016-12-02 18:58:51 +00:00
|
|
|
|
2019-04-15 17:05:02 +00:00
|
|
|
# DEPRECATED - NEW CODE SHOULD NOT USE THIS. OLD CODE SHOULD STOP. Please use
|
|
|
|
# LIB_FUZZING_ENGINE instead.
|
|
|
|
# Path to fuzzing engine library to support some old users of
|
|
|
|
# LIB_FUZZING_ENGINE.
|
|
|
|
ENV LIB_FUZZING_ENGINE_DEPRECATED="/usr/lib/libFuzzingEngine.a"
|
|
|
|
|
|
|
|
# Argument passed to compiler to link against fuzzing engine.
|
|
|
|
# Defaults to the path, but is "-fsanitize=fuzzer" in libFuzzer builds.
|
2016-12-07 06:21:06 +00:00
|
|
|
ENV LIB_FUZZING_ENGINE="/usr/lib/libFuzzingEngine.a"
|
2016-12-07 06:18:45 +00:00
|
|
|
|
2016-12-13 19:07:48 +00:00
|
|
|
# TODO: remove after tpm2 catchup.
|
2016-11-18 19:45:51 +00:00
|
|
|
ENV FUZZER_LDFLAGS ""
|
2016-08-11 22:42:21 +00:00
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
WORKDIR $SRC
|
2016-10-18 22:37:23 +00:00
|
|
|
|
2021-02-06 22:58:58 +00:00
|
|
|
# TODO: switch to -b stable once we can.
|
|
|
|
RUN git clone https://github.com/AFLplusplus/AFLplusplus.git aflplusplus && \
|
2021-01-25 17:14:11 +00:00
|
|
|
cd aflplusplus && \
|
2021-12-16 00:38:25 +00:00
|
|
|
git checkout 5525f8c9ef8bb879dadd0eb942d524827d1b0362
|
2021-01-25 17:14:11 +00:00
|
|
|
|
2021-01-21 06:18:03 +00:00
|
|
|
RUN cd $SRC && \
|
|
|
|
curl -L -O https://github.com/google/honggfuzz/archive/oss-fuzz.tar.gz && \
|
|
|
|
mkdir honggfuzz && \
|
2017-06-02 00:55:01 +00:00
|
|
|
cd honggfuzz && \
|
|
|
|
tar -xzv --strip-components=1 -f $SRC/oss-fuzz.tar.gz && \
|
2021-01-21 06:18:03 +00:00
|
|
|
rm -rf examples $SRC/oss-fuzz.tar.gz
|
2017-06-02 00:55:01 +00:00
|
|
|
|
2021-09-01 20:36:17 +00:00
|
|
|
# Do precompiles before copying other scripts for better cache efficiency.
|
|
|
|
COPY precompile_afl /usr/local/bin/
|
|
|
|
RUN precompile_afl
|
2020-01-06 20:17:26 +00:00
|
|
|
|
2021-09-01 20:36:17 +00:00
|
|
|
COPY precompile_honggfuzz /usr/local/bin/
|
2019-11-20 00:04:33 +00:00
|
|
|
RUN precompile_honggfuzz
|
2021-09-01 20:36:17 +00:00
|
|
|
|
|
|
|
COPY cargo compile compile_afl compile_dataflow compile_libfuzzer compile_honggfuzz \
|
|
|
|
compile_go_fuzzer debug_afl srcmap \
|
|
|
|
write_labels.py bazel_build_fuzz_tests \
|
|
|
|
# Go, java, and swift installation scripts.
|
|
|
|
install_go.sh \
|
|
|
|
install_java.sh \
|
|
|
|
install_python.sh \
|
|
|
|
install_rust.sh \
|
|
|
|
install_swift.sh \
|
|
|
|
/usr/local/bin/
|
|
|
|
|
|
|
|
COPY llvmsymbol.diff $SRC
|
|
|
|
COPY detect_repo.py /opt/cifuzz/
|
2017-01-05 21:27:53 +00:00
|
|
|
|
|
|
|
CMD ["compile"]
|