Skip to content

Commit

Permalink
chore(fuzz): Add fuzzing tests for assured reliability
Browse files Browse the repository at this point in the history
mike-engel committed Sep 22, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 904c157 commit 4bbb5ea
Showing 8 changed files with 93 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
target/
**/*.rs.bk
Cargo.lock
fuzz/artifacts
fuzz/corpus
fuzz/target
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 1.2.1

> 2018-09-22
#### Bug fixes

- accept-language-rs is now testing with cargo-fuzz. You can find the test results in the [README.md](README.md) file
- Compile and test with the latest version of stable rust

# 1.2.0

> 2018-07-07
#### Minor changes

- Don't auto-capitalize language codes [[#3](https://github.com/mike-engel/accept-language-rs/pull/3)]

# 1.1.1

> 2018-06-23
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ documentation = "https://docs.rs/accept-language"
license = "MIT"
keywords = ["accept-language", "i18n", "internationalization", "header", "parser"]
categories = ["parsing"]
version = "1.2.0"
version = "1.2.1"
authors = ["Mike Engel <[email protected]>", "Sean Stangl"]

[dependencies]
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -19,6 +19,26 @@ let common_languages = intersection("en-US, en-GB;q=0.5", vec!["en-US", "de", "e

For more info and to view the full documentation, check them out on [docs.rs](https://docs.rs/accept-language).

# Stability

`accept-language` is fuzz tested with [`cargo-fuzz`](). As of `1.2.1`, these are the results of both fuzz tests for `parse` and `intersection` respectively.

**`parse`**

```sh
cargo fuzz run -O parse -- -max_total_time=60
...
Done 926619 runs in 61 second(s)
```

**`intersection`**

```sh
cargo fuzz run -O intersection -- -max_total_time=60
...
Done 846914 runs in 61 second(s)
```

# Contributing

Contributions are always welcome! If you found a bug, please submit an issue. If you'd like to submit a patch or feature, feel free to submit a pull request. [rustfmt](https://github.com/rust-lang-nursery/rustfmt) should be used to have consistent code formatting throughout the project.
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

target
corpus
artifacts
26 changes: 26 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

[package]
name = "accept-language-fuzz"
version = "1.0.0"
authors = ["Automatically generated"]
publish = false

[package.metadata]
cargo-fuzz = true

[dependencies.accept-language]
path = ".."
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "parse"
path = "fuzz_targets/parse.rs"

[[bin]]
name = "intersection"
path = "fuzz_targets/intersection.rs"
11 changes: 11 additions & 0 deletions fuzz/fuzz_targets/intersection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
extern crate accept_language;

#[cfg_attr(rustfmt, rustfmt_skip)]
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
accept_language::intersection(s, vec!["en-US", "en", "de-DE"]);
}
});
11 changes: 11 additions & 0 deletions fuzz/fuzz_targets/parse.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
extern crate accept_language;

#[cfg_attr(rustfmt, rustfmt_skip)]
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
accept_language::parse(s);
}
});

0 comments on commit 4bbb5ea

Please sign in to comment.