-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted fuzzing to Go 1.18 native fuzzing (#157)
- Loading branch information
1 parent
5acbf84
commit 2b29b4e
Showing
2 changed files
with
22 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package jwt | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// How to run: `go test -fuzz=FuzzParseNoVerify -parallel=32` | ||
func FuzzParseNoVerify(f *testing.F) { | ||
f.Add([]byte("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1MDUxODI5Mzg2ODc2NTc3MTIzIiwibmFtZSI6IjdNZUNSbG9xSXAiLCJpYXQiOjE3MjA1NTM4NDV9.QW7kzr70jrbZpPV4")) | ||
f.Add([]byte("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")) | ||
f.Add([]byte("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.invalid_signature")) | ||
f.Add([]byte("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9")) | ||
f.Add([]byte("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.")) | ||
f.Add([]byte("")) | ||
f.Add([]byte("random bytes")) | ||
|
||
f.Fuzz(func(t *testing.T, data []byte) { | ||
if _, err := ParseNoVerify(data); err != nil { | ||
t.Skip() | ||
} | ||
}) | ||
} |