Skip to content
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

increase fuzzing coverage #677

Merged
merged 1 commit into from
May 29, 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
26 changes: 21 additions & 5 deletions fuzz/parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
length += out_url->get_origin().size();
length += out_url->get_port().size();

out_url->to_string();
length += out_url->to_string().size();
}

/**
Expand Down Expand Up @@ -184,9 +184,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
length += out_aggregator->get_origin().size();
length += out_aggregator->get_port().size();

out_aggregator->to_string();
out_aggregator->to_diagram();
out_aggregator->validate();
volatile bool is_output_valid = false;
length += out_aggregator->to_string().size();
is_output_valid = out_aggregator->validate();

// Printing due to dead-code elimination
printf("diagram %s\n", out_aggregator->to_diagram().c_str());

// clear methods
out_aggregator->clear_port();
Expand All @@ -197,7 +200,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
/**
* Node.js specific
*/
ada::href_from_file(source);
length += ada::href_from_file(source).size();

/**
* Others
*/
bool is_valid = ada::checkers::verify_dns_length(source);

// Only used for avoiding dead-code elimination
if (is_valid) {
printf("dns length is valid\n");
}

// Only used for avoiding dead-code elimination
printf("length of url is %d\n", length);

return 0;
} // extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
31 changes: 25 additions & 6 deletions fuzz/url.dict
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
"ftp://"
"file://"
"http://"
"https://"
"ws://"
"wss://"
# Protocols
"ftp:"
"file:"
"http:"
"https:"
"ws:"
"wss:"

# Suffixes
".com"

# Full URLs
"https://www.ada-url.com"

# Encoded characters
"%2f"
"%40"
"%26"

# Misc
"://"
"//"
"\\"
"../"
";type=a"
"xn--"
Loading