diff options
-rw-r--r-- | projects/oak/Dockerfile | 21 | ||||
-rwxr-xr-x | projects/oak/build.sh | 65 | ||||
-rw-r--r-- | projects/oak/project.yaml | 8 | ||||
-rw-r--r-- | projects/oak/rustc.py | 28 |
4 files changed, 46 insertions, 76 deletions
diff --git a/projects/oak/Dockerfile b/projects/oak/Dockerfile index e6f44f30..d32abbe2 100644 --- a/projects/oak/Dockerfile +++ b/projects/oak/Dockerfile @@ -14,26 +14,9 @@ # ################################################################################ -# TODO(https://github.com/google/oss-fuzz/issues/3093): Stop specifying the -# image SHA once the bug is fixed. -FROM gcr.io/oss-fuzz-base/base-builder@sha256:276813aef0ce5972db43c0230f96162003994fa742fb1b2f4e66c67498575c65 - -# Use a fixed Bazel version. -# https://github.com/google/asylo/blob/088ea3490dd4579655bd5b65b0e31fe18de7f6dd/asylo/distrib/toolchain/Dockerfile#L48-L71 -ARG bazel_version=1.1.0 -ARG bazel_sha=138b47ffd54924e3c0264c65d31d3927803fb9025db4d5b18107df79ee3bda95 -ARG bazel_url=https://storage.googleapis.com/bazel-apt/pool/jdk1.8/b/bazel/bazel_${bazel_version}_amd64.deb - -# Install Bazel. -RUN apt-get update && \ - apt-get install -y wget && \ - wget "${bazel_url}" -nv -o- -O bazel.deb && \ - echo "${bazel_sha} bazel.deb" > bazel.sha256 && \ - sha256sum --check bazel.sha256 && \ - apt-get install -y ./bazel.deb && \ - rm bazel.deb bazel.sha256 && \ - apt-get clean +FROM gcr.io/oss-fuzz-base/base-builder RUN git clone --depth 1 https://github.com/project-oak/oak oak WORKDIR oak COPY build.sh $SRC/ +COPY rustc.py $SRC/ diff --git a/projects/oak/build.sh b/projects/oak/build.sh index 2e46c774..97e44f61 100755 --- a/projects/oak/build.sh +++ b/projects/oak/build.sh @@ -15,62 +15,21 @@ # ################################################################################ -# Mostly copied from -# https://github.com/google/oss-fuzz/blob/7f8013db108e62727fba1c3cbcccac07d543682b/projects/grpc/build.sh +cd oak_functions/loader/ -# Copy $CFLAGS and $CXXFLAGS into Bazel command-line flags, for both -# compilation and linking. -# -# Some flags, such as `-stdlib=libc++`, generate warnings if used on a C source -# file. Since the build runs with `-Werror` this will cause it to break, so we -# use `--conlyopt` and `--cxxopt` instead of `--copt`. -readonly EXTRA_BAZEL_FLAGS="$( -for f in ${CFLAGS}; do - echo "--conlyopt=${f}" "--linkopt=${f}" -done -for f in ${CXXFLAGS}; do - echo "--cxxopt=${f}" "--linkopt=${f}" -done -if [ "${SANITIZER}" = "undefined" ] +if [ "$SANITIZER" = "coverage" ] then - # Bazel uses clang to link binary, which does not link clang_rt ubsan library for C++ automatically. - # See issue: https://github.com/bazelbuild/bazel/issues/8777 - echo "--linkopt=$(find $(llvm-config --libdir) -name libclang_rt.ubsan_standalone_cxx-x86_64.a | head -1)" + export RUSTFLAGS="$RUSTFLAGS -C debug-assertions=no" + chmod +x $SRC/rustc.py + export RUSTC="$SRC/rustc.py" fi -)" - -# Temporary hack, see https://github.com/google/oss-fuzz/issues/383 -readonly NO_VPTR='--copt=-fno-sanitize=vptr --linkopt=-fno-sanitize=vptr' -readonly FUZZER_TARGETS=() -readonly ENABLED=false +cargo fuzz build -O -if [ "$ENABLED" = true ]; then - bazel build \ - --client_env=CC=${CC} \ - --client_env=CXX=${CXX} \ - --dynamic_mode=off \ - --spawn_strategy=standalone \ - --genrule_strategy=standalone \ - ${NO_VPTR} \ - --strip=never \ - --linkopt=-lc++ \ - --linkopt=-pthread \ - --cxxopt=-std=c++11 \ - --copt=${LIB_FUZZING_ENGINE} \ - --linkopt=${LIB_FUZZING_ENGINE} \ - --remote_cache=https://storage.googleapis.com/oak-bazel-cache \ - --remote_upload_local_results=false \ - ${EXTRA_BAZEL_FLAGS} \ - ${FUZZER_TARGETS[@]} - - for target in ${FUZZER_TARGETS}; do - # Replace : with /. - fuzzer_name="${target/:/\/}" - cp "./bazel-bin/${fuzzer_name}" "${OUT}/" - done +FUZZ_TARGET_OUTPUT_DIR=fuzz/target/x86_64-unknown-linux-gnu/release +for f in fuzz/fuzz_targets/*.rs +do + FUZZ_TARGET_NAME=$(basename ${f%.*}) + cp $FUZZ_TARGET_OUTPUT_DIR/$FUZZ_TARGET_NAME $OUT/ +done - # Cleanup bazel- symlinks to avoid oss-fuzz trying to copy out of the build - # cache. - rm -f ./bazel-* -fi diff --git a/projects/oak/project.yaml b/projects/oak/project.yaml index 3f79c7f9..84368912 100644 --- a/projects/oak/project.yaml +++ b/projects/oak/project.yaml @@ -1,15 +1,15 @@ -disabled: True homepage: "https://github.com/project-oak/oak" -language: c++ +language: rust primary_contact: "tzn@google.com" auto_ccs: - "project-oak-team@google.com" - "benblaxill@google.com" - - "drysdale@google.com" - "grobler@google.com" - "iovi@google.com" - "ivanpetrov@google.com" - - "mks@google.com" + - "razieh@google.com" +sanitizers: + - address fuzzing_engines: - libfuzzer main_repo: 'https://github.com/project-oak/oak' diff --git a/projects/oak/rustc.py b/projects/oak/rustc.py new file mode 100644 index 00000000..55ce4c40 --- /dev/null +++ b/projects/oak/rustc.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# Copyright 2021 Google LLC +# +# 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. + +import sys +import subprocess + +#Disable coverage for troubling crates. +sys.argv[0] = "rustc" +if "tokio_util" in sys.argv or "hyper" in sys.argv: + try: + sys.argv.remove("-Zinstrument-coverage") + except: + pass + print(sys.argv) +subprocess.call(sys.argv) |