Skip to content

Slow inputs example #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
17 changes: 17 additions & 0 deletions .cifuzz-findings/philosophical_capybara/finding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "philosophical_capybara",
"type": "WARNING",
"input_data": "inGKcf+S3ESO5gI73P////////8BAFBgAABaIP9DjuaC",
"logs": [
"Slow input: 38 seconds for processing",
"artifact_prefix='/tmp/libfuzzer-out-2077056338/'; Test unit written to .cifuzz-findings/philosophical_capybara/crashing-input",
"Base64: inGKcf+S3ESO5gI73P////////8BAFBgAABaIP9DjuaC"
],
"details": "Slow input detected. Processing time: 38 s",
"more_details": {
"id": "slow_input"
},
"created_at": "2024-08-22T09:02:49.692610917Z",
"input_file": ".cifuzz-findings/philosophical_capybara/crashing-input",
"fuzz_test": "slow_input_checks_fuzz_test"
}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ lcov.info

.cifuzz-findings/*
!.cifuzz-findings/awesome_gnu/

.cifuzz-findings/awesome_gnu/.lock
.cifuzz-findings/awesome_gnu/.lock
!.cifuzz-findings/philosophical_capybara/
.cifuzz-findings/philosophical_capybara/.lock
3 changes: 3 additions & 0 deletions src/advanced_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ endif()
foreach(TestType IN ITEMS
structured_input_checks
custom_mutator_example_checks
slow_input_checks
)

add_executable(${TestType}_test
Expand All @@ -69,6 +70,8 @@ foreach(TestType IN ITEMS

add_fuzz_test(${TestType}_fuzz_test
${TestType}_test.cpp
TEST_FRAMEWORK
GTEST
)

target_link_libraries(${TestType}_fuzz_test
Expand Down
15 changes: 15 additions & 0 deletions src/advanced_examples/explore_me.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstring>
#include <zlib.h>
#include <iostream>
#include "explore_me.h"

static long insecureEncrypt(long input);
Expand Down Expand Up @@ -32,6 +33,20 @@ void ExploreCompressedInputChecks(const uint8_t *Data, size_t Size){
}
}

void ExploreSlowInputsChecks(int a, int b){
if (a == 48664131) {
for (int i = 0; i < b; i++) {
if (i % 100'000'000 == 0) {
std::cerr << "In loop at position: "
<< std::to_string(i)
<< " of "
<< std::to_string(b)
<< std::endl;
}
}
}
}

static long insecureEncrypt(long input) {
long key = 0xefe4eb93215cb6b0L;
return input ^ key;
Expand Down
1 change: 1 addition & 0 deletions src/advanced_examples/explore_me.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ struct InputStruct {

void ExploreStructuredInputChecks(InputStruct inputStruct);
void ExploreCompressedInputChecks(const uint8_t *Data, size_t Size);
void ExploreSlowInputsChecks(int a, int b);
22 changes: 22 additions & 0 deletions src/advanced_examples/slow_input_checks_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <cifuzz/cifuzz.h>
#include <fuzzer/FuzzedDataProvider.h>

#include "explore_me.h"
#include <gtest/gtest.h>

TEST(ExploreSlowInputsChecks, FirstTest) {

EXPECT_NO_THROW(ExploreSlowInputsChecks(23323, 100));
}

TEST(ExploreSlowInputsChecks, SecondTest) {
EXPECT_NO_THROW(ExploreSlowInputsChecks(1324153, 192198));
}

DEBUG_FINDING(philosophical_capybara)
FUZZ_TEST(const uint8_t *data, size_t size) {
FuzzedDataProvider fdp(data, size);
long a = fdp.ConsumeIntegral<int>();
long b = fdp.ConsumeIntegral<int>();
ExploreSlowInputsChecks(a,b);
}