aboutsummaryrefslogtreecommitdiff
path: root/projects/mruby
diff options
context:
space:
mode:
authorBhargava Shastry <bshas3@gmail.com>2019-05-13 19:40:35 +0200
committerjonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>2019-05-13 10:40:34 -0700
commit8017ffc384ea91d0eed5644458db2bccd660617d (patch)
treeea71f047de2ef778d314b5c75f44169a04675279 /projects/mruby
parent4a9941d9c490c5f9c368fd375802243408e26550 (diff)
downloadoss-fuzz-8017ffc384ea91d0eed5644458db2bccd660617d.tar.gz
[mruby] Add mruby compile fuzzer (#2380)
Diffstat (limited to 'projects/mruby')
-rw-r--r--projects/mruby/Dockerfile23
-rwxr-xr-xprojects/mruby/build.sh38
-rw-r--r--projects/mruby/project.yaml8
3 files changed, 69 insertions, 0 deletions
diff --git a/projects/mruby/Dockerfile b/projects/mruby/Dockerfile
new file mode 100644
index 000000000..0839edb3f
--- /dev/null
+++ b/projects/mruby/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
+RUN apt-get update && apt-get install -y make autoconf automake libtool ruby \
+ bison
+RUN git clone --depth 1 https://github.com/mruby/mruby mruby
+RUN git clone --depth 1 https://github.com/bshastry/mruby_seeds.git mruby_seeds
+COPY build.sh $SRC
+WORKDIR mruby
diff --git a/projects/mruby/build.sh b/projects/mruby/build.sh
new file mode 100755
index 000000000..c254be263
--- /dev/null
+++ b/projects/mruby/build.sh
@@ -0,0 +1,38 @@
+#!/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.
+#
+################################################################################
+
+# build project
+export LD=clang
+export LDFLAGS="$CFLAGS"
+./minirake clean && ./minirake -j$(nproc) all
+
+# build fuzzers
+FUZZ_TARGET=$SRC/mruby/oss-fuzz/mruby_fuzzer.c
+name=$(basename $FUZZ_TARGET .c)
+$CC -c $CFLAGS -Iinclude \
+ ${FUZZ_TARGET} -o $OUT/${name}.o
+$CXX $CXXFLAGS $OUT/${name}.o $LIB_FUZZING_ENGINE -lm \
+ $SRC/mruby/build/host/lib/libmruby.a -o $OUT/${name}
+rm -f $OUT/${name}.o
+
+# dict and config
+cp $SRC/mruby/oss-fuzz/config/mruby.dict $OUT
+cp $SRC/mruby/oss-fuzz/config/mruby_fuzzer.options $OUT
+
+# seeds
+find $SRC/mruby_seeds -exec zip -ujq \
+ $OUT/mruby_fuzzer_seed_corpus.zip "{}" \;
diff --git a/projects/mruby/project.yaml b/projects/mruby/project.yaml
new file mode 100644
index 000000000..3a717909a
--- /dev/null
+++ b/projects/mruby/project.yaml
@@ -0,0 +1,8 @@
+homepage: https://www.mruby.org/
+primary_contact: matz@ruby.or.jp
+auto_ccs:
+ - "bshas3@gmail.com"
+sanitizers:
+ - address
+ - memory
+ - undefined