-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/go_modules/examples/src/golang.or…
…g/x/image-0.18.0
- Loading branch information
Showing
5 changed files
with
112 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
const redactedSecretStr = "*** REDACTED ***" | ||
|
||
// HideSensitiveInfo removes sensitive information from the config. | ||
func HideSensitiveInfo(in Config) Config { | ||
out := in | ||
// TODO: avoid printing sensitive data without need to resetting them manually (which is an error-prone approach) | ||
for key, val := range out.Communications { | ||
val.SocketSlack.AppToken = redactedSecretStr | ||
val.SocketSlack.BotToken = redactedSecretStr | ||
val.Elasticsearch.Password = redactedSecretStr | ||
val.Discord.Token = redactedSecretStr | ||
val.Mattermost.Token = redactedSecretStr | ||
val.CloudSlack.Token = redactedSecretStr | ||
// To keep the printed config readable, we don't print the certificate bytes. | ||
val.CloudSlack.Server.TLS.CACertificate = nil | ||
val.CloudTeams.Server.TLS.CACertificate = nil | ||
|
||
// Replace private channel names with aliases | ||
cloudSlackChannels := make(IdentifiableMap[CloudSlackChannel]) | ||
for _, channel := range val.CloudSlack.Channels { | ||
if channel.Alias == nil { | ||
cloudSlackChannels[channel.ChannelBindingsByName.Name] = channel | ||
continue | ||
} | ||
|
||
outChannel := channel | ||
outChannel.ChannelBindingsByName.Name = fmt.Sprintf("%s (public alias)", *channel.Alias) | ||
outChannel.Alias = nil | ||
cloudSlackChannels[*channel.Alias] = outChannel | ||
} | ||
val.CloudSlack.Channels = cloudSlackChannels | ||
|
||
// maps are not addressable: https://stackoverflow.com/questions/42605337/cannot-assign-to-struct-field-in-a-map | ||
out.Communications[key] = val | ||
} | ||
|
||
return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters