Browse Source

fix: AWS attr. dot check off-by-one error (#1459)

* Fix off-by-one in check for dot in JSON attr. name

Signed-off-by: stephen-dexda <stephen@dexda.io>
stephen-dexda 3 years ago
parent
commit
e64acea549

+ 1 - 1
pkg/provider/aws/parameterstore/parameterstore.go

@@ -189,7 +189,7 @@ func (pm *ParameterStore) GetSecret(ctx context.Context, ref esv1beta1.ExternalS
 		return nil, fmt.Errorf("invalid secret received. parameter value is nil for key: %s", ref.Key)
 		return nil, fmt.Errorf("invalid secret received. parameter value is nil for key: %s", ref.Key)
 	}
 	}
 	idx := strings.Index(ref.Property, ".")
 	idx := strings.Index(ref.Property, ".")
-	if idx > 0 {
+	if idx > -1 {
 		refProperty := strings.ReplaceAll(ref.Property, ".", "\\.")
 		refProperty := strings.ReplaceAll(ref.Property, ".", "\\.")
 		val := gjson.Get(*out.Parameter.Value, refProperty)
 		val := gjson.Get(*out.Parameter.Value, refProperty)
 		if val.Exists() {
 		if val.Exists() {

+ 1 - 1
pkg/provider/aws/secretsmanager/secretsmanager.go

@@ -256,7 +256,7 @@ func (sm *SecretsManager) GetSecret(ctx context.Context, ref esv1beta1.ExternalS
 	}
 	}
 	// We need to search if a given key with a . exists before using gjson operations.
 	// We need to search if a given key with a . exists before using gjson operations.
 	idx := strings.Index(ref.Property, ".")
 	idx := strings.Index(ref.Property, ".")
-	if idx > 0 {
+	if idx > -1 {
 		refProperty := strings.ReplaceAll(ref.Property, ".", "\\.")
 		refProperty := strings.ReplaceAll(ref.Property, ".", "\\.")
 		val := gjson.Get(payload, refProperty)
 		val := gjson.Get(payload, refProperty)
 		if val.Exists() {
 		if val.Exists() {