Merge pull request #58 from 5225225/fuzzy

Add fuzzing harness, in order to find panics through invalid input
This commit is contained in:
PaddiM8 2021-09-22 14:42:00 +02:00 committed by GitHub
commit a7ad38b6fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

4
kalk/fuzz/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
target
corpus
artifacts

26
kalk/fuzz/Cargo.toml Normal file
View File

@ -0,0 +1,26 @@
[package]
name = "kalk-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
[dependencies.kalk]
path = ".."
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "parse"
path = "fuzz_targets/parse.rs"
test = false
doc = false

View File

@ -0,0 +1,10 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &str| {
let mut ctx = kalk::parser::Context::new().set_timeout(Some(5));
// We don't care if it parses or not, we only care about if it panicked
// while parsing
let _ = kalk::parser::parse(&mut ctx, data);
});