2019-10-14 16:33:10 +00:00
|
|
|
#!/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.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
PROJECT=osquery
|
|
|
|
|
2021-09-15 13:30:27 +00:00
|
|
|
# Ensure xlocale.h is found.
|
|
|
|
ln -s /usr/include/locale.h /usr/include/xlocale.h
|
|
|
|
|
2019-10-14 16:33:10 +00:00
|
|
|
# Move the project content into the current overlay.
|
|
|
|
# CMake builtin 'rename' will attempt a hardlink.
|
|
|
|
( cd / &&\
|
|
|
|
mv "${SRC}/${PROJECT}" "${SRC}/${PROJECT}-dev" &&\
|
|
|
|
mv "${SRC}/${PROJECT}-dev" "${SRC}/${PROJECT}" )
|
|
|
|
|
|
|
|
pushd "${SRC}/${PROJECT}"
|
|
|
|
|
2020-01-05 07:32:42 +00:00
|
|
|
mkdir build && pushd build
|
2019-10-14 16:33:10 +00:00
|
|
|
|
|
|
|
cmake \
|
|
|
|
-DOSQUERY_VERSION:string=0.0.0-fuzz \
|
2019-10-22 04:55:21 +00:00
|
|
|
-DOSQUERY_ENABLE_ADDRESS_SANITIZER:BOOL=ON \
|
2020-12-22 18:40:01 +00:00
|
|
|
-DOSQUERY_BUILD_FUZZERS:BOOL=ON \
|
|
|
|
-DOSQUERY_BUILD_AWS:BOOL=OFF \
|
2023-04-23 22:59:39 +00:00
|
|
|
-DOSQUERY_BUILD_EXPERIMENTS:BOOL=OFF \
|
2019-10-14 16:33:10 +00:00
|
|
|
..
|
2020-12-12 02:20:57 +00:00
|
|
|
|
2019-10-14 16:33:10 +00:00
|
|
|
cmake \
|
2020-01-05 07:32:42 +00:00
|
|
|
"-DCMAKE_EXE_LINKER_FLAGS=${LIB_FUZZING_ENGINE} -Wl,-rpath,'\$ORIGIN/lib'" \
|
2019-10-14 16:33:10 +00:00
|
|
|
..
|
2019-10-18 03:18:40 +00:00
|
|
|
|
2021-09-15 13:30:27 +00:00
|
|
|
# Fix circular definitions
|
|
|
|
# See: https://github.com/osquery/osquery/issues/6551
|
|
|
|
sed -i 's/AUDIT_FILTER_EXCLUDE/AUDIT_FILTER_EXCLUDE1/g' /src/osquery/libraries/cmake/source/libaudit/src/lib/libaudit.h
|
|
|
|
|
2019-10-18 03:18:40 +00:00
|
|
|
# Build harnesses
|
2019-10-14 16:33:10 +00:00
|
|
|
cmake --build . -j$(nproc) --target osqueryfuzz-config
|
2019-10-31 00:51:01 +00:00
|
|
|
cmake --build . -j$(nproc) --target osqueryfuzz-sqlquery
|
2019-10-18 03:18:40 +00:00
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
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
|
|
|
|
|
2020-01-05 07:32:42 +00:00
|
|
|
# Move libunwind to output path
|
|
|
|
mkdir -p "${OUT}/lib"
|
|
|
|
cp /usr/lib/x86_64-linux-gnu/libunwind.so.8 "${OUT}/lib"
|
|
|
|
|
2019-10-18 03:18:40 +00:00
|
|
|
# Move harnesses to output path
|
2019-10-22 04:55:21 +00:00
|
|
|
cp osquery/main/harnesses/osqueryfuzz-config "${OUT}/osqueryfuzz-config"
|
2019-10-31 00:51:01 +00:00
|
|
|
cp osquery/main/harnesses/osqueryfuzz-sqlquery "${OUT}/osqueryfuzz-sqlquery"
|
|
|
|
|
|
|
|
# Build supporting files
|
|
|
|
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"
|
2020-01-05 07:32:42 +00:00
|
|
|
cp tools/harnesses/osqueryfuzz_sqlquery.dict "${OUT}/osqueryfuzz-sqlquery.dict"
|