• 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    python3-setuptools \
49    unzip \
50    wget \
51    zip --no-install-recommends
52
53ENV CODE_COVERAGE_SRC=/opt/code_coverage
54RUN git clone https://chromium.googlesource.com/chromium/src/tools/code_coverage $CODE_COVERAGE_SRC && \
55    cd /opt/code_coverage && \
56    git checkout edba4873b5e8a390e977a64c522db2df18a8b27d && \
57    pip3 install wheel && \
58    pip3 install -r requirements.txt && \
59    pip3 install MarkupSafe==0.23
60
61# Default environment options for various sanitizers.
62# Note that these match the settings used in ClusterFuzz and
63# shouldn't be changed unless a corresponding change is made on
64# ClusterFuzz side as well.
65ENV 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"
66ENV MSAN_OPTIONS="print_stats=1:strip_path_prefix=/workspace/:symbolize=1:dedup_token_length=3"
67ENV UBSAN_OPTIONS="print_stacktrace=1:print_summary=1:silence_unsigned_overflow=1:strip_path_prefix=/workspace/:symbolize=1:dedup_token_length=3"
68ENV FUZZER_ARGS="-rss_limit_mb=2560 -timeout=25"
69ENV AFL_FUZZER_ARGS="-m none"
70
71# Download and install the latest stable Go.
72ADD https://storage.googleapis.com/golang/getgo/installer_linux $SRC/
73RUN chmod +x $SRC/installer_linux && \
74    SHELL="bash" $SRC/installer_linux && \
75    rm $SRC/installer_linux
76
77# Set up Golang environment variables (copied from /root/.bash_profile).
78ENV GOPATH /root/go
79
80# /root/.go/bin is for the standard Go binaries (i.e. go, gofmt, etc).
81# $GOPATH/bin is for the binaries from the dependencies installed via "go get".
82ENV PATH $PATH:/root/.go/bin:$GOPATH/bin
83
84# Set up Golang coverage modules.
85COPY gocoverage $GOPATH/gocoverage
86RUN cd $GOPATH/gocoverage && go install ./...
87
88# Install OpenJDK 15 and trim its size by removing unused components.
89ENV JAVA_HOME=/usr/lib/jvm/java-15-openjdk-amd64
90ENV JVM_LD_LIBRARY_PATH=$JAVA_HOME/lib/server
91ENV PATH=$PATH:$JAVA_HOME/bin
92
93RUN 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 && \
94    cd /tmp && \
95    mkdir -p $JAVA_HOME && \
96    tar -xzv --strip-components=1 -f openjdk-15.0.2_linux-x64_bin.tar.gz --directory $JAVA_HOME && \
97    rm -f openjdk-15.0.2_linux-x64_bin.tar.gz && \
98    rm -rf $JAVA_HOME/jmods $JAVA_HOME/lib/src.zip
99
100# Install JaCoCo for JVM coverage.
101RUN wget https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.7/org.jacoco.cli-0.8.7-nodeps.jar -O /opt/jacoco-cli.jar && \
102    wget https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.7/org.jacoco.agent-0.8.7-runtime.jar -O /opt/jacoco-agent.jar && \
103    echo "37df187b76888101ecd745282e9cd1ad4ea508d6  /opt/jacoco-agent.jar" | shasum --check && \
104    echo "c1814e7bba5fd8786224b09b43c84fd6156db690  /opt/jacoco-cli.jar" | shasum --check
105
106# Do this last to make developing these files easier/faster due to caching.
107COPY bad_build_check \
108    collect_dft \
109    coverage \
110    coverage_helper \
111    dataflow_tracer.py \
112    download_corpus \
113    jacoco_report_converter.py \
114    rcfilt \
115    reproduce \
116    run_fuzzer \
117    parse_options.py \
118    profraw_update.py \
119    targets_list \
120    test_all.py \
121    test_one.py \
122    /usr/local/bin/
123