forked from capstone-engine/capstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fuzzit integration (capstone-engine#1520)
- Loading branch information
1 parent
85dffae
commit ba97425
Showing
6 changed files
with
107 additions
and
10 deletions.
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
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
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
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,34 @@ | ||
Fuzzing | ||
=============== | ||
|
||
|
||
Build the fuzz target | ||
------- | ||
|
||
To build the fuzz target, you can simply run `make` with appropriate flags set : | ||
``` | ||
ASAN_OPTIONS=detect_leaks=0 CXXFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" CFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" LDFLAGS="-fsanitize=address" make | ||
``` | ||
You can replace `address` with another sanitizer : `memory` or `undefined` | ||
The fuzz target is then `suite/fuzz/fuzz_bindisasm2` | ||
|
||
You can find this in travis configuration `.travis.yml` | ||
|
||
Another way is to use oss-fuzz, see https://github.com/google/oss-fuzz/blob/master/projects/capstone/build.sh | ||
|
||
Fuzz drivers | ||
------ | ||
|
||
There are custom drivers : | ||
- driverbin.c : prints cstool command before running one input | ||
- drivermc.c : converts MC test data to raw binary data before running as many inputs as there are lines in a file | ||
- onefile.c : simple one file driver | ||
|
||
For libfuzzer, the preferred main function is now to use linker option `-fsanitize=fuzzer` | ||
|
||
Fuzzit integration | ||
------ | ||
|
||
Travis will build the fuzz target with the different sanitizers. | ||
Then, Travis will launch sanity fuzzit jobs as part of continuous integration (for each of the sanitizers) | ||
The fuzzit target ids are stored in a configuration file fuzzitid.txt and used by fuzzit.sh |
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,27 @@ | ||
FUZZIT_API_KEY=f10b19a56d96b29dfdfe459d41b3d82e475e49c737095c74c99d65a032d5c2ab84d44dad510886bc824f101a860b1754 | ||
|
||
[ -s ./suite/fuzz/fuzz_bindisasm2 ] || exit 0 | ||
|
||
if [ ${TRAVIS_EVENT_TYPE} -eq 'cron' ]; then | ||
FUZZING_TYPE=fuzzing | ||
else | ||
FUZZING_TYPE=sanity | ||
fi | ||
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then | ||
FUZZIT_BRANCH="${TRAVIS_BRANCH}" | ||
else | ||
FUZZIT_BRANCH="PR-${TRAVIS_PULL_REQUEST}" | ||
fi | ||
|
||
FUZZIT_ARGS="--type ${FUZZING_TYPE} --branch ${FUZZIT_BRANCH} --revision ${TRAVIS_COMMIT}" | ||
if [ -n "$UBSAN_OPTIONS" ]; then | ||
FUZZIT_ARGS+=" --ubsan_options ${UBSAN_OPTIONS}" | ||
fi | ||
wget -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v1.2.5/fuzzit_1.2.5_Linux_x86_64 | ||
chmod +x fuzzit | ||
./fuzzit auth ${FUZZIT_API_KEY} | ||
set -x | ||
grep "$QA_FUZZIT" suite/fuzz/fuzzitid.txt | cut -d" " -f2 | while read i; do | ||
./fuzzit c job ${FUZZIT_ARGS} ${i} ./suite/fuzz/fuzz_bindisasm2 | ||
done | ||
set +x |
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,3 @@ | ||
asan A1NqPndmOVrguCNj95LZ | ||
msan JchjH3j58fOnB8ZXGyWl | ||
ubsan JqHqVabfDEqitOusrPFx |