Add fuzzing test for sailfish-compiler

cc #26
This commit is contained in:
Kogia-sima 2020-07-14 22:27:51 +09:00
parent b420cc0161
commit 4d548bdb94
8 changed files with 93 additions and 0 deletions

View File

@ -66,6 +66,7 @@ version = "0.1.3"
dependencies = [
"afl",
"sailfish",
"sailfish-compiler",
]
[[package]]
@ -89,6 +90,36 @@ version = "0.2.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
[[package]]
name = "linked-hash-map"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]]
name = "proc-macro2"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
@ -113,6 +144,17 @@ dependencies = [
"version_check",
]
[[package]]
name = "sailfish-compiler"
version = "0.1.3"
dependencies = [
"memchr",
"proc-macro2",
"quote",
"syn",
"yaml-rust",
]
[[package]]
name = "semver"
version = "0.9.0"
@ -134,6 +176,17 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "textwrap"
version = "0.11.0"
@ -149,6 +202,12 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -188,3 +247,12 @@ name = "xdg"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
[[package]]
name = "yaml-rust"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d"
dependencies = [
"linked-hash-map",
]

View File

@ -10,3 +10,4 @@ publish = false
[dependencies]
afl = "0.8.0"
sailfish = { path = "../sailfish" }
sailfish-compiler = { path = "../sailfish-compiler" }

View File

@ -0,0 +1 @@
<h1><%= message %></h1>

View File

@ -0,0 +1,9 @@
<table>
<% for i in 1..=9 %>
<tr>
<% for j in 1..=9 %>
<td><%= i * j %></td>
<% } %>
</td>
<% } %>
</table>

View File

@ -0,0 +1,14 @@
#[macro_use]
extern crate afl;
use sailfish_compiler::Compiler;
fn main() {
fuzz!(|data: &[u8]| {
// HTML escaping
if let Ok(feed) = std::str::from_utf8(data) {
let compiler = Compiler::default();
let _ = compiler.compile_str(feed);
}
});
}