forked from skupperproject/skupper-router
-
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.
Fixes skupperproject#1613: Added fuzz testing for the http2 decoder. …
…Fixes for two issues that the fuzz tester found.
- Loading branch information
1 parent
7462d96
commit fa562ce
Showing
70 changed files
with
489 additions
and
11 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
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,56 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
# | ||
add_definitions(${C_STANDARD_FLAGS} ${COMPILE_WARNING_FLAGS}) | ||
|
||
option(FUZZ_REGRESSION_TESTS "Run fuzz tests with regression test driver" ON) | ||
option(FUZZ_LONG_TESTS "Run fuzz tests that take a long time" OFF) | ||
set(FUZZER LibFuzzer CACHE STRING "Fuzzing engine to use") | ||
set(FUZZING_LIB_LibFuzzer FuzzingEngine) | ||
set(FUZZING_LIB_AFL -fsanitize=fuzzer) | ||
|
||
add_library(StandaloneFuzzTargetMain STATIC StandaloneFuzzTargetMain.c StandaloneFuzzTargetInit.c) | ||
|
||
if (FUZZ_REGRESSION_TESTS) | ||
message(STATUS "FUZZ_REGRESSION_TESTS") | ||
set(FUZZING_LIBRARY StandaloneFuzzTargetMain) | ||
else () | ||
message(STATUS "NO FUZZ_REGRESSION_TESTS") | ||
set(FUZZING_LIBRARY ${FUZZING_LIB_${FUZZER}}) | ||
endif () | ||
|
||
macro(add_fuzz_test test) | ||
add_executable (${test} ${ARGN}) | ||
target_link_libraries (${test} ${FUZZING_LIBRARY} skupper-router) | ||
set_target_properties(fuzz_http2_decoder PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
if(FUZZ_REGRESSION_TESTS) | ||
file(GLOB_RECURSE files ${CMAKE_CURRENT_SOURCE_DIR}/${test}/*) | ||
unset(file_lines) | ||
foreach(f IN LISTS files) | ||
set(file_lines "${file_lines}${f}\n") | ||
endforeach() | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${test}-files" "${file_lines}") | ||
add_test(${test} ${TEST_WRAP} ${test} "@${CMAKE_CURRENT_BINARY_DIR}/${test}-files") | ||
else(FUZZ_REGRESSION_TESTS) | ||
add_test(${test} ${TEST_WRAP} ${test} "-runs=1 ${CMAKE_CURRENT_SOURCE_DIR}/${test}") | ||
endif(FUZZ_REGRESSION_TESTS) | ||
endmacro(add_fuzz_test test) | ||
|
||
add_fuzz_test(fuzz_http2_decoder fuzz_http2_decoder.c) | ||
#add_fuzz_test(fuzz_http1_decoder fuzz_http1_decoder.c) |
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,54 @@ | ||
# Copyright 2017 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 | ||
RUN apt-get update | ||
|
||
# Ensure we work from right python version | ||
# Minimum python version required by qpid-proton and skupper-router is Python 3.9 | ||
RUN apt-get install -y python3.9 python3.9-dev && \ | ||
ln --force -s /usr/bin/python3.9 /usr/local/bin/python3 && \ | ||
apt-get install -y python3-pip | ||
RUN apt-get install -y libuv1-dev wget cmake emacs python3-dev libwebsockets-dev libtool zlib1g-dev cmake libsasl2-dev libssl-dev sasl2-bin libnghttp2-dev | ||
|
||
# LibwebSockets library is required by skupper-router | ||
RUN git clone https://github.com/warmcat/libwebsockets.git --branch v4.3-stable | ||
WORKDIR /src | ||
RUN mkdir libwebsockets/build && cd libwebsockets/build && cmake .. -DLWS_LINK_TESTAPPS_DYNAMIC=ON -DLWS_WITH_LIBUV=OFF -DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON -DLWS_WITHOUT_BUILTIN_SHA1=ON -DLWS_WITH_STATIC=OFF -DLWS_IPV6=ON -DLWS_WITH_HTTP2=OFF -DLWS_WITHOUT_CLIENT=OFF -DLWS_WITHOUT_SERVER=OFF -DLWS_WITHOUT_TESTAPPS=ON -DLWS_WITHOUT_TEST_SERVER=ON -DLWS_WITHOUT_TEST_SERVER_EXTPOLL=ON -DLWS_WITHOUT_TEST_PING=ON -DLWS_WITHOUT_TEST_CLIENT=ON && make install | ||
|
||
RUN git clone https://github.com/apache/qpid-proton.git | ||
WORKDIR /src/qpid-proton | ||
RUN mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF -DENABLE_LINKTIME_OPTIMIZATION=OFF -DBUILD_TLS=ON -DSSL_IMPL=openssl -DBUILD_TOOLS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF && make install | ||
|
||
WORKDIR /src | ||
RUN git clone https://github.com/ganeshmurthy/skupper-router.git --branch FUZZ-TESTING | ||
|
||
WORKDIR /src/skupper-router | ||
|
||
# refresh the build directory if it exists already | ||
RUN rm build -rf || true | ||
|
||
# /usr/local/bin/compile compiles libFuzzer or AmericanFuzzyLop(afl), then calls /src/build.sh and sets correct environment variables for it | ||
RUN echo cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF -DFUZZ_REGRESSION_TESTS=OFF -DCMAKE_C_FLAGS=-DQD_MEMORY_DEBUG -DRUNTIME_CHECK=asan > /src/build.sh | ||
|
||
# build and run the test. Choose AFL for fuzzer | ||
RUN mkdir build | ||
WORKDIR /src/skupper-router/build | ||
RUN export FUZZING_LANGUAGE='' && export FUZZING_ENGINE=afl && /usr/local/bin/compile | ||
WORKDIR /src/skupper-router/build/tests/fuzz | ||
RUN make | ||
ENTRYPOINT LD_LIBRARY_PATH=/usr/local/lib/clang/18/lib/x86_64-unknown-linux-gnu/ AFL_MAP_SIZE=10000000 AFL_DEBUG=1 AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 make test; bash | ||
#CMD ["/bin/bash"] |
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,36 @@ | ||
/* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
* | ||
*/ | ||
#include <qpid/dispatch/alloc_pool.h> | ||
#include <qpid/dispatch/log.h> | ||
|
||
void qd_log_initialize(void); | ||
void qd_error_initialize(void); | ||
|
||
#include "libFuzzingEngine.h" | ||
|
||
int LLVMFuzzerInitialize(int *argc, char ***argv) | ||
{ | ||
qd_alloc_initialize(); | ||
qd_log_initialize(); | ||
qd_error_initialize(); | ||
return 0; | ||
} | ||
|
Oops, something went wrong.