From ba88b1da165233883e67e0367338c7a27f83a3e9 Mon Sep 17 00:00:00 2001 From: AnPucel Date: Tue, 10 May 2022 14:07:45 -0700 Subject: [PATCH] [VAULT-14990] Support retrieving kv secret paths with trailing spaces (#15188) --- changelog/15188.txt | 3 +++ command/kv_get.go | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/15188.txt diff --git a/changelog/15188.txt b/changelog/15188.txt new file mode 100644 index 000000000..4435ccbb0 --- /dev/null +++ b/changelog/15188.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: kv get command now honors trailing spaces to retrieve secrets +``` diff --git a/command/kv_get.go b/command/kv_get.go index 070334481..ce4f60a76 100644 --- a/command/kv_get.go +++ b/command/kv_get.go @@ -124,7 +124,8 @@ func (c *KVGetCommand) Run(args []string) int { // Parse the paths and grab the KV version if mountFlagSyntax { // In this case, this arg is the secret path (e.g. "foo"). - partialPath = sanitizePath(args[0]) + partialPath = args[0] + mountPath = sanitizePath(c.flagMount) _, v2, err = isKVv2(mountPath, client) if err != nil { @@ -134,7 +135,8 @@ func (c *KVGetCommand) Run(args []string) int { } else { // In this case, this arg is a path-like combination of mountPath/secretPath. // (e.g. "secret/foo") - partialPath = sanitizePath(args[0]) + partialPath = args[0] + mountPath, v2, err = isKVv2(partialPath, client) if err != nil { c.UI.Error(err.Error())