From 89c53fee79bd7aabfdbc989dfab6ca4074c3acba Mon Sep 17 00:00:00 2001 From: steadmon Date: Fri, 9 Nov 2018 15:10:24 -0800 Subject: [git] Add basic config for git fuzzing. (#1938) * Add basic config for git fuzzing. * Fix CFLAGS/CXXFLAGS issue when building Git fuzzers. * Build corpora from packfiles and add libfuzzer options. --- projects/git/Dockerfile | 27 +++++++++++++++++++++++++++ projects/git/build.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ projects/git/project.yaml | 3 +++ 3 files changed, 72 insertions(+) create mode 100644 projects/git/Dockerfile create mode 100755 projects/git/build.sh create mode 100644 projects/git/project.yaml diff --git a/projects/git/Dockerfile b/projects/git/Dockerfile new file mode 100644 index 00000000..a9fa16ce --- /dev/null +++ b/projects/git/Dockerfile @@ -0,0 +1,27 @@ +# Copyright 2018 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 gcr.io/oss-fuzz-base/base-builder +MAINTAINER steadmon@google.com +RUN apt-get update && \ + apt-get install -y cvs cvsps gettext libcgi-pm-perl libcurl4-gnutls-dev \ + libdbd-sqlite3-perl liberror-perl libexpat1-dev libhttp-date-perl \ + libio-pty-perl libmailtools-perl libpcre2-dev libpcre3-dev libsvn-perl \ + libtime-modules-perl libyaml-perl libz-dev python subversion tcl unzip \ + asciidoc docbook-xsl xmlto libssl-dev zip +RUN git clone --depth 1 https://github.com/git/git git +WORKDIR git +COPY build.sh $SRC/ diff --git a/projects/git/build.sh b/projects/git/build.sh new file mode 100755 index 00000000..7e9b3d08 --- /dev/null +++ b/projects/git/build.sh @@ -0,0 +1,42 @@ +#!/bin/bash -eu +# Copyright 2018 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. +# +################################################################################ + +# build fuzzers +make -j$(nproc) CC=$CC CXX=$CXX CFLAGS="$CXXFLAGS" \ + LIB_FUZZING_ENGINE=$LIB_FUZZING_ENGINE fuzz-all + +FUZZERS="fuzz-pack-headers fuzz-pack-idx" + +# copy fuzzers +for fuzzer in $FUZZERS ; do + cp $fuzzer $OUT +done + +# build corpora from Git's own packfiles +zip -j $OUT/fuzz-pack-idx_seed_corpus.zip .git/objects/pack/*.idx +for packfile in .git/objects/pack/*.pack ; do + dd ibs=1 skip=12 if=$packfile of=$packfile.trimmed +done +zip -j $OUT/fuzz-pack-headers_seed_corpus.zip .git/objects/pack/*.pack.trimmed + +# Mute stderr +for fuzzer in $FUZZERS ; do + cat >$OUT/$fuzzer.options << EOF +[libfuzzer] +close_fd_mask = 2 +EOF +done diff --git a/projects/git/project.yaml b/projects/git/project.yaml new file mode 100644 index 00000000..d21585f9 --- /dev/null +++ b/projects/git/project.yaml @@ -0,0 +1,3 @@ +homepage: "https://git-scm.com" +primary_contact: "steadmon@google.com" +experimental: True -- cgit v1.2.3