Skip to content

Commit 23cadcd

Browse files
feat: detect and unescape url-encoded placeholder
Signed-off-by: DziyanaT <dziyana.tsetserava@etu.umontpellier.fr>
1 parent b046a7d commit 23cadcd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/kube/util.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/argoproj-labs/argocd-vault-plugin/pkg/types"
1414
"github.com/argoproj-labs/argocd-vault-plugin/pkg/utils"
1515
k8yaml "k8s.io/apimachinery/pkg/util/yaml"
16+
"net/url"
1617
)
1718

1819
type missingKeyError struct {
@@ -106,6 +107,14 @@ func genericReplacement(key, value string, resource Resource) (_ interface{}, er
106107
var nonStringReplacement interface{}
107108
var placeholderRegex = specificPathPlaceholder
108109

110+
decoded, decodeError := url.QueryUnescape(value)
111+
if decodeError == nil && decoded != value && placeholderRegex.Match([]byte(decoded)) {
112+
res, err := genericReplacement(key, string(decoded), resource)
113+
114+
utils.VerboseToStdErr("key %s had URL encoded placeholder value, URL encoding value %s to fit", key, value)
115+
return url.QueryEscape(stringify(res)), err
116+
}
117+
109118
// If the Vault path annotation is present, there may be placeholders with/without an explicit path
110119
// so we look for those. Only if the annotation is absent do we narrow the search to placeholders with
111120
// explicit paths, to prevent catching <things> that aren't placeholders

0 commit comments

Comments
 (0)