aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Ari Rubinstein <arirubinstein@users.noreply.github.com>2022-06-28 05:15:15 -0700
committerGravatar GitHub <noreply@github.com>2022-06-28 13:15:15 +0100
commitf78fb0a7e1729fedc2e4b0b2d7788c810dc1a94b (patch)
tree85ff721eacfa4d4b12fac99ed904432c46119cda
parentc39384b1125237fcd92fdb35881d196892970a06 (diff)
fix: XS coverage builds, and add dictionaries and corpus seeds (#7917)
-rw-r--r--projects/xs/Dockerfile17
-rwxr-xr-xprojects/xs/build.sh34
-rw-r--r--projects/xs/target.c31
3 files changed, 52 insertions, 30 deletions
diff --git a/projects/xs/Dockerfile b/projects/xs/Dockerfile
index 4b266df2..9b7b5bf2 100644
--- a/projects/xs/Dockerfile
+++ b/projects/xs/Dockerfile
@@ -14,9 +14,20 @@
FROM gcr.io/oss-fuzz-base/base-builder
+#Apache-2.0 license
+RUN git clone --depth 1 https://github.com/dvyukov/go-fuzz-corpus && \
+ zip -q $SRC/xst_jsonparse_seed_corpus.zip go-fuzz-corpus/json/corpus/*
+
+#Apache-2.0 license
+RUN git clone --depth 1 https://github.com/google/fuzzing && \
+ cat fuzzing/dictionaries/json.dict > $SRC/xst_jsonparse.dict && \
+ cat fuzzing/dictionaries/js.dict > $SRC/xst.dict
+
+#Apache-2.0 license, MIT license, BSD license
+RUN git clone --depth 1 https://github.com/tc39/test262-parser-tests && \
+ zip -q $SRC/xst_seed_corpus.zip test262-parser-tests/pass-explicit/*
+
RUN git clone --depth=1 https://github.com/Moddable-OpenSource/moddable moddable
WORKDIR moddable
-COPY target.c $SRC/
-COPY build.sh $SRC/
-COPY xst.options $SRC/
+COPY target.c build.sh xst.options $SRC/
diff --git a/projects/xs/build.sh b/projects/xs/build.sh
index 518ac90f..60bc4804 100755
--- a/projects/xs/build.sh
+++ b/projects/xs/build.sh
@@ -13,6 +13,9 @@
#
################################################################################
+# Copy seed corpus and dictionary.
+mv $SRC/{*.zip,*.dict} $OUT
+
export MODDABLE=$PWD
export ASAN_OPTIONS="detect_leaks=0"
@@ -22,23 +25,30 @@ FUZZ_TARGETS=(
xst_jsonparse
)
-# Build a wrapper binary for each target to set environment variables.
-for FUZZ_TARGET in ${FUZZ_TARGETS[@]}
-do
- $CC $CFLAGS -O0 \
- -DFUZZ_TARGET=$FUZZ_TARGET \
- $SRC/target.c -o $OUT/$FUZZ_TARGET
-done
-
-# Stash actual binaries in subdirectory so they aren't picked up by target discovery
-mkdir -p $OUT/real
+REALBIN_PATH=$OUT
+if [ "$SANITIZER" = "coverage" ]
+then
+ echo "this is a coverage build"
+else
+ # Stash actual binaries in subdirectory so they aren't picked up by target discovery
+ mkdir -p $OUT/real
+ REALBIN_PATH=$OUT/real
+
+ # Build a wrapper binary for each target to set environment variables.
+ for FUZZ_TARGET in ${FUZZ_TARGETS[@]}
+ do
+ $CC $CFLAGS -O0 \
+ -DFUZZ_TARGET=$FUZZ_TARGET \
+ $SRC/target.c -o $OUT/$FUZZ_TARGET
+ done
+fi
# build main target
cd "$MODDABLE/xs/makefiles/lin"
FUZZING=1 OSSFUZZ=1 make debug
cd "$MODDABLE"
-cp ./build/bin/lin/debug/xst $OUT/real/xst
+cp ./build/bin/lin/debug/xst $REALBIN_PATH/xst
cp $SRC/xst.options $OUT/
# build jsonparse target
@@ -47,6 +57,6 @@ make -f xst.mk clean
FUZZING=1 OSSFUZZ=1 OSSFUZZ_JSONPARSE=1 make debug
cd "$MODDABLE"
-cp ./build/bin/lin/debug/xst $OUT/real/xst_jsonparse
+cp ./build/bin/lin/debug/xst $REALBIN_PATH/xst_jsonparse
cp $SRC/xst.options $OUT/xst_jsonparse.options
diff --git a/projects/xs/target.c b/projects/xs/target.c
index 55ac2cde..70a98cc6 100644
--- a/projects/xs/target.c
+++ b/projects/xs/target.c
@@ -1,19 +1,20 @@
/*
-#
-# 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.
-#
-################################################################################
-*/
+ ********************************************************************************
+ *
+ * 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.
+ *
+ ********************************************************************************
+ */
#include <limits.h>
#include <stdio.h>