From ec354fd2587178ee792de9ab41c6f56102a68e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 10 Dec 2019 11:52:25 +0200 Subject: [PATCH] tests/fuzzers: fixup --- fuzzbuzz.yaml | 17 +++++------ tests/fuzzers/keystore/keystore-fuzz.go | 22 -------------- tests/fuzzers/keystore/keystore-fuzzer.go | 37 +++++++++++++++++++++++ tests/fuzzers/rlp/rlp_fuzzer.go | 19 ++++++++++-- tests/fuzzers/trie/trie-fuzzer.go | 16 ++++++++++ tests/fuzzers/whisperv6/whisper-fuzzer.go | 18 +++++++++-- 6 files changed, 93 insertions(+), 36 deletions(-) delete mode 100644 tests/fuzzers/keystore/keystore-fuzz.go create mode 100644 tests/fuzzers/keystore/keystore-fuzzer.go diff --git a/fuzzbuzz.yaml b/fuzzbuzz.yaml index 7e3c3337b4..72c3835ace 100644 --- a/fuzzbuzz.yaml +++ b/fuzzbuzz.yaml @@ -4,34 +4,33 @@ base: ubuntu:16.04 targets: - name: rlp language: go - version: "1.11" + version: "1.13" corpus: ./fuzzers/rlp/corpus harness: function: Fuzz - package: github.com/ethereum/go-ethereum/fuzzers/rlp + package: github.com/ethereum/go-ethereum/tests/fuzzers/rlp checkout: github.com/ethereum/go-ethereum/ - name: keystore language: go - version: "1.11" + version: "1.13" corpus: ./fuzzers/keystore/corpus harness: function: Fuzz - package: github.com/ethereum/go-ethereum/fuzzers/keystore + package: github.com/ethereum/go-ethereum/tests/fuzzers/keystore checkout: github.com/ethereum/go-ethereum/ - name: trie language: go - version: "1.11" + version: "1.13" corpus: ./fuzzers/trie/corpus harness: function: Fuzz - package: github.com/ethereum/go-ethereum/fuzzers/trie + package: github.com/ethereum/go-ethereum/tests/fuzzers/trie checkout: github.com/ethereum/go-ethereum/ - name: whisperv6 language: go - version: "1.11" + version: "1.13" corpus: ./fuzzers/whisperv6/corpus harness: function: Fuzz - package: github.com/ethereum/go-ethereum/fuzzers/whisperv6 + package: github.com/ethereum/go-ethereum/tests/fuzzers/whisperv6 checkout: github.com/ethereum/go-ethereum/ - diff --git a/tests/fuzzers/keystore/keystore-fuzz.go b/tests/fuzzers/keystore/keystore-fuzz.go deleted file mode 100644 index 155e3fb62f..0000000000 --- a/tests/fuzzers/keystore/keystore-fuzz.go +++ /dev/null @@ -1,22 +0,0 @@ -package keystore - -import ( - "os" - - "github.com/ethereum/go-ethereum/accounts/keystore" -) - -func Fuzz(input []byte) int { - - ks := keystore.NewKeyStore("/tmp/ks", keystore.LightScryptN, keystore.LightScryptP) - - a, err := ks.NewAccount(string(input)) - if err != nil { - panic(err) - } - if err := ks.Unlock(a, string(input)); err != nil { - panic(err) - } - os.Remove(a.URL.Path) - return 0 -} diff --git a/tests/fuzzers/keystore/keystore-fuzzer.go b/tests/fuzzers/keystore/keystore-fuzzer.go new file mode 100644 index 0000000000..704f29dc48 --- /dev/null +++ b/tests/fuzzers/keystore/keystore-fuzzer.go @@ -0,0 +1,37 @@ +// Copyright 2019 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package keystore + +import ( + "os" + + "github.com/ethereum/go-ethereum/accounts/keystore" +) + +func Fuzz(input []byte) int { + ks := keystore.NewKeyStore("/tmp/ks", keystore.LightScryptN, keystore.LightScryptP) + + a, err := ks.NewAccount(string(input)) + if err != nil { + panic(err) + } + if err := ks.Unlock(a, string(input)); err != nil { + panic(err) + } + os.Remove(a.URL.Path) + return 0 +} diff --git a/tests/fuzzers/rlp/rlp_fuzzer.go b/tests/fuzzers/rlp/rlp_fuzzer.go index 9c4de825cd..534540476c 100644 --- a/tests/fuzzers/rlp/rlp_fuzzer.go +++ b/tests/fuzzers/rlp/rlp_fuzzer.go @@ -1,3 +1,19 @@ +// Copyright 2019 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + package rlp import ( @@ -21,7 +37,6 @@ func decodeEncode(input []byte, val interface{}, i int) { } func Fuzz(input []byte) int { - var i int { if len(input) > 0 { @@ -107,8 +122,6 @@ func Fuzz(input []byte) int { i++ var rs types.Receipts decodeEncode(input, &rs, i) - i++ } - return 0 } diff --git a/tests/fuzzers/trie/trie-fuzzer.go b/tests/fuzzers/trie/trie-fuzzer.go index df2f499ae3..9818838053 100644 --- a/tests/fuzzers/trie/trie-fuzzer.go +++ b/tests/fuzzers/trie/trie-fuzzer.go @@ -1,3 +1,19 @@ +// Copyright 2019 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + package trie import ( diff --git a/tests/fuzzers/whisperv6/whisper-fuzzer.go b/tests/fuzzers/whisperv6/whisper-fuzzer.go index 0c68bbd729..379e4224fd 100644 --- a/tests/fuzzers/whisperv6/whisper-fuzzer.go +++ b/tests/fuzzers/whisperv6/whisper-fuzzer.go @@ -1,3 +1,19 @@ +// Copyright 2019 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + package whisperv6 import ( @@ -60,7 +76,6 @@ func Fuzz(input []byte) int { } if !decrypted.ValidateAndParse() { panic("ValidateAndParse failed") - return 0 } if !bytes.Equal(text, decrypted.Payload) { panic("text != decrypted.Payload") @@ -71,6 +86,5 @@ func Fuzz(input []byte) int { if !whisperv6.IsPubKeyEqual(decrypted.Src, ¶ms.Src.PublicKey) { panic("Unexpected public key") } - return 0 }