-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fuzz the expr command #4642
Fuzz the expr command #4642
Conversation
4536baa
to
9c9fc84
Compare
9c9be73
to
3c02dfe
Compare
3c02dfe
to
afe48a3
Compare
f1762a8
to
b689ed0
Compare
@@ -149,6 +149,13 @@ jobs: | |||
## Run it | |||
cd fuzz | |||
cargo +nightly fuzz run fuzz_test -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 | |||
- name: Run fuzz_expr for XX seconds | |||
continue-on-error: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b689ed0
to
e5988bd
Compare
as expected, fails quickly:
|
e5988bd
to
ec7ced2
Compare
fn generate_random_string(max_length: usize) -> String { | ||
let mut rng = rand::thread_rng(); | ||
let valid_utf8: Vec<char> = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" | ||
.chars() | ||
.collect(); | ||
let invalid_utf8 = [0xC3, 0x28]; // Invalid UTF-8 sequence | ||
let mut result = String::new(); | ||
|
||
for _ in 0..rng.gen_range(1..=max_length) { | ||
if rng.gen_bool(0.9) { | ||
let ch = valid_utf8.choose(&mut rng).unwrap(); | ||
result.push(*ch); | ||
} else { | ||
let ch = invalid_utf8.choose(&mut rng).unwrap(); | ||
if let Some(c) = char::from_u32(*ch as u32) { | ||
result.push(c); | ||
} | ||
} | ||
} | ||
|
||
result | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function looks like a candidate for fuzz_common.rs
as it is used in fuzz_test.rs
, too.
.to_string() | ||
.trim() | ||
.to_owned(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 111 - 156 also look like a candidate for fuzz_common.rs
, they seem to be identical to the code in fuzz_test.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :) My suggestions are probably more something for a future PR.
agreed, it was part of my place to refactor some of the code :) |
Based on:
#4641