Skip to content

Commit e20e66a

Browse files
utkuozdemirsmira
authored andcommitted
fix: redact service account key in config in RedactSecrets method
Include the previously missing service account key field in the redaction. Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com> (cherry picked from commit 873bd38)
1 parent 42b04e3 commit e20e66a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ func (c *Config) Bytes() ([]byte, error) {
103103
}
104104

105105
// RedactSecrets implements the config.Provider interface.
106+
//
107+
//nolint:gocyclo
106108
func (c *Config) RedactSecrets(replacement string) config.Provider {
107109
if c == nil {
108110
return nil
@@ -135,6 +137,10 @@ func (c *Config) RedactSecrets(replacement string) config.Provider {
135137
clone.ClusterConfig.ClusterAESCBCEncryptionSecret = redactStr(clone.ClusterConfig.ClusterAESCBCEncryptionSecret)
136138
clone.ClusterConfig.ClusterSecretboxEncryptionSecret = redactStr(clone.ClusterConfig.ClusterSecretboxEncryptionSecret)
137139

140+
if clone.ClusterConfig.ClusterServiceAccount != nil {
141+
clone.ClusterConfig.ClusterServiceAccount.Key = redactBytes(clone.ClusterConfig.ClusterServiceAccount.Key)
142+
}
143+
138144
if clone.ClusterConfig.ClusterCA != nil {
139145
clone.ClusterConfig.ClusterCA.Key = redactBytes(clone.ClusterConfig.ClusterCA.Key)
140146
}

pkg/machinery/config/types/v1alpha1/v1alpha1_redact_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestRedactSecrets(t *testing.T) {
3434
require.NotEmpty(t, config.ClusterConfig.ClusterSecretboxEncryptionSecret)
3535
require.NotEmpty(t, config.ClusterConfig.ClusterCA.Key)
3636
require.NotEmpty(t, config.ClusterConfig.EtcdConfig.RootCA.Key)
37+
require.NotEmpty(t, config.ClusterConfig.ClusterServiceAccount.Key)
3738

3839
replacement := "**.***"
3940

@@ -55,4 +56,5 @@ func TestRedactSecrets(t *testing.T) {
5556
require.Equal(t, replacement, redacted.Cluster().SecretboxEncryptionSecret())
5657
require.Equal(t, replacement, string(redacted.Cluster().CA().Key))
5758
require.Equal(t, replacement, string(redacted.Cluster().Etcd().CA().Key))
59+
require.Equal(t, replacement, string(redacted.Cluster().ServiceAccount().Key))
5860
}

0 commit comments

Comments
 (0)