• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2018 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#!/usr/bin/env bash
19set -ex
20
21ROOTDIR="${SRC}/solidity"
22BUILDDIR="${ROOTDIR}/build"
23mkdir -p "${BUILDDIR}"
24
25generate_protobuf_bindings()
26{
27  cd "${ROOTDIR}"/test/tools/ossfuzz
28  # Generate protobuf C++ bindings
29  for protoName in yul abiV2 sol;
30  do
31    protoc "${protoName}"Proto.proto --cpp_out .
32  done
33}
34
35build_fuzzers()
36{
37  cd "${BUILDDIR}"
38  CXXFLAGS="${CXXFLAGS} -I/usr/local/include/c++/v1"
39  cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/ossfuzz.cmake \
40        -DCMAKE_BUILD_TYPE=Release \
41        "${ROOTDIR}"
42  make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j $(nproc)
43}
44
45copy_fuzzers_and_config()
46{
47  cp "${BUILDDIR}"/test/tools/ossfuzz/*_ossfuzz "${OUT}"
48  cp "${ROOTDIR}"/test/tools/ossfuzz/config/*.options "${OUT}"
49  cp "${ROOTDIR}"/test/tools/ossfuzz/config/*.dict "${OUT}"
50}
51
52update_corpus()
53{
54  rm -f "${OUT}"/*.zip
55  cd "${SRC}"/solidity-fuzzing-corpus
56  git pull origin master
57  for dir in "${SRC}"/solidity-fuzzing-corpus/*;
58  do
59    name=$(basename $dir)
60    zip -rq "${OUT}"/$name $dir
61  done
62}
63
64generate_protobuf_bindings
65build_fuzzers
66copy_fuzzers_and_config
67update_corpus
68