aboutsummaryrefslogtreecommitdiffstats
path: root/askama_parser/fuzz
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_parser/fuzz/.gitignore4
-rw-r--r--askama_parser/fuzz/Cargo.toml27
-rw-r--r--askama_parser/fuzz/README.md14
-rw-r--r--askama_parser/fuzz/fuzz_targets/fuzz_parser.rs13
4 files changed, 58 insertions, 0 deletions
diff --git a/askama_parser/fuzz/.gitignore b/askama_parser/fuzz/.gitignore
new file mode 100644
index 0000000..1a45eee
--- /dev/null
+++ b/askama_parser/fuzz/.gitignore
@@ -0,0 +1,4 @@
+target
+corpus
+artifacts
+coverage
diff --git a/askama_parser/fuzz/Cargo.toml b/askama_parser/fuzz/Cargo.toml
new file mode 100644
index 0000000..3190e5a
--- /dev/null
+++ b/askama_parser/fuzz/Cargo.toml
@@ -0,0 +1,27 @@
+[package]
+name = "askama_parser-fuzz"
+version = "0.0.0"
+publish = false
+edition = "2021"
+
+[package.metadata]
+cargo-fuzz = true
+
+[dependencies]
+libfuzzer-sys = "0.4"
+
+[dependencies.askama_parser]
+path = ".."
+
+# Prevent this from interfering with workspaces
+[workspace]
+members = ["."]
+
+[profile.release]
+debug = 1
+
+[[bin]]
+name = "fuzz_parser"
+path = "fuzz_targets/fuzz_parser.rs"
+test = false
+doc = false
diff --git a/askama_parser/fuzz/README.md b/askama_parser/fuzz/README.md
new file mode 100644
index 0000000..6f6c2a1
--- /dev/null
+++ b/askama_parser/fuzz/README.md
@@ -0,0 +1,14 @@
+# Fuzzing
+
+Install `cargo-fuzz`:
+
+```sh
+cargo install -f cargo-fuzz
+```
+
+Run any available target where `$target` is the name of the target.
+
+```sh
+cargo fuzz list # get list of targets
+cargo +nightly fuzz run $target
+``` \ No newline at end of file
diff --git a/askama_parser/fuzz/fuzz_targets/fuzz_parser.rs b/askama_parser/fuzz/fuzz_targets/fuzz_parser.rs
new file mode 100644
index 0000000..374936c
--- /dev/null
+++ b/askama_parser/fuzz/fuzz_targets/fuzz_parser.rs
@@ -0,0 +1,13 @@
+#![no_main]
+use askama_parser::*;
+use libfuzzer_sys::fuzz_target;
+use std::str;
+
+fuzz_target!(|data: &[u8]| {
+ // fuzzed code goes here
+ if data.len() < 500 {
+ if let Ok(data) = str::from_utf8(data) {
+ if let Ok(_) = Ast::from_str(data, &Syntax::default()) {}
+ }
+ }
+});