• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15################################################################################
16
17# Build rust stuff in its own image. We only need the resulting binaries.
18# Keeping the rust toolchain in the image wastes 1 GB.
19FROM gcr.io/oss-fuzz-base/base-image as temp-runner-binary-builder
20
21RUN apt-get update && apt-get install -y cargo
22RUN cargo install rustfilt
23
24# Using multi-stage build to copy some LLVM binaries needed in the runner image.
25FROM gcr.io/oss-fuzz-base/base-clang AS base-clang
26
27# Real image that will be used later.
28FROM gcr.io/oss-fuzz-base/base-image
29
30COPY --from=temp-runner-binary-builder /root/.cargo/bin/rustfilt /usr/local/bin
31
32# Copy the binaries needed for code coverage and crash symbolization.
33COPY --from=base-clang /usr/local/bin/llvm-cov \
34     /usr/local/bin/llvm-profdata \
35     /usr/local/bin/llvm-symbolizer \
36     /usr/local/bin/
37
38RUN apt-get update && apt-get install -y \
39    binutils \
40    file \
41    fonts-dejavu \
42    git \
43    lib32gcc1 \
44    libc6-i386 \
45    libcap2 \
46    python3 \
47    python3-pip \
48    unzip \
49    wget \
50    zip --no-install-recommends
51
52RUN git clone https://chromium.googlesource.com/chromium/src/tools/code_coverage /opt/code_coverage && \
53    pip3 install -r /opt/code_coverage/requirements.txt
54
55# Default environment options for various sanitizers.
56# Note that these match the settings used in ClusterFuzz and
57# shouldn't be changed unless a corresponding change is made on
58# ClusterFuzz side as well.
59ENV ASAN_OPTIONS="alloc_dealloc_mismatch=0:allocator_may_return_null=1:allocator_release_to_os_interval_ms=500:check_malloc_usable_size=0:detect_container_overflow=1:detect_odr_violation=0:detect_leaks=1:detect_stack_use_after_return=1:fast_unwind_on_fatal=0:handle_abort=1:handle_segv=1:handle_sigill=1:max_uar_stack_size_log=16:print_scariness=1:quarantine_size_mb=10:strict_memcmp=1:strip_path_prefix=/workspace/:symbolize=1:use_sigaltstack=1:dedup_token_length=3"
60ENV MSAN_OPTIONS="print_stats=1:strip_path_prefix=/workspace/:symbolize=1:dedup_token_length=3"
61ENV UBSAN_OPTIONS="print_stacktrace=1:print_summary=1:silence_unsigned_overflow=1:strip_path_prefix=/workspace/:symbolize=1:dedup_token_length=3"
62ENV FUZZER_ARGS="-rss_limit_mb=2560 -timeout=25"
63ENV AFL_FUZZER_ARGS="-m none"
64
65# Download and install the latest stable Go.
66ADD https://storage.googleapis.com/golang/getgo/installer_linux $SRC/
67RUN chmod +x $SRC/installer_linux && \
68    SHELL="bash" $SRC/installer_linux && \
69    rm $SRC/installer_linux
70
71# Set up Golang environment variables (copied from /root/.bash_profile).
72ENV GOPATH /root/go
73
74# /root/.go/bin is for the standard Go binaries (i.e. go, gofmt, etc).
75# $GOPATH/bin is for the binaries from the dependencies installed via "go get".
76ENV PATH $PATH:/root/.go/bin:$GOPATH/bin
77
78# Set up Golang coverage modules.
79COPY gocoverage $GOPATH/gocoverage
80RUN cd $GOPATH/gocoverage && go install ./...
81
82# Install OpenJDK 15 and trim its size by removing unused components.
83ENV JAVA_HOME=/usr/lib/jvm/java-15-openjdk-amd64
84ENV JVM_LD_LIBRARY_PATH=$JAVA_HOME/lib/server
85ENV PATH=$PATH:$JAVA_HOME/bin
86
87RUN wget https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk-15.0.2_linux-x64_bin.tar.gz && \
88    cd /tmp && \
89    mkdir -p $JAVA_HOME && \
90    tar -xzv --strip-components=1 -f openjdk-15.0.2_linux-x64_bin.tar.gz --directory $JAVA_HOME && \
91    rm -f openjdk-15.0.2_linux-x64_bin.tar.gz && \
92    rm -rf $JAVA_HOME/jmods $JAVA_HOME/lib/src.zip
93
94# Do this last to make developing these files easier/faster due to caching.
95COPY bad_build_check \
96    collect_dft \
97    coverage \
98    coverage_helper \
99    dataflow_tracer.py \
100    download_corpus \
101    rcfilt \
102    reproduce \
103    run_fuzzer \
104    parse_options.py \
105    targets_list \
106    test_all.py \
107    test_one.py \
108    /usr/local/bin/
109