build.sh (2241B)
1 #!/bin/bash -eu 2 # 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 # 7 ################################################################################ 8 9 # List of targets disabled for oss-fuzz. 10 declare -A disabled=() 11 12 # Helper function that copies a fuzzer binary and its seed corpus. 13 copy_fuzzer() 14 { 15 local fuzzer=$1 16 local name=$2 17 18 # Copy the binary. 19 cp ../dist/Debug/bin/$fuzzer $OUT/$name 20 21 # Zip and copy the corpus, if any. 22 if [ -d "$SRC/nss-corpus/$name" ]; then 23 zip $OUT/${name}_seed_corpus.zip $SRC/nss-corpus/$name/* 24 fi 25 } 26 27 # Copy libFuzzer options 28 cp fuzz/options/*.options $OUT/ 29 30 # Build the library (non-TLS fuzzing mode). 31 CXX="$CXX -stdlib=libc++" LDFLAGS="$CFLAGS" \ 32 ./build.sh -c -v --fuzz=oss --fuzz --disable-tests 33 34 # Copy fuzzing targets. 35 for fuzzer in $(find ../dist/Debug/bin -name "nssfuzz-*" -printf "%f\n"); do 36 name=${fuzzer:8} 37 if [ -z "${disabled[$name]:-}" ]; then 38 [ -f "fuzz/options/${name}-no_fuzzer_mode.options" ] && name="${name}-no_fuzzer_mode" 39 copy_fuzzer $fuzzer $name 40 fi 41 done 42 43 # Build Cryptofuzz. 44 # We want to build with the non-TLS fuzzing mode version of NSS. 45 ./automation/taskcluster/scripts/build_cryptofuzz.sh 46 47 # Copy dictionary and fuzz target. 48 cp ./cryptofuzz/cryptofuzz-dict.txt $OUT/cryptofuzz.dict 49 cp ./cryptofuzz/cryptofuzz $OUT/cryptofuzz 50 51 # Zip and copy the corpus, if any. 52 if [ -d "$SRC/nss-corpus/cryptofuzz" ]; then 53 zip $OUT/cryptofuzz_seed_corpus.zip $SRC/nss-corpus/cryptofuzz/* 54 fi 55 56 # TLS Fuzzing mode: Totally Lacking Security 57 # This mode disables a lot of cryptography to help the fuzzer. 58 # It was originally used for the TLS-specific fuzzers but has been generalized. 59 # Build the library again (TLS fuzzing mode). 60 CXX="$CXX -stdlib=libc++" LDFLAGS="$CFLAGS" \ 61 ./build.sh -c -v --fuzz=oss --fuzz=tls --disable-tests 62 63 for fuzzer in $(find ../dist/Debug/bin -name "nssfuzz-*" -printf "%f\n"); do 64 name=${fuzzer:8} 65 if [ -z "${disabled[$name]:-}" ] && [ -f "fuzz/options/${name}-no_fuzzer_mode.options" ]; then 66 copy_fuzzer "$fuzzer" "$name" 67 fi 68 done