Add warning if shell expansion characters make it in to the path (#5001)

This commit is contained in:
Raul Jordan
2020-03-04 12:34:23 -06:00
committed by GitHub
parent 239efe7410
commit 0bdd0dba67
3 changed files with 12 additions and 0 deletions

View File

@@ -42,6 +42,10 @@ func NewKeystore(input string) (KeyManager, string, error) {
return nil, keystoreOptsHelp, err
}
if strings.Contains(opts.Path, "$") || strings.Contains(opts.Path, "~") || strings.Contains(opts.Path, "%") {
log.WithField("path", opts.Path).Warn("Keystore path contains unexpanded shell expansion characters")
}
if opts.Path == "" {
opts.Path = defaultValidatorDir()
}

View File

@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
@@ -35,6 +36,10 @@ func NewUnencrypted(input string) (*Unencrypted, string, error) {
return nil, unencryptedOptsHelp, err
}
if strings.Contains(opts.Path, "$") || strings.Contains(opts.Path, "~") || strings.Contains(opts.Path, "%") {
log.WithField("path", opts.Path).Warn("Keystore path contains unexpanded shell expansion characters")
}
path, err := filepath.Abs(opts.Path)
if err != nil {
return nil, unencryptedOptsHelp, err

View File

@@ -60,6 +60,9 @@ func NewWallet(input string) (KeyManager, string, error) {
accounts: make(map[[48]byte]e2wtypes.Account),
}
if strings.Contains(opts.Location, "$") || strings.Contains(opts.Location, "~") || strings.Contains(opts.Location, "%") {
log.WithField("path", opts.Location).Warn("Keystore path contains unexpanded shell expansion characters")
}
var store e2wtypes.Store
if opts.Location == "" {
store = filesystem.New()