Skip to content

Commit

Permalink
Remove all spaces and newlines in secret strings (#147)
Browse files Browse the repository at this point in the history
Just strip spaces and newlines before base64-decoding. This allows the
secret strings to be line-wrapped.
  • Loading branch information
rohansingh authored Feb 4, 2022
1 parent c31dfc1 commit 4578063
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion runtime/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/base64"
"fmt"
"regexp"
"strings"
"sync"

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 4578063

Please sign in to comment.