Skip to content

Commit 16dafec

Browse files
author
me
committed
more cov
1 parent ab0220b commit 16dafec

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

.github/workflows/coverage.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
-DCMAKE_C_COMPILER=clang \
2828
-DCMAKE_CXX_COMPILER=clang++ \
2929
-DHTTP_BUILD_FUZZERS=ON
30-
cmake --build build --target request_parser response_parser sha1 base64 --parallel
30+
cmake --build build --target request_parser response_parser websocket_parser sha1 base64 --parallel
3131
3232
- name: Extract corpus
3333
run: |
@@ -36,8 +36,9 @@ jobs:
3636
- name: Run fuzzers
3737
run: |
3838
mkdir -p /tmp/corpus
39-
LLVM_PROFILE_FILE="request.profraw" ./build/request_parser /tmp/corpus/ seeds/request_parser/ -max_total_time=30
40-
LLVM_PROFILE_FILE="response.profraw" ./build/response_parser /tmp/corpus/ seeds/response_parser/ -max_total_time=30
39+
LLVM_PROFILE_FILE="request.profraw" ./build/request_parser /tmp/corpus/ seeds/request_parser/ -max_total_time=30
40+
LLVM_PROFILE_FILE="response.profraw" ./build/response_parser /tmp/corpus/ seeds/response_parser/ -max_total_time=30
41+
LLVM_PROFILE_FILE="websocket.profraw" ./build/websocket_parser /tmp/corpus/ seeds/websocket_parser/ -max_total_time=30
4142
LLVM_PROFILE_FILE="sha1.profraw" ./build/sha1 -max_total_time=30
4243
LLVM_PROFILE_FILE="base64.profraw" ./build/base64 -max_total_time=30
4344
@@ -46,11 +47,13 @@ jobs:
4647
llvm-profdata merge -o coverage.profdata \
4748
request.profraw \
4849
response.profraw \
50+
websocket.profraw \
4951
sha1.profraw \
5052
base64.profraw
5153
llvm-cov export -format=lcov -instr-profile coverage.profdata \
5254
-object ./build/request_parser \
5355
-object ./build/response_parser \
56+
-object ./build/websocket_parser \
5457
-object ./build/sha1 \
5558
-object ./build/base64 \
5659
-sources ./src \

examples/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ if (HTTP_BUILD_FUZZERS)
7373
target_link_options(${target_name} PRIVATE -fsanitize=fuzzer -fprofile-instr-generate -fcoverage-mapping)
7474
endfunction()
7575

76-
add_fuzz(request_parser fuzz/request_parser.cpp)
77-
add_fuzz(response_parser fuzz/response_parser.cpp)
78-
add_fuzz(sha1 fuzz/sha1.cpp)
79-
add_fuzz(base64 fuzz/base64.cpp)
76+
add_fuzz(request_parser fuzz/request_parser.cpp)
77+
add_fuzz(response_parser fuzz/response_parser.cpp)
78+
add_fuzz(websocket_parser fuzz/websocket_parser.cpp)
79+
add_fuzz(sha1 fuzz/sha1.cpp)
80+
add_fuzz(base64 fuzz/base64.cpp)
8081
endif()

examples/fuzz/seeds.tgz

260 Bytes
Binary file not shown.

examples/fuzz/websocket_parser.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <cstdint>
2+
#include <cstddef>
3+
#include <http.h>
4+
5+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
6+
{
7+
std::string buf(reinterpret_cast<const char*>(data), size);
8+
9+
http::request req{};
10+
std::error_code ec{};
11+
http::parser<http::request> parser;
12+
parser.parse(req, buf, ec);
13+
bool is_websocket_req = req.is_websocket_req();
14+
15+
std::vector<char> msg;
16+
http::websocket_parser ws_parser;
17+
ws_parser.parse(msg, buf, ec);
18+
const auto opcode = ws_parser.get_opcode();
19+
const auto is_server = ws_parser.is_server();
20+
return 0;
21+
}

0 commit comments

Comments
 (0)