Skip to content

Commit

Permalink
Merge pull request #4915 from r-vasquez/strip-other-from-config-bundle
Browse files Browse the repository at this point in the history
rpk: redact blindly decoded parameter
  • Loading branch information
twmb committed May 25, 2022
2 parents c860914 + 3646ddd commit 3c4a9cd
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/go/rpk/pkg/cli/cmd/debug/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,28 @@ func saveConfig(ps *stepParams, conf *config.Config) step {
conf.Rpk.SASL.User = redacted
conf.Rpk.SASL.Password = redacted
}
// We want to redact any blindly decoded parameters.
redactOtherMap(conf.Other)
redactOtherMap(conf.Redpanda.Other)
redactServerTLSSlice(conf.Redpanda.RPCServerTLS)
redactServerTLSSlice(conf.Redpanda.KafkaAPITLS)
redactServerTLSSlice(conf.Redpanda.AdminAPITLS)
if conf.SchemaRegistry != nil {
for _, server := range conf.SchemaRegistry.SchemaRegistryAPITLS {
redactOtherMap(server.Other)
}
}
if conf.Pandaproxy != nil {
redactOtherMap(conf.Pandaproxy.Other)
redactServerTLSSlice(conf.Pandaproxy.PandaproxyAPITLS)
}
if conf.PandaproxyClient != nil {
redactOtherMap(conf.PandaproxyClient.Other)
}
if conf.SchemaRegistryClient != nil {
redactOtherMap(conf.SchemaRegistryClient.Other)
}

bs, err := yaml.Marshal(conf)
if err != nil {
return fmt.Errorf("couldn't encode the redpanda config as YAML: %w", err)
Expand All @@ -554,6 +576,18 @@ func saveConfig(ps *stepParams, conf *config.Config) step {
}
}

func redactServerTLSSlice(servers []config.ServerTLS) {
for _, server := range servers {
redactOtherMap(server.Other)
}
}

func redactOtherMap(other map[string]interface{}) {
for k := range other {
other[k] = "(REDACTED)"
}
}

// Saves the contents of '/proc/cpuinfo'.
func saveCPUInfo(ps *stepParams) step {
return func() error {
Expand Down

0 comments on commit 3c4a9cd

Please sign in to comment.