fix(store): satisfy makezero when building cipher payload

append(nonce, sealed...) appends to a slice initialized with a non-zero
length, which makezero flags. Build the nonce||ciphertext||tag payload with
an explicit buffer sized upfront instead.

Found by golangci-lint.
This commit is contained in:
sam committed 2026-09-03 00:01:11 +10:00
1 parent c13ec2f225
commit ded0f0aef5
1 file changed
+4 -2
+4 -2
View File
@@ -98,9 +98,11 @@ func (c *bindingCipher) Encrypt(plaintext string) (string, error) {
return "", fmt.Errorf("store: binding cipher: nonce: %w", err)
}
sealed := gcm.Seal(nil, nonce, []byte(plaintext), bindingSecretAAD)
payload := base64.RawURLEncoding.EncodeToString(append(nonce, sealed...))
payload := make([]byte, 0, bindingNonceLen+len(sealed))
payload = append(payload, nonce...)
payload = append(payload, sealed...)
return fmt.Sprintf("%s:%s:%s:%s", bindingEnvelopeMarker, bindingEnvelopeVersion,
c.activeFingerprint, payload), nil
c.activeFingerprint, base64.RawURLEncoding.EncodeToString(payload)), nil
}
// Decrypt parses the envelope, looks up the key by its embedded fingerprint,