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.

47 lines
881 B

  1. // nolint: gosec
  2. package main
  3. import (
  4. "flag"
  5. "fmt"
  6. "log"
  7. "os"
  8. "path/filepath"
  9. )
  10. func main() {
  11. baseDir := flag.String("base", ".", `where the "corpus" directory will live`)
  12. flag.Parse()
  13. initCorpus(*baseDir)
  14. }
  15. func initCorpus(baseDir string) {
  16. log.SetFlags(0)
  17. corpusDir := filepath.Join(baseDir, "corpus")
  18. if err := os.MkdirAll(corpusDir, 0755); err != nil {
  19. log.Fatal(err)
  20. }
  21. data := []string{
  22. "dadc04c2-cfb1-4aa9-a92a-c0bf780ec8b6",
  23. "",
  24. " ",
  25. " a ",
  26. `{"a": 12, "tsp": 999, k: "blue"}`,
  27. `9999.999`,
  28. `""`,
  29. `Tendermint fuzzing`,
  30. }
  31. for i, datum := range data {
  32. filename := filepath.Join(corpusDir, fmt.Sprintf("%d", i))
  33. if err := os.WriteFile(filename, []byte(datum), 0644); err != nil {
  34. log.Fatalf("can't write %v to %q: %v", datum, filename, err)
  35. }
  36. log.Printf("wrote %q", filename)
  37. }
  38. }