-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package example | ||
|
||
// Function you want to fuzz, but requires the input to be formatted | ||
// against complex rules. | ||
func Function(in []byte) { | ||
// ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package example | ||
|
||
import ( | ||
_ "embed" | ||
"testing" | ||
|
||
goabnf "github.com/pandatix/go-abnf" | ||
) | ||
|
||
//go:embed my-grammar.abnf | ||
var myGrammar []byte | ||
|
||
func FuzzFunction(f *testing.F) { | ||
g, err := goabnf.ParseABNF(myGrammar) | ||
if err != nil { | ||
f.Fatal(err) | ||
} | ||
|
||
f.Fuzz(func(t *testing.T, seed int64) { | ||
// Generate a random test case based on the seed | ||
b, _ := g.Generate(seed, "a", | ||
goabnf.WithRepMax(15), // Limit repetitions to 15 | ||
goabnf.WithThreshold(1024), // Stop ASAP input generation if reached 1024 bytes | ||
) | ||
|
||
Function(b) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a = "a" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.