Skip to content

Commit

Permalink
fix(config): redact redis endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstanley committed Aug 13, 2024
1 parent 428bd0c commit b2ae4b3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Disabled the `authority-claimer` when `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED` is set to `true`.
- Redacted the contents of `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT`.

## [1.5.0] 2024-07-22

Expand Down
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 config.ExperimentalSunodoValidatorEnabled {
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 @@ -43,3 +43,11 @@ func (s *ConfigTestSuite) TestAuthIsNotSetWhenClaimerIsDisabled() {
c := FromEnv()
assert.Nil(s.T(), c.Auth)
}

func (s *ConfigTestSuite) TestExperimentalSunodoValidatorRedisEndpointIsRedacted() {
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED", "true")
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT",
"redis://username:p@ssw0rd@hostname:9999")
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 b2ae4b3

Please sign in to comment.