2019-05-31 23:59:45 +00:00
|
|
|
#!/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.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2019-06-03 16:06:53 +00:00
|
|
|
# Build pcre dependency to be linked statically.
|
|
|
|
pushd $SRC/pcre
|
|
|
|
./autogen.sh
|
2019-06-06 14:44:27 +00:00
|
|
|
CFLAGS="$CFLAGS -fno-use-cxa-atexit" CXXFLAGS="$CXXFLAGS -fno-use-cxa-atexit" ./configure
|
2019-06-03 16:06:53 +00:00
|
|
|
make -j$(nproc) clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
popd
|
|
|
|
|
2019-05-31 23:59:45 +00:00
|
|
|
# build project
|
|
|
|
rm -rf build
|
|
|
|
|
|
|
|
./configure
|
|
|
|
make njs
|
|
|
|
|
|
|
|
# build fuzzers
|
|
|
|
# e.g.
|
2019-08-01 23:03:49 +00:00
|
|
|
$CC $CFLAGS -Inxt -Ibuild -Isrc -c \
|
2019-05-31 23:59:45 +00:00
|
|
|
$SRC/njs_process_script_fuzzer.c -o build/njs_process_script_fuzzer.o
|
|
|
|
|
2019-06-03 16:06:53 +00:00
|
|
|
$CXX $CXXFLAGS build/njs_process_script_fuzzer.o \
|
|
|
|
-o $OUT/njs_process_script_fuzzer \
|
2019-08-01 23:03:49 +00:00
|
|
|
$LIB_FUZZING_ENGINE build/libnjs.a \
|
2019-06-03 16:06:53 +00:00
|
|
|
$SRC/pcre/.libs/libpcre.a -lm -lreadline
|
2019-05-31 23:59:45 +00:00
|
|
|
|
|
|
|
SEED_CORPUS_PATH=$OUT/njs_process_script_fuzzer_seed_corpus
|
|
|
|
mkdir -p $SEED_CORPUS_PATH
|
|
|
|
|
|
|
|
set +x
|
2019-08-01 23:03:49 +00:00
|
|
|
cat src/test/njs_interactive_test.c src/test/njs_unit_test.c \
|
2019-05-31 23:59:45 +00:00
|
|
|
| egrep -o '".*"' | awk '{print substr($0,2,length($0)-2)}' | sort | uniq \
|
|
|
|
| while IFS= read -r line; do
|
|
|
|
echo $line > $SEED_CORPUS_PATH/$(echo $line | sha1sum | awk '{ print $1 }');
|
|
|
|
done
|
|
|
|
set -x
|
|
|
|
|
2019-08-01 23:03:49 +00:00
|
|
|
cp -r test/fs test/module $SEED_CORPUS_PATH
|
|
|
|
|
2019-05-31 23:59:45 +00:00
|
|
|
zip -q $SEED_CORPUS_PATH.zip $SEED_CORPUS_PATH
|
|
|
|
rm -rf $SEED_CORPUS_PATH
|