Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask password discovered via module autodiscover hint #15616

Merged
merged 16 commits into from
Jan 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactoring: renaming to be bit more generic
ycombinator committed Jan 17, 2020
commit fbd3122e1fab6ea8635ee75d2dcbe4a3691e5199
4 changes: 2 additions & 2 deletions libbeat/common/config.go
Original file line number Diff line number Diff line change
@@ -357,7 +357,7 @@ func DebugString(c *Config, filterPrivate bool) string {
return fmt.Sprintf("<config error> %v", err)
}
if filterPrivate {
filterDebugObject(content)
applyLoggingMask(content)
}
j, _ := json.MarshalIndent(content, "", " ")
bufs = append(bufs, string(j))
@@ -368,7 +368,7 @@ func DebugString(c *Config, filterPrivate bool) string {
return fmt.Sprintf("<config error> %v", err)
}
if filterPrivate {
filterDebugObject(content)
applyLoggingMask(content)
}
j, _ := json.MarshalIndent(content, "", " ")
bufs = append(bufs, string(j))
10 changes: 5 additions & 5 deletions libbeat/common/logging.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package common

var debugMasklist = MakeStringSet(
var maskList = MakeStringSet(
"password",
"passphrase",
"key_passphrase",
@@ -12,11 +12,11 @@ var debugMasklist = MakeStringSet(
"hosts",
)

func filterDebugObject(c interface{}) {
func applyLoggingMask(c interface{}) {
switch cfg := c.(type) {
case map[string]interface{}:
for k, v := range cfg {
if debugMasklist.Has(k) {
if maskList.Has(k) {
if arr, ok := v.([]interface{}); ok {
for i := range arr {
arr[i] = "xxxxx"
@@ -25,13 +25,13 @@ func filterDebugObject(c interface{}) {
cfg[k] = "xxxxx"
}
} else {
filterDebugObject(v)
applyLoggingMask(v)
}
}

case []interface{}:
for _, elem := range cfg {
filterDebugObject(elem)
applyLoggingMask(elem)
}
}
}
4 changes: 2 additions & 2 deletions libbeat/common/mapstr.go
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ func (m MapStr) MarshalLogObject(enc zapcore.ObjectEncoder) error {
}

debugM := m.Clone()
filterDebugObject(map[string]interface{}(debugM))
applyLoggingMask(map[string]interface{}(debugM))

keys := make([]string, 0, len(debugM))
for k := range debugM {
@@ -246,7 +246,7 @@ func (m MapStr) Format(f fmt.State, c rune) {
}

debugM := m.Clone()
filterDebugObject(map[string]interface{}(debugM))
applyLoggingMask(map[string]interface{}(debugM))

io.WriteString(f, debugM.String())
}