oss-fuzz.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. # This file is for integration with Google OSS-Fuzz.
  18. # The following ENV variables are available when executing on OSS-fuzz:
  19. #
  20. # /out/ $OUT Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives).
  21. # /src/ $SRC Directory to checkout source files.
  22. # /work/ $WORK Directory to store intermediate files.
  23. #
  24. # $CC, $CXX, $CCC The C and C++ compiler binaries.
  25. # $CFLAGS, $CXXFLAGS C and C++ compiler flags.
  26. # $LIB_FUZZING_ENGINE C++ compiler argument to link fuzz target against the prebuilt engine library (e.g. libFuzzer).
  27. function compile_fuzzer {
  28. path=$SRC/go-ethereum/$1
  29. func=$2
  30. fuzzer=$3
  31. corpusfile="${path}/testdata/${fuzzer}_seed_corpus.zip"
  32. echo "Building $fuzzer (expecting corpus at $corpusfile)"
  33. (cd $path && \
  34. go-fuzz -func $func -o $WORK/$fuzzer.a . && \
  35. echo "First stage built OK" && \
  36. $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $WORK/$fuzzer.a -o $OUT/$fuzzer && \
  37. echo "Second stage built ok" )
  38. ## Check if there exists a seed corpus file
  39. if [ -f $corpusfile ]
  40. then
  41. cp $corpusfile $OUT/
  42. echo "Found seed corpus: $corpusfile"
  43. fi
  44. }
  45. compile_fuzzer common/bitutil Fuzz fuzzBitutilCompress
  46. compile_fuzzer crypto/bn256 FuzzAdd fuzzBn256Add
  47. compile_fuzzer crypto/bn256 FuzzMul fuzzBn256Mul
  48. compile_fuzzer crypto/bn256 FuzzPair fuzzBn256Pair
  49. compile_fuzzer core/vm/runtime Fuzz fuzzVmRuntime
  50. compile_fuzzer crypto/blake2b Fuzz fuzzBlake2b
  51. compile_fuzzer tests/fuzzers/keystore Fuzz fuzzKeystore
  52. compile_fuzzer tests/fuzzers/txfetcher Fuzz fuzzTxfetcher
  53. compile_fuzzer tests/fuzzers/rlp Fuzz fuzzRlp
  54. compile_fuzzer tests/fuzzers/trie Fuzz fuzzTrie
  55. compile_fuzzer tests/fuzzers/stacktrie Fuzz fuzzStackTrie
  56. compile_fuzzer tests/fuzzers/bls12381 FuzzG1Add fuzz_g1_add
  57. compile_fuzzer tests/fuzzers/bls12381 FuzzG1Mul fuzz_g1_mul
  58. compile_fuzzer tests/fuzzers/bls12381 FuzzG1MultiExp fuzz_g1_multiexp
  59. compile_fuzzer tests/fuzzers/bls12381 FuzzG2Add fuzz_g2_add
  60. compile_fuzzer tests/fuzzers/bls12381 FuzzG2Mul fuzz_g2_mul
  61. compile_fuzzer tests/fuzzers/bls12381 FuzzG2MultiExp fuzz_g2_multiexp
  62. compile_fuzzer tests/fuzzers/bls12381 FuzzPairing fuzz_pairing
  63. compile_fuzzer tests/fuzzers/bls12381 FuzzMapG1 fuzz_map_g1
  64. compile_fuzzer tests/fuzzers/bls12381 FuzzMapG2 fuzz_map_g2
  65. # This doesn't work very well @TODO
  66. #compile_fuzzertests/fuzzers/abi Fuzz fuzzAbi