-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fuzzing setup for
Message::decode
Co-authored-by: kpcyrd <[email protected]> Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
- Loading branch information
Showing
6 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "ssh-agent-lib-fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
ssh-encoding = "0.2.0" | ||
|
||
[dependencies.ssh-agent-lib] | ||
path = ".." | ||
|
||
[[bin]] | ||
name = "message_decode" | ||
path = "fuzz_targets/message_decode.rs" | ||
test = false | ||
doc = false | ||
bench = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Fuzzing | ||
|
||
This directory contains fuzzing targets for ssh-agent-lib. | ||
|
||
## Setup | ||
|
||
Install [`cargo-fuzz`](https://crates.io/crates/cargo-fuzz): | ||
|
||
```sh | ||
cargo install --locked cargo-fuzz | ||
``` | ||
|
||
## Running | ||
|
||
Select a target from the list printed by `cargo fuzz list` e.g. `message_decode`: | ||
|
||
```sh | ||
cargo +nightly fuzz run message_decode | ||
``` | ||
|
||
Options that can be added to the `fuzz run` command: | ||
|
||
- `--jobs N` - increase parallelism, | ||
- `--sanitizer none` - disable sanitizer since ssh-agent-lib does not use any `unsafe` blocks, | ||
|
||
Note that due to a limitation of cargo-fuzz nightly version of the toolchain is required. | ||
|
||
For more details see [Fuzzing with cargo-fuzz](https://rust-fuzz.github.io/book/cargo-fuzz.html) or the [more detailed explanation of fuzzing output](https://github.com/rust-fuzz/cargo-fuzz/issues/72#issuecomment-284448618) in a `cargo-fuzz` comment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use ssh_agent_lib::proto::message::Message; | ||
use ssh_encoding::Decode; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
let _ = Message::decode(&mut &data[..]); | ||
}); |