mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-27 04:50:52 +00:00
Added a fuzzer as integration to OSS-Fuzz. (#463)
* Added a fuzzer. * Added a README for the fuzzer set up.
This commit is contained in:
parent
8d66a68e47
commit
370a20cb71
4
fuzz/.gitignore
vendored
Normal file
4
fuzz/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
target
|
||||||
|
corpus
|
||||||
|
artifacts
|
24
fuzz/Cargo.toml
Normal file
24
fuzz/Cargo.toml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
[package]
|
||||||
|
name = "chrono-fuzz"
|
||||||
|
version = "0.0.0"
|
||||||
|
authors = ["David Korczynski <david@adalogics.com>"]
|
||||||
|
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"
|
12
fuzz/README.md
Normal file
12
fuzz/README.md
Normal file
@ -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
|
||||||
|
```
|
10
fuzz/fuzz_targets/fuzz_reader.rs
Normal file
10
fuzz/fuzz_targets/fuzz_reader.rs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user