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 9, 2024
1 parent b840ac6 commit f967576
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 @@ -40,3 +40,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://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 f967576

Please sign in to comment.