From 457806375f2ec2d45764e18272b754b984a87e78 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Thu, 3 Feb 2022 19:29:45 -0500 Subject: [PATCH] Remove all spaces and newlines in secret strings (#147) Just strip spaces and newlines before base64-decoding. This allows the secret strings to be line-wrapped. --- runtime/secret.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/secret.go b/runtime/secret.go index c21f1f43fd..865b7fa125 100644 --- a/runtime/secret.go +++ b/runtime/secret.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/base64" "fmt" + "regexp" "strings" "sync" @@ -96,7 +97,8 @@ func (sdk *SecretDecryptionKey) decrypterForApp(a *Applet) (decrypter, error) { context := []byte(strings.TrimSuffix(a.Filename, ".star")) return func(s starlark.String) (starlark.String, error) { - ciphertext, err := base64.StdEncoding.DecodeString(s.GoString()) + v := regexp.MustCompile(`\s`).ReplaceAllString(s.GoString(), "") + ciphertext, err := base64.StdEncoding.DecodeString(v) if err != nil { return "", errors.Wrapf(err, "base64 decoding of secret: %s", s) }