This repository was archived by the owner on Nov 14, 2022. It is now read-only.
File tree 4 files changed +70
-0
lines changed
4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Fuzzing
2
+
3
+ ## Installing ` honggfuzz `
4
+
5
+ ```
6
+ cargo install honggfuzz
7
+ ```
8
+
9
+ Install [ dependencies] ( https://github.com/rust-fuzz/honggfuzz-rs#dependencies ) for your system.
10
+
11
+ ## Running the fuzzer
12
+
13
+ Running the fuzzer is as easy as running in the ` fuzz ` directory.
14
+
15
+ Choose a target:
16
+
17
+ These are ` [[bin]] ` entries in ` Cargo.toml ` .
18
+ List them with ` cargo read-manifest | jq '.targets[].name' ` from the ` fuzz ` directory.
19
+
20
+ Run the fuzzer:
21
+
22
+ ``` shell
23
+ cd fuzz
24
+ cargo hfuzz run < target>
25
+ ```
26
+
27
+ After a panic is found, get a stack trace with:
28
+
29
+ ``` shell
30
+ cargo hfuzz run-debug < target> hfuzz_workspace/< target> /* .fuzz
31
+ ```
32
+
33
+ For example, with the ` fuzz_parse_sql ` target:
34
+
35
+ ``` shell
36
+ cargo hfuzz run fuzz_parse_sql
37
+ cargo hfuzz run-debug fuzz_parse_sql hfuzz_workspace/fuzz_parse_sql/* .fuzz
38
+ ```
Original file line number Diff line number Diff line change
1
+ corpus
2
+ hfuzz_target
3
+ hfuzz_workspace
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " fuzz"
3
+ version = " 0.1.0"
4
+ edition = " 2018"
5
+ publish = false
6
+
7
+ [dependencies ]
8
+ honggfuzz = " 0.5.54"
9
+ sqlparser = { path = " .." }
10
+
11
+ # Prevent this from interfering with workspaces
12
+ [workspace ]
13
+ members = [" ." ]
14
+
15
+ [[bin ]]
16
+ name = " fuzz_parse_sql"
17
+ path = " fuzz_targets/fuzz_parse_sql.rs"
Original file line number Diff line number Diff line change
1
+ use honggfuzz:: fuzz;
2
+ use sqlparser:: dialect:: GenericDialect ;
3
+ use sqlparser:: parser:: Parser ;
4
+
5
+ fn main ( ) {
6
+ loop {
7
+ fuzz ! ( |data: String | {
8
+ let dialect = GenericDialect { } ;
9
+ let _ = Parser :: parse_sql( & dialect, & data) ;
10
+ } ) ;
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments