From 8e2aa92c9ca4115afa30b395f059bf0ad0cc68ad Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Wed, 2 Nov 2016 16:06:02 -0700 Subject: [PATCH] helper.py run should use .options file It is very unfortunate, but we have to copy the file. I'll think how it is possible to restructure our images to avoid duplication. Issue #19 --- infra/base-images/libfuzzer-runner/Dockerfile | 2 +- infra/base-images/libfuzzer-runner/run_fuzzer | 31 +++++++++++++++++++ infra/helper.py | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 infra/base-images/libfuzzer-runner/run_fuzzer diff --git a/infra/base-images/libfuzzer-runner/Dockerfile b/infra/base-images/libfuzzer-runner/Dockerfile index d11efeb75..8e5fbacf0 100644 --- a/infra/base-images/libfuzzer-runner/Dockerfile +++ b/infra/base-images/libfuzzer-runner/Dockerfile @@ -17,7 +17,7 @@ FROM ossfuzz/base MAINTAINER mike.aizatsky@gmail.com RUN apt-get install -y gdb -COPY llvm-symbolizer /usr/local/bin +COPY llvm-symbolizer run_fuzzer /usr/local/bin/ ENV ASAN_OPTIONS="symbolize=1:detect_leaks=0" # set up /out dir diff --git a/infra/base-images/libfuzzer-runner/run_fuzzer b/infra/base-images/libfuzzer-runner/run_fuzzer new file mode 100755 index 000000000..ededbee48 --- /dev/null +++ b/infra/base-images/libfuzzer-runner/run_fuzzer @@ -0,0 +1,31 @@ +#!/bin/bash -eu +# Copyright 2016 Google Inc. +# +# 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. +# +################################################################################ + +# Fuzzer runner. + +FUZZER=$1 +shift +CMD_LINE="$FUZZER $@" + +OPTIONS_FILE="${FUZZER}.options" +if [ -f $OPTIONS_FILE ]; then + OPTIONS_ARGS=$(grep "=" $OPTIONS_FILE | sed 's/\(\w*\)\W*=\W*\(.*\)/-\1=\2 /g' | tr '\n' ' ') + CMD_LINE="$CMD_LINE $OPTIONS_ARGS" +fi + +echo $CMD_LINE +bash -c "$CMD_LINE" diff --git a/infra/helper.py b/infra/helper.py index 3182a1579..64fd17293 100755 --- a/infra/helper.py +++ b/infra/helper.py @@ -166,6 +166,7 @@ def run_fuzzer(run_args): 'docker', 'run', '-i', '-v', '%s:/out' % os.path.join(BUILD_DIR, 'out'), '-t', 'ossfuzz/libfuzzer-runner', + 'run_fuzzer', '/out/%s/%s' %(args.target_name, args.fuzzer_name) ] + args.fuzzer_args