Skip to content

Commit

Permalink
Adjusted fuzzing to Go 1.18 native fuzzing (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonohana627 authored Jul 10, 2024
1 parent 5acbf84 commit 2b29b4e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
18 changes: 0 additions & 18 deletions fuzz.go

This file was deleted.

22 changes: 22 additions & 0 deletions fuzz_test.go
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()
}
})
}

0 comments on commit 2b29b4e

Please sign in to comment.