github.com/CommerciumBlockchain/go-commercium@v0.0.0-20220709212705-b46438a77516/oss-fuzz.sh (about) 1 #/bin/bash -eu 2 # Copyright 2020 Google Inc. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # 16 ################################################################################ 17 18 # This file is for integration with Google OSS-Fuzz. 19 # The following ENV variables are available when executing on OSS-fuzz: 20 # 21 # /out/ $OUT Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives). 22 # /src/ $SRC Directory to checkout source files. 23 # /work/ $WORK Directory to store intermediate files. 24 # 25 # $CC, $CXX, $CCC The C and C++ compiler binaries. 26 # $CFLAGS, $CXXFLAGS C and C++ compiler flags. 27 # $LIB_FUZZING_ENGINE C++ compiler argument to link fuzz target against the prebuilt engine library (e.g. libFuzzer). 28 29 function compile_fuzzer { 30 path=$SRC/go-ethereum/$1 31 func=$2 32 fuzzer=$3 33 corpusfile="${path}/testdata/${fuzzer}_seed_corpus.zip" 34 echo "Building $fuzzer (expecting corpus at $corpusfile)" 35 (cd $path && \ 36 go-fuzz -func $func -o $WORK/$fuzzer.a . && \ 37 echo "First stage built OK" && \ 38 $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $WORK/$fuzzer.a -o $OUT/$fuzzer && \ 39 echo "Second stage built ok" ) 40 41 ## Check if there exists a seed corpus file 42 if [ -f $corpusfile ] 43 then 44 cp $corpusfile $OUT/ 45 echo "Found seed corpus: $corpusfile" 46 fi 47 } 48 49 compile_fuzzer common/bitutil Fuzz fuzzBitutilCompress 50 compile_fuzzer crypto/bn256 FuzzAdd fuzzBn256Add 51 compile_fuzzer crypto/bn256 FuzzMul fuzzBn256Mul 52 compile_fuzzer crypto/bn256 FuzzPair fuzzBn256Pair 53 compile_fuzzer core/vm/runtime Fuzz fuzzVmRuntime 54 compile_fuzzer crypto/blake2b Fuzz fuzzBlake2b 55 compile_fuzzer tests/fuzzers/keystore Fuzz fuzzKeystore 56 compile_fuzzer tests/fuzzers/txfetcher Fuzz fuzzTxfetcher 57 compile_fuzzer tests/fuzzers/rlp Fuzz fuzzRlp 58 compile_fuzzer tests/fuzzers/trie Fuzz fuzzTrie 59 compile_fuzzer tests/fuzzers/stacktrie Fuzz fuzzStackTrie 60 compile_fuzzer tests/fuzzers/difficulty Fuzz fuzzDifficulty 61 62 compile_fuzzer tests/fuzzers/bls12381 FuzzG1Add fuzz_g1_add 63 compile_fuzzer tests/fuzzers/bls12381 FuzzG1Mul fuzz_g1_mul 64 compile_fuzzer tests/fuzzers/bls12381 FuzzG1MultiExp fuzz_g1_multiexp 65 compile_fuzzer tests/fuzzers/bls12381 FuzzG2Add fuzz_g2_add 66 compile_fuzzer tests/fuzzers/bls12381 FuzzG2Mul fuzz_g2_mul 67 compile_fuzzer tests/fuzzers/bls12381 FuzzG2MultiExp fuzz_g2_multiexp 68 compile_fuzzer tests/fuzzers/bls12381 FuzzPairing fuzz_pairing 69 compile_fuzzer tests/fuzzers/bls12381 FuzzMapG1 fuzz_map_g1 70 compile_fuzzer tests/fuzzers/bls12381 FuzzMapG2 fuzz_map_g2 71 72 # This doesn't work very well @TODO 73 #compile_fuzzertests/fuzzers/abi Fuzz fuzzAbi 74