Skip to content

Commit

Permalink
fuzz: add types.ParseCoin (#8513)
Browse files Browse the repository at this point in the history
Updates #7921
  • Loading branch information
Cuong Manh Le authored Mar 22, 2021
1 parent 59ea84b commit bdec2b2
Show file tree
Hide file tree
Showing 115 changed files with 182 additions and 0 deletions.
20 changes: 20 additions & 0 deletions fuzz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Fuzzing

## Installation

```
go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
```

## Preparing

Create own go package under `fuzz` directory, which contains the function that you want to fuzz. See `fuzz/types/ParseCoin`
for example, which has example for how to generating corpus and directory structure.

## Running

```
$ cd types/ParseCoin
$ go-fuzz-build
$ go-fuzz
```
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c;۠     
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
02723020666751402211777651274057615023250.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6944695195361415446930700890931692099581386864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151687451416053935972929274569212053128963117210175788882384896278380661454255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6944695195361415446930700890931692099581386864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151687451416053935972929274569212053128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
����
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��۠     
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0a⇗
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4545549772963113914895361415446930700890931692099581386864797660130609714981900799081393217264634591855431833976560521225596406614545549772963113914895361415446930700890931692099581386864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296370089093169209958138686479766013060971498190079908139321726943530014330540939446345918554318339765605212255964066145455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172646345918554318339765605212255964064634455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172694353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151687085803712198799971664381257402829111505715168745141605393597292927456921203812574028291115057151685312891139148085803712198799971664381257402829111505715168708580371219879997166438125740282911150571516874514160539359729294353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929274569212038125740282911150571516853128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c;۠   
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
  5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ҩ�


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
٩٩


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
� 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��۠         
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
33634694469519536141544693070089093169209958138687451416053935972929274569212053128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�⭯   
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
536141544693070089093169209958138686479766013060971498190079908139321726943530014330540939446345918554318339765605212255964066145455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172694353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929274569212038125740282911150571516853128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�  
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
         ‭                
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0ake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
53365159055017425 stak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
٩ 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���� 


  
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
365159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
٩

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
‿                                   
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
𝕒
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
  5sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@



Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
 ٩ 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6930700890931692099581386864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391489536141544693070089093169209958138686479766013060971498190079908139321726463459185543183397656052122559640661454554977296311391489536141544693070089093169209958138686479766013060971498190079908139321726943530014330540939446345918554318339765605212255964066145455497729631139148085803712198799971664381257402829111505715168708580371219879997166438125740282911150571516874514160539359729294353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929274569212038125740282911150571516853128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
𝕒𝕒
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
         ‭ 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15014460159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�� 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1X��
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
      ‭ 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
٩٩




Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
����
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3365159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3008909316920995813868647976601306097149819007990813932172694353001433054093944634591855431833976560521225596406614545549772963113914895361415446930700890931692099581386864797660130609714981900799081393217264634591855431833976560521225596406614545549772963113914895361415446930700890931692099581386864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296370089093169209958138686479766013060971498190079908139321726943530014330540939446345918554318339765605212255964066145455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172646345918554318339765605212255964064634455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172694353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151687085803712198799971664381257402829111505715168745141605393597292927456921203812574028291115057151685312891139148085803712198799971664381257402829111505715168708580371219879997166438125740282911150571516874514160539359729294353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929274569212038125740282911150571516853128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
35014460159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
115792089210356248762697446949407573530086143415290314195533631308867097853951dst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��۠                

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

‭
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
         ‭          
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
  ‭�‭ 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5336346944695195361418882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08sss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
7

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3686479766013060971498190079908139321726943530014330540939446345918554318339765605212255964066145455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172646345918554318339765605212255964066145455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172694353001433054093944634591855431833976560521225596406614545549772963700890931692099581386864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391489536141544693070089093964066145455497729631139148085803712198799971664381257402829111505715168708580371219879997166438125740282911150571516874514160539359729294353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929274569212038125740282911150571516853128911391480858037121987999716643812574028291115057151687085803712198799971664381257402829111505715168745141605393597292943530014330540939446345918554318339765605212255964066145455497729631139148085803712198799971664381257402829111505715168708580371219879997166438125740282911150571516874514160539359729292745692120381257402829111505715168531289616920995813868647976601306097149819007990813932172646345918554318339765605212255964064634455497729631139148953614154469307008909316920995813868647976601306097149819007990813932172694353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151687085803712198799971664381257402829111505715168745141605393597292927456921203812574028291115057151685312891139148085803712198799971664381257402829111505715168708580371219879997166438125740282911150571516874514160539359729294353001433054093944634591855431833976560521225596406614545549772963113914808580371219879997166438125740282911150571516870858037121987999716643812574028291115057151687451416053935972929274569212038125740282911150571516853128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
350144601590527230206665017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
95195361415446930700890931692099581386864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151687451416053935972929274569212038125740282911150571516853128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�⭯ 


  
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0sssssssssssssssssssssss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
         ‭                          
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
����

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0sss                                
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5195361415446930700833976560521225596406614545549772963113914808580371219879997166438125740282911150571516874514160539359729292745692120531290931692099581386864797660130609714981900799081393217269435300143545409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151687451416053935972929274569212053128963117210175788882384896278381347656255159055017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0^ke
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
   ‭ 
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
35014462842170943040400743484497070312501590527230206665017425sta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
1 change: 1 addition & 0 deletions fuzz/types/ParseCoin/corpus/leading_space.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10stake
1 change: 1 addition & 0 deletions fuzz/types/ParseCoin/corpus/less_than_3char_denom.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10s
1 change: 1 addition & 0 deletions fuzz/types/ParseCoin/corpus/minus_sign.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-10stake
1 change: 1 addition & 0 deletions fuzz/types/ParseCoin/corpus/no_denom.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
1 change: 1 addition & 0 deletions fuzz/types/ParseCoin/corpus/plus_sign.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+10stake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10 stake
1 change: 1 addition & 0 deletions fuzz/types/ParseCoin/corpus/trailing_space.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10stake
1 change: 1 addition & 0 deletions fuzz/types/ParseCoin/corpus/valid.seed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10stake
13 changes: 13 additions & 0 deletions fuzz/types/ParseCoin/fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package parsecoin

import (
"github.com/cosmos/cosmos-sdk/types"
)

func Fuzz(data []byte) int {
_, err := types.ParseCoin(string(data))
if err != nil {
return 0
}
return 1
}
40 changes: 40 additions & 0 deletions fuzz/types/ParseCoin/generate/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"fmt"
"log"
"os"
"strings"
)

func main() {
seeds := []struct {
name string
coin string
}{
{"valid", "10stake"},
{"space_between_amount_denom", "10 stake"},
{"leading_space", " 10stake"},
{"trailing_space", "10stake "},
{"plus_sign", "+10stake"},
{"minus_sign", "-10stake"},
{"no_denom", "10"},
{"less_than_3char_denom", "10s"},
{"greater_than_128char_denom", "10" + strings.Repeat("s", 129)},
}

for _, seed := range seeds {
func() {
f, err := os.Create(fmt.Sprintf("corpus/%s.seed", seed.name))
if err != nil {
return
}
if _, err := f.Write([]byte(seed.coin)); err != nil {
log.Fatal(err)
}
if err := f.Close(); err != nil {
log.Fatal(err)
}
}()
}
}
Binary file added fuzz/types/ParseCoin/parsecoin-fuzz.zip
Binary file not shown.

0 comments on commit bdec2b2

Please sign in to comment.