[MM-39597] Implement ConfigDiffs.Sanitize() (#18855)

* Implement ConfigDiffs.Sanitize()

* Remove possibly sensitive info from logs
Этот коммит содержится в:
Claudio Costa
2021-10-28 14:07:35 +02:00
коммит произвёл GitHub
родитель ceee3f4b5f
Коммит f621989c58
5 изменённых файлов: 552 добавлений и 20 удалений

Просмотреть файл

@@ -3746,9 +3746,11 @@ func (o *Config) Sanitize() {
*o.LdapSettings.BindPassword = FakeSetting
}
*o.FileSettings.PublicLinkSalt = FakeSetting
if o.FileSettings.PublicLinkSalt != nil {
*o.FileSettings.PublicLinkSalt = FakeSetting
}
if *o.FileSettings.AmazonS3SecretAccessKey != "" {
if o.FileSettings.AmazonS3SecretAccessKey != nil && *o.FileSettings.AmazonS3SecretAccessKey != "" {
*o.FileSettings.AmazonS3SecretAccessKey = FakeSetting
}
@@ -3756,7 +3758,7 @@ func (o *Config) Sanitize() {
*o.EmailSettings.SMTPPassword = FakeSetting
}
if *o.GitLabSettings.Secret != "" {
if o.GitLabSettings.Secret != nil && *o.GitLabSettings.Secret != "" {
*o.GitLabSettings.Secret = FakeSetting
}
@@ -3772,10 +3774,17 @@ func (o *Config) Sanitize() {
*o.OpenIdSettings.Secret = FakeSetting
}
*o.SqlSettings.DataSource = FakeSetting
*o.SqlSettings.AtRestEncryptKey = FakeSetting
if o.SqlSettings.DataSource != nil {
*o.SqlSettings.DataSource = FakeSetting
}
*o.ElasticsearchSettings.Password = FakeSetting
if o.SqlSettings.AtRestEncryptKey != nil {
*o.SqlSettings.AtRestEncryptKey = FakeSetting
}
if o.ElasticsearchSettings.Password != nil {
*o.ElasticsearchSettings.Password = FakeSetting
}
for i := range o.SqlSettings.DataSourceReplicas {
o.SqlSettings.DataSourceReplicas[i] = FakeSetting
@@ -3785,7 +3794,9 @@ func (o *Config) Sanitize() {
o.SqlSettings.DataSourceSearchReplicas[i] = FakeSetting
}
if o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != nil && *o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != "" {
if o.MessageExportSettings.GlobalRelaySettings != nil &&
o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != nil &&
*o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != "" {
*o.MessageExportSettings.GlobalRelaySettings.SMTPPassword = FakeSetting
}
@@ -3793,7 +3804,9 @@ func (o *Config) Sanitize() {
*o.ServiceSettings.GfycatAPISecret = FakeSetting
}
*o.ServiceSettings.SplitKey = FakeSetting
if o.ServiceSettings.SplitKey != nil {
*o.ServiceSettings.SplitKey = FakeSetting
}
}
// structToMapFilteredByTag converts a struct into a map removing those fields that has the tag passed