[infra] extracting base-runner image

This commit is contained in:
Mike Aizatsky 2016-11-18 14:53:09 -08:00
parent 26630f32cb
commit 01364bf2b7
6 changed files with 131 additions and 10 deletions

View File

@ -21,15 +21,21 @@ def dockerOptions="--no-cache"
node {
git url: 'https://github.com/google/oss-fuzz/'
stage name: 'ossfuzz/base', concurrency: 1
sh "docker build $dockerOptions --pull -t ossfuzz/base infra/base-images/base"
stage name: 'ossfuzz/base-clang', concurrency: 1
sh "docker build $dockerOptions -t ossfuzz/base-clang infra/base-images/base-clang"
stage name: 'ossfuzz/base-libfuzzer', concurrency: 1
sh "docker build $dockerOptions -t ossfuzz/base-libfuzzer infra/base-images/base-libfuzzer"
dir ("infra/base-images") {
stage name: 'ossfuzz/base', concurrency: 1
sh "docker build $dockerOptions --pull -t ossfuzz/base base"
stage name: 'ossfuzz/libfuzzer-runner', concurrency: 1
sh "docker build $dockerOptions -t ossfuzz/libfuzzer-runner infra/base-images/libfuzzer-runner"
stage name: 'ossfuzz/base-clang', concurrency: 1
sh "docker build $dockerOptions -t ossfuzz/base-clang base-clang"
stage name: 'ossfuzz/base-libfuzzer', concurrency: 1
sh "docker build $dockerOptions -t ossfuzz/base-libfuzzer base-libfuzzer"
stage name: 'ossfuzz/base-runner', concurrency: 1
sh "docker build $dockerOptions -t ossfuzz/base-runner base-runner"
stage name: 'ossfuzz/libfuzzer-runner', concurrency: 1
sh "docker build $dockerOptions -t ossfuzz/libfuzzer-runner libfuzzer-runner"
}
}

View File

@ -18,4 +18,5 @@
docker build --pull -t ossfuzz/base $@ infra/base-images/base
docker build -t ossfuzz/base-clang $@ infra/base-images/base-clang
docker build -t ossfuzz/base-libfuzzer $@ infra/base-images/base-libfuzzer
docker build -t ossfuzz/base-runner $@ infra/base-images/base-runner
docker build -t ossfuzz/libfuzzer-runner $@ infra/base-images/libfuzzer-runner

View File

@ -0,0 +1,20 @@
# 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.
#
################################################################################
FROM ossfuzz/base
MAINTAINER mike.aizatsky@gmail.com
COPY test_all run_fuzzer /usr/local/bin/

View File

@ -0,0 +1,41 @@
#!/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. Appends .options arguments and seed corpus to users args.
# Usage: $0 <fuzzer_name> <fuzzer_args>
cd $OUT
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
SEED_CORPUS="${FUZZER}_seed_corpus.zip"
if [ -f $SEED_CORPUS ]; then
rm -rf /tmp/seed_corpus/ && mkdir /tmp/seed_corpus/
unzip -d /tmp/seed_corpus/ $SEED_CORPUS
CMD_LINE="$CMD_LINE /tmp/seed_corpus/"
fi
echo $CMD_LINE
bash -c "$CMD_LINE"

View File

@ -0,0 +1,53 @@
#!/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.
#
################################################################################
# Test fuzzers
REPORT_DIR="/junit_reports"
mkdir -p $REPORT_DIR
set -o pipefail
N=0
for FUZZER_BINARY in $(find $OUT/ -executable -type f); do
FUZZER=$(basename $FUZZER_BINARY)
echo "testing $FUZZER"
out=$(tempfile)
run_fuzzer $FUZZER -runs=32 | tee $out
N=$[$N+1]
REPORT_TEXT=$(cat <<-EOF
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="$FUZZER" tests="1" skipped="0" failures="0" errors="0" timestamp="2016-10-25T02:57:01" hostname="box678.localdomain" time="1">
<properties/>
<testcase name="$FUZZER" classname="$FUZZER" time="1"/>
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
EOF
)
echo $REPORT_TEXT > /junit_reports/$FUZZER.xml
done
if [ "$N" -eq "0" ]; then
echo "ERROR: no fuzzers found in $OUT/"
ls -al $OUT
exit 1
fi
echo "$N fuzzers total"

View File

@ -17,7 +17,7 @@
// Jenkins build script to push docker images to docker repository.
def images = ['ossfuzz/base', 'ossfuzz/base-clang', 'ossfuzz/base-libfuzzer',
'ossfuzz/libfuzzer-runner']
'ossfuzz/base-runner', 'ossfuzz/libfuzzer-runner']
node() {
docker.withRegistry('', 'docker-login') {