aboutsummaryrefslogtreecommitdiff
path: root/projects/nanopb
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@github.mail.kapsi.fi>2019-12-18 16:32:17 +0200
committerjonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>2019-12-18 06:32:17 -0800
commitacaffc79a889dad0cae205469f5bf30215c3f269 (patch)
tree77b9940cd350a7817317187ca51cdf856c8b9b63 /projects/nanopb
parent298335473338052a0f0b90c0de2b28dfab3aaebe (diff)
downloadoss-fuzz-acaffc79a889dad0cae205469f5bf30215c3f269.tar.gz
[nanopb] Added nanopb project (#3149)
Diffstat (limited to 'projects/nanopb')
-rw-r--r--projects/nanopb/Dockerfile23
-rwxr-xr-xprojects/nanopb/build.sh46
-rw-r--r--projects/nanopb/project.yaml7
3 files changed, 76 insertions, 0 deletions
diff --git a/projects/nanopb/Dockerfile b/projects/nanopb/Dockerfile
new file mode 100644
index 000000000..5ddb2ffaf
--- /dev/null
+++ b/projects/nanopb/Dockerfile
@@ -0,0 +1,23 @@
+# Copyright 2019 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 jpa@npb.mail.kapsi.fi
+RUN apt-get update && apt-get install -y python-pip git scons
+RUN pip install protobuf grpcio-tools
+RUN git clone --depth 1 https://github.com/nanopb/nanopb $SRC/nanopb
+COPY build.sh $SRC/
+
diff --git a/projects/nanopb/build.sh b/projects/nanopb/build.sh
new file mode 100755
index 000000000..f9fc81cd3
--- /dev/null
+++ b/projects/nanopb/build.sh
@@ -0,0 +1,46 @@
+#!/bin/bash -eu
+# Copyright 2019 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.
+#
+################################################################################
+
+cd $SRC/nanopb/tests
+
+# Build seed corpus.
+# Generating it here ensures it will contain all of the fields in the AllTypes
+# test case. The generators are built without fuzzing instrumentation.
+rm -rf build
+scons build/alltypes/encode_alltypes build/fuzztest/generate_message
+mkdir fuzztest_seed_corpus
+build/alltypes/encode_alltypes 0 > fuzztest_seed_corpus/alltypes0
+build/alltypes/encode_alltypes 1 > fuzztest_seed_corpus/alltypes1
+build/alltypes/encode_alltypes 2 > fuzztest_seed_corpus/alltypes2
+build/fuzztest/generate_message $(date +%s) > fuzztest_seed_corpus/rndmsg 2>/dev/null
+for f in fuzztest_seed_corpus/*; do
+ mv $f fuzztest_seed_corpus/$(sha1sum $f | cut -f 1 -d ' ')
+done
+zip -r "$OUT/fuzztest_seed_corpus.zip" fuzztest_seed_corpus
+
+# Build the fuzz testing stub with instrumentation
+rm -rf build
+scons CC="$CC" CXX="$CXX" LINK="$CXX" \
+ CCFLAGS="-Wall -Wextra -g -DLLVMFUZZER $CFLAGS" \
+ CXXFLAGS="-Wall -Wextra -g -DLLVMFUZZER $CXXFLAGS" \
+ NODEFARGS="1" \
+ LINKFLAGS="-std=c++11 $CXXFLAGS" \
+ LINKLIBS="$LIB_FUZZING_ENGINE" build/fuzztest/fuzztest
+
+cp build/fuzztest/fuzztest "$OUT/fuzztest"
+
+
diff --git a/projects/nanopb/project.yaml b/projects/nanopb/project.yaml
new file mode 100644
index 000000000..53aab2e2a
--- /dev/null
+++ b/projects/nanopb/project.yaml
@@ -0,0 +1,7 @@
+homepage: "https://jpa.kapsi.fi/nanopb/"
+primary_contact: "jpa@npb.mail.kapsi.fi"
+sanitizers:
+ - address
+ - memory
+ - undefined
+