Skip to content

Commit

Permalink
Add partial instrumentation example
Browse files Browse the repository at this point in the history
  • Loading branch information
louismerlin committed Nov 13, 2024
1 parent 368f950 commit 77fa36d
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
".",
"examples/arbitrary",
"examples/asan",
"examples/partial",
"examples/url",
]

Expand Down
11 changes: 11 additions & 0 deletions examples/partial/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "partial-fuzz"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
ziggy = { path = "../../", default-features = false }

[features]
fuzzing = []
1 change: 1 addition & 0 deletions examples/partial/allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src:src/allowed.rs
1 change: 1 addition & 0 deletions examples/partial/blocklist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src:src/blocked.rs
5 changes: 5 additions & 0 deletions examples/partial/src/allowed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub fn allowed(data: &[u8]) {
if data[0] == b'a' && data[1] == b'l' && data[2] == b'l' && data[3] == b'o' {
println!("Wow!");
}
}
5 changes: 5 additions & 0 deletions examples/partial/src/blocked.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub fn blocked(data: &[u8]) {
if data[0] == b'b' && data[1] == b'l' && data[2] == b'o' && data[3] == b'c' {
panic!("This was blocked");
}
}
14 changes: 14 additions & 0 deletions examples/partial/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod blocked;
mod allowed;
mod other;

fn main() {
ziggy::fuzz!(|data: &[u8]| {
if data.len() < 4 {
return
}
allowed::allowed(&data);
blocked::blocked(&data);
other::other(&data);
});
}
5 changes: 5 additions & 0 deletions examples/partial/src/other.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub fn other(data: &[u8]) {
if data[0] == b'o' && data[1] == b't' && data[2] == b'h' && data[3] == b'e' {
println!("Another one");
}
}

0 comments on commit 77fa36d

Please sign in to comment.