From 55b7ded4c8a0ab3ddb9f838594ecd16ab1564ea9 Mon Sep 17 00:00:00 2001 From: Teddy Reed Date: Sun, 5 Jan 2020 02:32:42 -0500 Subject: [PATCH] [osquery] Use platform toolchain and fix coverage builds (#3182) --- projects/osquery/Dockerfile | 7 +------ projects/osquery/build.sh | 17 +++++++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/projects/osquery/Dockerfile b/projects/osquery/Dockerfile index 35ae8a30a..58e73df89 100755 --- a/projects/osquery/Dockerfile +++ b/projects/osquery/Dockerfile @@ -17,7 +17,7 @@ FROM gcr.io/oss-fuzz-base/base-builder MAINTAINER theopolis@osquery.io RUN apt-get update -RUN apt-get install -y --no-install-recommends python python3 bison flex make wget xz-utils +RUN apt-get install -y --no-install-recommends python python3 bison flex make wget xz-utils libunwind-dev # Install specific git version. RUN export GIT_VER=2.21.0 \ @@ -36,11 +36,6 @@ RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.14.6/cmake-3.1 && tar xf cmake-3.14.6-Linux-x86_64.tar.gz -C /usr/local --strip 1 \ && rm cmake-3.14.6-Linux-x86_64.tar.gz -# Install build toolchain -RUN wget https://github.com/osquery/osquery-toolchain/releases/download/1.0.0/osquery-toolchain-1.0.0.tar.xz \ - && tar xf osquery-toolchain-1.0.0.tar.xz -C /usr/local \ - && rm osquery-toolchain-1.0.0.tar.xz - RUN git clone --depth 1 https://github.com/osquery/osquery osquery WORKDIR osquery diff --git a/projects/osquery/build.sh b/projects/osquery/build.sh index 3815a6d46..b5b31d635 100755 --- a/projects/osquery/build.sh +++ b/projects/osquery/build.sh @@ -24,19 +24,20 @@ PROJECT=osquery mv "${SRC}/${PROJECT}-dev" "${SRC}/${PROJECT}" ) pushd "${SRC}/${PROJECT}" -mkdir build && pushd build -export CXXFLAGS="${CXXFLAGS} -Wl,-lunwind -Wl,-lc++abi" -export CFLAGS="${CFLAGS} -Wl,-lunwind" +# Prefer shared libs +sed -i 's/CMAKE_LINK_SEARCH_START_STATIC ON/CMAKE_LINK_SEARCH_START_STATIC OFF/g' cmake/flags.cmake +sed -i 's/CMAKE_LINK_SEARCH_END_STATIC ON/CMAKE_LINK_SEARCH_END_STATIC OFF/g' cmake/flags.cmake + +mkdir build && pushd build cmake \ -DOSQUERY_VERSION:string=0.0.0-fuzz \ -DOSQUERY_ENABLE_ADDRESS_SANITIZER:BOOL=ON \ -DOSQUERY_ENABLE_FUZZER_SANITIZERS:BOOL=ON \ - -DOSQUERY_TOOLCHAIN_SYSROOT=/usr/local/osquery-toolchain \ .. cmake \ - -DCMAKE_EXE_LINKER_FLAGS=${LIB_FUZZING_ENGINE} \ + "-DCMAKE_EXE_LINKER_FLAGS=${LIB_FUZZING_ENGINE} -Wl,-rpath,'\$ORIGIN/lib'" \ .. # Build harnesses @@ -48,6 +49,10 @@ find . -type f -name '*.o' -delete rm -rf "${SRC}/${PROJECT}/libraries/cmake/source/libudev/src/test" rm -rf libs/src/patched-source/libudev/src/test +# Move libunwind to output path +mkdir -p "${OUT}/lib" +cp /usr/lib/x86_64-linux-gnu/libunwind.so.8 "${OUT}/lib" + # Move harnesses to output path cp osquery/main/harnesses/osqueryfuzz-config "${OUT}/osqueryfuzz-config" cp osquery/main/harnesses/osqueryfuzz-sqlquery "${OUT}/osqueryfuzz-sqlquery" @@ -57,4 +62,4 @@ popd tools/harnesses/osqueryfuzz_config_corpus.sh "${OUT}/osqueryfuzz-config_seed_corpus.zip" tools/harnesses/osqueryfuzz_config_dict.sh "${OUT}/osqueryfuzz-config.dict" tools/harnesses/osqueryfuzz_sqlquery_corpus.sh "${OUT}/osqueryfuzz-sqlquery_seed_corpus.zip" -cp tools/harnesses/osqueryfuzz_sqlquery.dict "${OUT}/osqueryfuzz-sqlquery.dict" \ No newline at end of file +cp tools/harnesses/osqueryfuzz_sqlquery.dict "${OUT}/osqueryfuzz-sqlquery.dict"