forked from chronotope/chrono
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a fuzzer as integration to OSS-Fuzz. (chronotope#463)
* Added a fuzzer. * Added a README for the fuzzer set up.
- Loading branch information
1 parent
8d66a68
commit 370a20c
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
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 |
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,24 @@ | ||
|
||
[package] | ||
name = "chrono-fuzz" | ||
version = "0.0.0" | ||
authors = ["David Korczynski <[email protected]>"] | ||
publish = false | ||
edition = "2018" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.3" | ||
|
||
[dependencies.chrono] | ||
path = ".." | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[[bin]] | ||
name = "fuzz_reader" | ||
path = "fuzz_targets/fuzz_reader.rs" |
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,12 @@ | ||
# Fuzzing Chrono | ||
To fuzz Chrono we rely on the [Cargo-fuzz](https://rust-fuzz.github.io/) project. | ||
|
||
To install cargo-fuzz: | ||
``` | ||
cargo install cargo-fuzz | ||
``` | ||
|
||
To run the Chrono fuzzer, navigate to the top directory of chrono and issue the following command: | ||
``` | ||
cargo-fuzz run fuzz_reader | ||
``` |
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,10 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
use chrono::prelude::*; | ||
if let Ok(data) = std::str::from_utf8(data) { | ||
let _ = DateTime::parse_from_rfc2822(data); | ||
let _ = DateTime::parse_from_rfc3339(data); | ||
} | ||
}); |