From a4374a23bcc904d98aa2d9abb0f5582d22f25242 Mon Sep 17 00:00:00 2001 From: Konstantin Munichev Date: Thu, 5 Sep 2019 16:45:22 +0300 Subject: [PATCH] [iroha] Add Hyperledger Iroha project (#2753) * [Iroha] Add initial Dockerfile and build.sh * Single fuzzing target; grpc timeout bumper Signed-off-by: Konstantin Munichev * Build fuzzing in a single thread Signed-off-by: Konstantin Munichev --- projects/iroha/Dockerfile | 55 +++++++++++++++++++++++++++++++++++++ projects/iroha/build.sh | 26 ++++++++++++++++++ projects/iroha/project.yaml | 4 +++ 3 files changed, 85 insertions(+) create mode 100644 projects/iroha/Dockerfile create mode 100755 projects/iroha/build.sh create mode 100644 projects/iroha/project.yaml diff --git a/projects/iroha/Dockerfile b/projects/iroha/Dockerfile new file mode 100644 index 000000000..67ef353d2 --- /dev/null +++ b/projects/iroha/Dockerfile @@ -0,0 +1,55 @@ +# 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. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +MAINTAINER konstantin@soramitsu.co.jp + +RUN set -e; \ + apt-get update && \ + apt-get -y --no-install-recommends install libicu-dev \ + apt-utils git curl wget unzip tar; \ + apt-get -y clean + +RUN wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4-Linux-x86_64.tar.gz && tar -xzvf cmake-3.14.4-Linux-x86_64.tar.gz && cp -a cmake-3.14.4-Linux-x86_64/bin/. /usr/bin/ && cp -a cmake-3.14.4-Linux-x86_64/share/. /usr/share/ + + +# Get *your* source code here. +RUN git clone --depth 1 https://github.com/hyperledger/iroha.git + +WORKDIR iroha + +RUN cp -R $SRC/iroha/vcpkg /tmp/vcpkg-vars + +RUN set -e; \ + git clone https://github.com/microsoft/vcpkg /tmp/vcpkg; \ + (cd /tmp/vcpkg ; git checkout $(cat /tmp/vcpkg-vars/VCPKG_COMMIT_SHA)); \ + for i in /tmp/vcpkg-vars/patches/*.patch; do git -C /tmp/vcpkg apply $i; done; \ + for i in /tmp/vcpkg-vars/patches/oss/*.patch; do git -C /tmp/vcpkg apply $i; done; \ + sh /tmp/vcpkg/bootstrap-vcpkg.sh; \ + /tmp/vcpkg/vcpkg install $(cat /tmp/vcpkg-vars/VCPKG_BOOST_LOCALE_DEPS_LIST | cut -d':' -f1 | tr '\n' ' '); \ + (cd /tmp/vcpkg ; git checkout -- scripts/toolchains/linux.cmake); \ + (cd /tmp/vcpkg ; git apply /tmp/vcpkg-vars/patches/oss/0002-vcpkg-dependencies-flags.patch); \ + /tmp/vcpkg/vcpkg install boost-locale; \ + (cd /tmp/vcpkg ; git apply /tmp/vcpkg-vars/patches/oss/0003-vcpkg-dependencies-sanitizer.patch); \ + /tmp/vcpkg/vcpkg install $(sed 's/grpc://' /tmp/vcpkg-vars/VCPKG_DEPS_LIST | cut -d':' -f1 | tr '\n' ' '); \ + bash -c 'function bumper { while sleep 1; do echo bump; done; }; function run_with_bumper { bumper & p=$!; $@; kill $p; }; ASAN_OPTIONS=detect_leaks=0 run_with_bumper /tmp/vcpkg/vcpkg install grpc'; \ + /tmp/vcpkg/vcpkg install --head $(cat /tmp/vcpkg-vars/VCPKG_HEAD_DEPS_LIST | cut -d':' -f1 | tr '\n' ' '); \ + /tmp/vcpkg/vcpkg export $(/tmp/vcpkg/vcpkg list | cut -d':' -f1 | tr '\n' ' ') --raw --output=dependencies; \ + mv /tmp/vcpkg/dependencies /opt/dependencies; \ + chmod +x /opt/dependencies/installed/x64-linux/tools/protobuf/protoc*; \ + rm -rf /tmp/vcpkg* + +COPY build.sh $SRC/ \ No newline at end of file diff --git a/projects/iroha/build.sh b/projects/iroha/build.sh new file mode 100755 index 000000000..bc7809573 --- /dev/null +++ b/projects/iroha/build.sh @@ -0,0 +1,26 @@ +#!/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. +# +################################################################################ + +cd $SRC/iroha +./clean.sh +mkdir build +cd build + +cmake -DCMAKE_TOOLCHAIN_FILE=/opt/dependencies/scripts/buildsystems/vcpkg.cmake -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" -DFUZZING=ON .. +make fuzzing + +cp test_bin/* $OUT/ \ No newline at end of file diff --git a/projects/iroha/project.yaml b/projects/iroha/project.yaml new file mode 100644 index 000000000..da25f96e2 --- /dev/null +++ b/projects/iroha/project.yaml @@ -0,0 +1,4 @@ +homepage: "https://github.com/hyperledger/iroha" +primary_contact: "konstantin@soramitsu.co.jp" +sanitizers: + - address \ No newline at end of file