Skip to content

Commit

Permalink
feat(config): redact redis endpoint on experimental mode
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstanley committed Aug 7, 2024
1 parent 85c64fd commit b6f49bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type NodeConfig struct {
FeatureDisableMachineHashCheck bool
ExperimentalServerManagerBypassLog bool
ExperimentalSunodoValidatorEnabled bool
ExperimentalSunodoValidatorRedisEndpoint string
ExperimentalSunodoValidatorRedisEndpoint Redacted[string]
Auth Auth
}

Expand Down Expand Up @@ -99,7 +99,7 @@ func FromEnv() NodeConfig {
config.ExperimentalSunodoValidatorEnabled = getExperimentalSunodoValidatorEnabled()
if getExperimentalSunodoValidatorEnabled() {
config.ExperimentalSunodoValidatorRedisEndpoint =
getExperimentalSunodoValidatorRedisEndpoint()
Redacted[string]{getExperimentalSunodoValidatorRedisEndpoint()}
config.FeatureDisableClaimer = true
}
if !config.FeatureDisableClaimer && !getExperimentalSunodoValidatorEnabled() {
Expand Down
8 changes: 8 additions & 0 deletions internal/node/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ func (s *ConfigTestSuite) TestSunodoExperimentalModeDisablesClaimer() {
c := FromEnv()
assert.Equal(s.T(), true, c.FeatureDisableClaimer)
}

func (s *ConfigTestSuite) TestExperimentalSunodoValidatorRedisEndpointIsRedacted() {
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED", "true")
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT",
"redis://default:[email protected]:6379")
c := FromEnv()
assert.Equal(s.T(), "[REDACTED]", c.ExperimentalSunodoValidatorRedisEndpoint.String())
}
2 changes: 1 addition & 1 deletion internal/node/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func getPort(c config.NodeConfig, offset portOffset) int {
// Get the redis endpoint based on whether the experimental sunodo validator mode is enabled.
func getRedisEndpoint(c config.NodeConfig) string {
if c.ExperimentalSunodoValidatorEnabled {
return c.ExperimentalSunodoValidatorRedisEndpoint
return c.ExperimentalSunodoValidatorRedisEndpoint.Value
} else {
return fmt.Sprintf("redis://%v:%v", localhost, getPort(c, portOffsetRedis))
}
Expand Down

0 comments on commit b6f49bf

Please sign in to comment.