-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some extra scripting for dealing with fuzzers
* check.sh: uses the oss-fuzz infrastructure scripts to run over various fuzzing engines, trying to build the fuzzers and run a sanity check on them * local.sh: builds the fuzzers locally with some minor assumptions on locations Signed-off-by: Erik Boasson <[email protected]>
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/bash | ||
|
||
if [ ! -f "infra/helper.py" ] ; then | ||
echo "this script must be executed in the oss-fuzz directory" 2>&1 | ||
exit 33 | ||
fi | ||
|
||
if [ "$1" = "build-image" ] ; then | ||
shift | ||
python3 infra/helper.py build_image cyclonedds | ||
fi | ||
|
||
if [ ! -d "$1" -o ! -f "$1/src/core/ddsi/src/ddsi_init.c" ] ; then | ||
echo "usage: $0 [build-image] cyclone-source-dir" 2>&1 | ||
exit 33 | ||
fi | ||
srcdir="$1" | ||
|
||
set -x | ||
engines="libfuzzer afl honggfuzz centipede" | ||
for eng in $engines ; do | ||
echo "********** ENGINE = $eng **********" | ||
sudo rm -rf $srcdir/{build,install,build_python} | ||
python3 infra/helper.py build_fuzzers --sanitizer address --engine $eng cyclonedds $srcdir || break | ||
python3 infra/helper.py check_build --engine $eng cyclonedds || break | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/bash | ||
|
||
# Local build | ||
# | ||
# sudo apt install clang libfuzzer-14-dev (replace 14 with clang version) | ||
|
||
set -ex | ||
|
||
if [ ! -f ../src/core/ddsi/src/ddsi_receive.c -o ! -d ../fuzz ] ; then | ||
echo "This expects to be run in a build directory that is a subdirectory of the Cyclone repo" 2>&1 | ||
exit 1 | ||
fi | ||
if [ -z "$CYCLONEDDS_HOME" ] ; then | ||
echo "Need CYCLONEDDS_HOME to be set" 2>&1 | ||
fi | ||
if [ -z "$CYCLONEDDS_PYTHON" -o ! -d "$CYCLONEDDS_PYTHON/tests/support_modules/fuzz_tools" ] ; then | ||
echo "need CYCLONEDDS_PYTHON to point to the cyclone python binding sources" 2>&1 | ||
exit 1 | ||
fi | ||
|
||
export PATH="$CYCLONEDDS_HOME/bin:$PATH" | ||
export LD_LIBRARY_PATH="$CYCLONEDDS_HOME/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" | ||
export PATH="$CYCLONEDDS_HOME/lib:$PATH" | ||
export PYTHONPATH="$CYCLONEDDS_PYTHON/tests/support_modules${PYTHONPATH:+:$PYTHONPATH}" | ||
|
||
# Use current git HEAD hash as seed | ||
[ -z "$SEED" ] && SEED=$(git ls-remote https://github.com/eclipse-cyclonedds/cyclonedds HEAD |cut -f1) | ||
python3 "../fuzz/fuzz_sample_deser/generate_idl.py" $SEED "../fuzz/fuzz_sample_deser" | ||
|
||
export CC=clang | ||
export CXX=clang++ | ||
export LIB_FUZZING_ENGINE=/usr/lib/llvm-14/lib/libFuzzer.a | ||
|
||
cmake -G Ninja \ | ||
-DSANITIZER=address,undefined,fuzzer \ | ||
-DEXPORT_ALL_SYMBOLS=ON \ | ||
-DBUILD_SHARED_LIBS=OFF \ | ||
-DBUILD_EXAMPLES=NO \ | ||
-DENABLE_SECURITY=ON \ | ||
-DENABLE_SSL=NO \ | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | ||
-DBUILD_IDLC=NO \ | ||
-DBUILD_DDSPERF=NO \ | ||
-DCMAKE_BUILD_TYPE=Debug \ | ||
-DCMAKE_PREFIX_PATH=$PWD/host_install \ | ||
-DCMAKE_INSTALL_PREFIX=$PWD/install .. | ||
|
||
cmake --build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters