Skip to content

Commit

Permalink
feat(price-feeder): hide keyring password on input (#1696)
Browse files Browse the repository at this point in the history
## Description

Hides the password from the terminal for the price-feeder application (no local echo)

---

### Author Checklist

_All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues._

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] added appropriate labels to the PR
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/umee-network/umee/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

_All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items._

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
Reecepbcups authored Jan 9, 2023
1 parent bc9d114 commit fde1656
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions price-feeder/cmd/price-feeder.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"bufio"
"context"
"fmt"
"io"
Expand All @@ -12,13 +11,13 @@ import (
"syscall"
"time"

input "github.com/cosmos/cosmos-sdk/client/input"
"github.com/mitchellh/mapstructure"

"github.com/gorilla/mux"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
"golang.org/x/term"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -196,11 +195,14 @@ func priceFeederCmdHandler(cmd *cobra.Command, args []string) error {
}

func getKeyringPassword() (string, error) {
reader := bufio.NewReader(os.Stdin)

pass := os.Getenv(envVariablePass)
if pass == "" {
return input.GetString("Enter keyring password", reader)
fmt.Print("Enter keyring password: ")
bytePassword, err := term.ReadPassword(syscall.Stdin)
if err != nil {
return "", err
}
pass = string(bytePassword)
}
return pass, nil
}
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/tendermint/tendermint v0.34.24
github.com/umee-network/umee/v4 v4.0.0
golang.org/x/sync v0.1.0
golang.org/x/term v0.2.0
google.golang.org/grpc v1.51.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -284,7 +285,6 @@ require (
golang.org/x/net v0.2.0 // indirect
golang.org/x/oauth2 v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
Expand Down

0 comments on commit fde1656

Please sign in to comment.