Skip to content

Commit

Permalink
Merge pull request #491 from anandrgitnirman/pvtkey
Browse files Browse the repository at this point in the history
#490 :hide any sensitve info from logs / response sent
  • Loading branch information
anandrgitnirman authored Apr 18, 2020
2 parents 066df2a + c173f26 commit 3fb726a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
44 changes: 42 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,53 @@ func SubWithDefault(config *viper.Viper, key string) *viper.Viper {
return sub
}

var DisplayKeys = map[string]bool{
strings.ToUpper(AllowedUserFlag): true,
strings.ToUpper(AllowedUserAddresses): true,
strings.ToUpper(AuthenticationAddresses): true,
strings.ToUpper(AutoSSLDomainKey): true,
strings.ToUpper(AutoSSLCacheDirKey): true,
strings.ToUpper(BlockchainEnabledKey): true,
strings.ToUpper(BlockChainNetworkSelected): true,
strings.ToUpper(BurstSize): true,
strings.ToUpper(ConfigPathKey): true,
strings.ToUpper(DaemonGroupName): true,
strings.ToUpper(DaemonTypeKey): true,
strings.ToUpper(DaemonEndPoint): true,
strings.ToUpper(ExecutablePathKey): true,
strings.ToUpper(IpfsEndPoint): true,
strings.ToUpper(IpfsTimeout): true,
strings.ToUpper(LogKey): true,
strings.ToUpper(MaxMessageSizeInMB): true,
strings.ToUpper(MeteringEnabled): true,
strings.ToUpper(OrganizationId): true,
strings.ToUpper(ServiceId): true,
strings.ToUpper(PassthroughEnabledKey): true,
strings.ToUpper(PassthroughEndpointKey): true,
strings.ToUpper(RateLimitPerMinute): true,
strings.ToUpper(SSLCertPathKey): true,
strings.ToUpper(SSLKeyPathKey): true,
strings.ToUpper(PaymentChannelCertPath): true,
strings.ToUpper(PaymentChannelCaPath): true,
strings.ToUpper(PaymentChannelKeyPath): true,
strings.ToUpper(PaymentChannelStorageTypeKey): true,
strings.ToUpper(PaymentChannelStorageClientKey): true,
strings.ToUpper(PaymentChannelStorageServerKey): true,
strings.ToUpper(AlertsEMail): true,
strings.ToUpper(HeartbeatServiceEndpoint): true,
strings.ToUpper(MeteringEndPoint): true,
strings.ToUpper(NotificationServiceEndpoint): true,
strings.ToUpper(ServiceHeartbeatType): true,
}

func LogConfig() {
log.Info("Final configuration:")
keys := vip.AllKeys()
sort.Strings(keys)
for _, key := range keys {
log.Infof("%v: %v", key, vip.Get(key))

if DisplayKeys[strings.ToUpper(key)] {
log.Infof("%v: %v", key, vip.Get(key))
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion configuration_service/configuration_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"golang.org/x/net/context"
"math/big"
"sort"
"strings"
)

type ConfigurationService struct {
Expand Down Expand Up @@ -212,7 +213,10 @@ func getCurrentConfig() map[string]string {
keys := config.Vip().AllKeys()
sort.Strings(keys)
for _, key := range keys {
currentConfigMap[key] = config.GetString(key)
if config.DisplayKeys[strings.ToUpper(key)] {
currentConfigMap[key] = config.GetString(key)
}

}
return currentConfigMap
}
3 changes: 3 additions & 0 deletions configuration_service/configuration_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ func Test_getCurrentConfig(t *testing.T) {

currentConfig := getCurrentConfig()
assert.NotEmpty(t, currentConfig[config.DaemonEndPoint])
config.Vip().Set(config.PvtKeyForMetering, "HIDDEN")
currentConfig = getCurrentConfig()
assert.Empty(t, currentConfig[config.PvtKeyForMetering])
}

func TestConfigurationService_buildSchemaDetails(t *testing.T) {
Expand Down

0 comments on commit 3fb726a

Please sign in to comment.