mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
fuzzing: move keystore fuzzer
This commit is contained in:
parent
5059a5a714
commit
527eb79a02
3 changed files with 28 additions and 62 deletions
|
|
@ -16,10 +16,19 @@
|
|||
|
||||
package keystore
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Fuzz(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
fuzz(data)
|
||||
func FuzzPassword(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, password string) {
|
||||
ks := NewKeyStore(t.TempDir(), LightScryptN, LightScryptP)
|
||||
a, err := ks.NewAccount(password)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ks.Unlock(a, password); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
36
oss-fuzz.sh
36
oss-fuzz.sh
|
|
@ -81,31 +81,31 @@ function compile_fuzzer() {
|
|||
|
||||
go install github.com/holiman/gofuzz-shim@latest
|
||||
|
||||
#compile_fuzzer accounts/abi FuzzABI fuzzAbi
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/accounts/abi FuzzABI fuzzAbi
|
||||
# compile_fuzzer github.com/ethereum/go-ethereum/accounts/abi FuzzABI fuzzAbi
|
||||
# compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzEncoder fuzzBitutilEncoder
|
||||
# compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzDecoder fuzzBitutilDecoder
|
||||
# compile_fuzzer github.com/ethereum/go-ethereum/core/vm/runtime FuzzVmRuntime fuzzVmRuntime
|
||||
# compile_fuzzer github.com/ethereum/go-ethereum/core/vm FuzzPrecompiledContracts fuzzPrecompiledContracts
|
||||
# compile_fuzzer github.com/ethereum/go-ethereum/core/types FuzzRLP fuzzRlp
|
||||
|
||||
#compile_fuzzer common/bitutil FuzzEncoder fuzzBitutilEncoder
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzEncoder fuzzBitutilEncoder
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/crypto/blake2b Fuzz fuzzBlake2b
|
||||
|
||||
#compile_fuzzer common/bitutil FuzzDecoder fuzzBitutilDecoder
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzDecoder fuzzBitutilDecoder
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/accounts/keystore FuzzPassword fuzzKeystore
|
||||
|
||||
#compile_fuzzer core/vm/runtime FuzzVmRuntime fuzzVmRuntime
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/core/vm/runtime FuzzVmRuntime fuzzVmRuntime
|
||||
#compile_fuzzer tests/fuzzers/trie Fuzz fuzzTrie
|
||||
#compile_fuzzer tests/fuzzers/stacktrie Fuzz fuzzStackTrie
|
||||
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzARange fuzz_account_range
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzSRange fuzz_storage_range
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzByteCodes fuzz_byte_codes
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzTrieNodes fuzz_trie_nodes
|
||||
|
||||
#compile_fuzzer core/vm FuzzPrecompiledContracts fuzzPrecompiledContracts
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/core/vm FuzzPrecompiledContracts fuzzPrecompiledContracts
|
||||
|
||||
#compile_fuzzer core/types/ FuzzRLP fuzzRlp
|
||||
compile_fuzzer github.com/ethereum/go-ethereum/core/types FuzzRLP fuzzRlp
|
||||
|
||||
#compile_fuzzer tests/fuzzers/bn256 FuzzAdd fuzzBn256Add
|
||||
#compile_fuzzer tests/fuzzers/bn256 FuzzMul fuzzBn256Mul
|
||||
#compile_fuzzer tests/fuzzers/bn256 FuzzPair fuzzBn256Pair
|
||||
#compile_fuzzer tests/fuzzers/keystore Fuzz fuzzKeystore
|
||||
#compile_fuzzer tests/fuzzers/txfetcher Fuzz fuzzTxfetcher
|
||||
#compile_fuzzer tests/fuzzers/trie Fuzz fuzzTrie
|
||||
#compile_fuzzer tests/fuzzers/stacktrie Fuzz fuzzStackTrie
|
||||
#compile_fuzzer tests/fuzzers/difficulty Fuzz fuzzDifficulty
|
||||
#compile_fuzzer tests/fuzzers/les Fuzz fuzzLes
|
||||
#compile_fuzzer tests/fuzzers/secp256k1 Fuzz fuzzSecp256k1
|
||||
|
|
@ -126,9 +126,3 @@ compile_fuzzer github.com/ethereum/go-ethereum/core/types FuzzRLP fuzzRlp
|
|||
#compile_fuzzer tests/fuzzers/bls12381 FuzzCrossG2Add fuzz_cross_g2_add
|
||||
#compile_fuzzer tests/fuzzers/bls12381 FuzzCrossPairing fuzz_cross_pairing
|
||||
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzARange fuzz_account_range
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzSRange fuzz_storage_range
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzByteCodes fuzz_byte_codes
|
||||
#compile_fuzzer tests/fuzzers/snap FuzzTrieNodes fuzz_trie_nodes
|
||||
|
||||
#compile_fuzzer crypto/blake2b Fuzz fuzzBlake2b
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 1
|
||||
}
|
||||
Loading…
Reference in a new issue