You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
764 B

  1. package main
  2. import (
  3. "fmt"
  4. "io"
  5. "math/rand"
  6. "os"
  7. "reflect"
  8. "testing/quick"
  9. "github.com/gorilla/securecookie"
  10. )
  11. var hashKey = []byte("very-secret12345")
  12. var blockKey = []byte("a-lot-secret1234")
  13. var s = securecookie.New(hashKey, blockKey)
  14. type Cookie struct {
  15. B bool
  16. I int
  17. S string
  18. }
  19. func main() {
  20. var c Cookie
  21. t := reflect.TypeOf(c)
  22. rnd := rand.New(rand.NewSource(0))
  23. for i := 0; i < 100; i++ {
  24. v, ok := quick.Value(t, rnd)
  25. if !ok {
  26. panic("couldn't generate value")
  27. }
  28. encoded, err := s.Encode("fuzz", v.Interface())
  29. if err != nil {
  30. panic(err)
  31. }
  32. f, err := os.Create(fmt.Sprintf("corpus/%d.sc", i))
  33. if err != nil {
  34. panic(err)
  35. }
  36. _, err = io.WriteString(f, encoded)
  37. if err != nil {
  38. panic(err)
  39. }
  40. f.Close()
  41. }
  42. }