Loading CMakeLists.txt +3 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ project (Simple-Web-Server) option(USE_STANDALONE_ASIO "set ON to use standalone Asio instead of Boost.Asio" OFF) option(BUILD_TESTING "set ON to build library tests" OFF) option(BUILD_FUZZING "set ON to build library fuzzers" OFF) option(USE_OPENSSL "set OFF to build without OpenSSL" ON) add_library(simple-web-server INTERFACE) Loading Loading @@ -79,7 +80,9 @@ if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") install(FILES asio_compatibility.hpp server_http.hpp client_http.hpp server_https.hpp client_https.hpp crypto.hpp utility.hpp status_code.hpp mutex.hpp DESTINATION include/simple-web-server) endif() if(BUILD_TESTING OR BUILD_FUZZING) if(BUILD_TESTING) enable_testing() endif() add_subdirectory(tests) endif() tests/CMakeLists.txt +37 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ if(NOT MSVC) add_compile_options(-Wno-thread-safety) endif() if(BUILD_TESTING) add_executable(io_test io_test.cpp) target_link_libraries(io_test simple-web-server) add_test(NAME io_test COMMAND io_test) Loading @@ -12,13 +13,48 @@ if(NOT MSVC) target_link_libraries(parse_test simple-web-server) add_test(NAME parse_test COMMAND parse_test) endif() endif() if(OPENSSL_FOUND) if(OPENSSL_FOUND AND BUILD_TESTING) add_executable(crypto_test crypto_test.cpp) target_link_libraries(crypto_test simple-web-server) add_test(NAME crypto_test COMMAND crypto_test) endif() if(BUILD_TESTING) add_executable(status_code_test status_code_test.cpp) target_link_libraries(status_code_test simple-web-server) add_test(NAME status_code_test COMMAND status_code_test) endif() if(BUILD_FUZZING) add_executable(percent_decode fuzzers/percent_decode.cpp) target_compile_options(percent_decode PRIVATE -fsanitize=address,fuzzer) target_link_options(percent_decode PRIVATE -fsanitize=address,fuzzer) target_link_libraries(percent_decode simple-web-server) add_executable(query_string_parse fuzzers/query_string_parse.cpp) target_compile_options(query_string_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(query_string_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(query_string_parse simple-web-server) add_executable(http_header_parse fuzzers/http_header_parse.cpp) target_compile_options(http_header_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(http_header_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(http_header_parse simple-web-server) add_executable(http_header_field_value_semicolon_separated_attributes_parse fuzzers/http_header_field_value_semicolon_separated_attributes_parse.cpp) target_compile_options(http_header_field_value_semicolon_separated_attributes_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(http_header_field_value_semicolon_separated_attributes_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(http_header_field_value_semicolon_separated_attributes_parse simple-web-server) add_executable(request_message_parse fuzzers/request_message_parse.cpp) target_compile_options(request_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(request_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(request_message_parse simple-web-server) add_executable(response_message_parse fuzzers/response_message_parse.cpp) target_compile_options(response_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(response_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(response_message_parse simple-web-server) endif() No newline at end of file tests/fuzzers/README.md 0 → 100644 +6 −0 Original line number Diff line number Diff line Prior to running the fuzzers, build and prepare for instance as follows: ```sh CXX=clang++ cmake -DBUILD_FUZZING=1 .. make export LSAN_OPTIONS=detect_leaks=0 ``` tests/fuzzers/http_header_field_value_semicolon_separated_attributes_parse.cpp 0 → 100644 +6 −0 Original line number Diff line number Diff line #include "utility.hpp" extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { SimpleWeb::HttpHeader::FieldValue::SemicolonSeparatedAttributes::parse(std::string(reinterpret_cast<const char *>(data), size)); return 0; } tests/fuzzers/http_header_parse.cpp 0 → 100644 +9 −0 Original line number Diff line number Diff line #include "utility.hpp" #include <sstream> extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { std::stringstream ss; ss << std::string(reinterpret_cast<const char *>(data), size); SimpleWeb::HttpHeader::parse(ss); return 0; } Loading
CMakeLists.txt +3 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ project (Simple-Web-Server) option(USE_STANDALONE_ASIO "set ON to use standalone Asio instead of Boost.Asio" OFF) option(BUILD_TESTING "set ON to build library tests" OFF) option(BUILD_FUZZING "set ON to build library fuzzers" OFF) option(USE_OPENSSL "set OFF to build without OpenSSL" ON) add_library(simple-web-server INTERFACE) Loading Loading @@ -79,7 +80,9 @@ if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") install(FILES asio_compatibility.hpp server_http.hpp client_http.hpp server_https.hpp client_https.hpp crypto.hpp utility.hpp status_code.hpp mutex.hpp DESTINATION include/simple-web-server) endif() if(BUILD_TESTING OR BUILD_FUZZING) if(BUILD_TESTING) enable_testing() endif() add_subdirectory(tests) endif()
tests/CMakeLists.txt +37 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ if(NOT MSVC) add_compile_options(-Wno-thread-safety) endif() if(BUILD_TESTING) add_executable(io_test io_test.cpp) target_link_libraries(io_test simple-web-server) add_test(NAME io_test COMMAND io_test) Loading @@ -12,13 +13,48 @@ if(NOT MSVC) target_link_libraries(parse_test simple-web-server) add_test(NAME parse_test COMMAND parse_test) endif() endif() if(OPENSSL_FOUND) if(OPENSSL_FOUND AND BUILD_TESTING) add_executable(crypto_test crypto_test.cpp) target_link_libraries(crypto_test simple-web-server) add_test(NAME crypto_test COMMAND crypto_test) endif() if(BUILD_TESTING) add_executable(status_code_test status_code_test.cpp) target_link_libraries(status_code_test simple-web-server) add_test(NAME status_code_test COMMAND status_code_test) endif() if(BUILD_FUZZING) add_executable(percent_decode fuzzers/percent_decode.cpp) target_compile_options(percent_decode PRIVATE -fsanitize=address,fuzzer) target_link_options(percent_decode PRIVATE -fsanitize=address,fuzzer) target_link_libraries(percent_decode simple-web-server) add_executable(query_string_parse fuzzers/query_string_parse.cpp) target_compile_options(query_string_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(query_string_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(query_string_parse simple-web-server) add_executable(http_header_parse fuzzers/http_header_parse.cpp) target_compile_options(http_header_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(http_header_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(http_header_parse simple-web-server) add_executable(http_header_field_value_semicolon_separated_attributes_parse fuzzers/http_header_field_value_semicolon_separated_attributes_parse.cpp) target_compile_options(http_header_field_value_semicolon_separated_attributes_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(http_header_field_value_semicolon_separated_attributes_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(http_header_field_value_semicolon_separated_attributes_parse simple-web-server) add_executable(request_message_parse fuzzers/request_message_parse.cpp) target_compile_options(request_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(request_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(request_message_parse simple-web-server) add_executable(response_message_parse fuzzers/response_message_parse.cpp) target_compile_options(response_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_options(response_message_parse PRIVATE -fsanitize=address,fuzzer) target_link_libraries(response_message_parse simple-web-server) endif() No newline at end of file
tests/fuzzers/README.md 0 → 100644 +6 −0 Original line number Diff line number Diff line Prior to running the fuzzers, build and prepare for instance as follows: ```sh CXX=clang++ cmake -DBUILD_FUZZING=1 .. make export LSAN_OPTIONS=detect_leaks=0 ```
tests/fuzzers/http_header_field_value_semicolon_separated_attributes_parse.cpp 0 → 100644 +6 −0 Original line number Diff line number Diff line #include "utility.hpp" extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { SimpleWeb::HttpHeader::FieldValue::SemicolonSeparatedAttributes::parse(std::string(reinterpret_cast<const char *>(data), size)); return 0; }
tests/fuzzers/http_header_parse.cpp 0 → 100644 +9 −0 Original line number Diff line number Diff line #include "utility.hpp" #include <sstream> extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { std::stringstream ss; ss << std::string(reinterpret_cast<const char *>(data), size); SimpleWeb::HttpHeader::parse(ss); return 0; }