Skip to content

Commit

Permalink
Add warning if shell expansion characters make it in to the path (#5001)
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Mar 4, 2020
1 parent 239efe7 commit 0bdd0db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions validator/keymanager/direct_keystore.go
Expand Up @@ -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()
}
Expand Down
5 changes: 5 additions & 0 deletions validator/keymanager/direct_unencrypted.go
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions validator/keymanager/wallet.go
Expand Up @@ -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()
Expand Down

0 comments on commit 0bdd0db

Please sign in to comment.