feat(get): secret entries will not output unless --secret is explicitly passed
This commit is contained in:
parent
9036efb25b
commit
f1a4f86675
1 changed files with 13 additions and 0 deletions
13
cmd/get.go
13
cmd/get.go
|
|
@ -22,6 +22,8 @@ THE SOFTWARE.
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/dgraph-io/badger/v4"
|
"github.com/dgraph-io/badger/v4"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
@ -38,6 +40,7 @@ func get(cmd *cobra.Command, args []string) error {
|
||||||
store := &Store{}
|
store := &Store{}
|
||||||
|
|
||||||
var v []byte
|
var v []byte
|
||||||
|
var meta byte
|
||||||
trans := TransactionArgs{
|
trans := TransactionArgs{
|
||||||
key: args[0],
|
key: args[0],
|
||||||
readonly: true,
|
readonly: true,
|
||||||
|
|
@ -47,6 +50,7 @@ func get(cmd *cobra.Command, args []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
meta = item.UserMeta()
|
||||||
v, err = item.ValueCopy(nil)
|
v, err = item.ValueCopy(nil)
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
|
|
@ -56,6 +60,14 @@ func get(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
includeSecret, err := cmd.Flags().GetBool("secret")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if meta&metaSecret != 0 && !includeSecret {
|
||||||
|
return fmt.Errorf("%q is marked secret; re-run with --secret to display it", args[0])
|
||||||
|
}
|
||||||
|
|
||||||
binary, err := cmd.Flags().GetBool("include-binary")
|
binary, err := cmd.Flags().GetBool("include-binary")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -67,5 +79,6 @@ func get(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
getCmd.Flags().BoolP("include-binary", "b", false, "include binary data in text output")
|
getCmd.Flags().BoolP("include-binary", "b", false, "include binary data in text output")
|
||||||
|
getCmd.Flags().Bool("secret", false, "display values marked as secret")
|
||||||
rootCmd.AddCommand(getCmd)
|
rootCmd.AddCommand(getCmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue