Skip to content

Commit 7c99c90

Browse files
authored
Move common.MapStr and rename it to mapstr.M (#13)
1 parent 9240234 commit 7c99c90

File tree

8 files changed

+1842
-6
lines changed

8 files changed

+1842
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This repository is the home to the common libraries used by Elastic Agent and Be
44

55
Provided packages:
66
* `github.com/elastic/elastic-agent-libs/config` the previous `config.go` file from `github.com/elastic/beats/v7/libbeat/common`. A minimal wrapper around `github.com/elastic/go-ucfg`. It contains helpers for merging and accessing configuration objects and flags.
7-
* `github.com/elastic/elastic-agent-libs/str` the previous `stringset.go` file from `github.com/elastic/beats/v7/libbeat/common`. It provides a string set implementation.
87
* `github.com/elastic/elastic-agent-libs/file` is responsible for rotating and writing input and output files.
98
* `github.com/elastic/elastic-agent-libs/logp` is the well known logger from libbeat.
9+
* `github.com/elastic/elastic-agent-libs/mapstr` is the old `github.com/elastic/beats/v7/libbeat/common.MapStr`. It is an extra layer on top of `map[string]interface{}`.
10+
* `github.com/elastic/elastic-agent-libs/safemapstr` contains safe operations for `mapstr.M`.
11+
* `github.com/elastic/elastic-agent-libs/str` the previous `stringset.go` file from `github.com/elastic/beats/v7/libbeat/common`. It provides a string set implementation.

config/config.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func DebugString(c *C, filterPrivate bool) string {
336336
return fmt.Sprintf("<config error> %v", err)
337337
}
338338
if filterPrivate {
339-
applyLoggingMask(content)
339+
ApplyLoggingMask(content)
340340
}
341341
j, _ := json.MarshalIndent(content, "", " ")
342342
bufs = append(bufs, string(j))
@@ -347,7 +347,7 @@ func DebugString(c *C, filterPrivate bool) string {
347347
return fmt.Sprintf("<config error> %v", err)
348348
}
349349
if filterPrivate {
350-
applyLoggingMask(content)
350+
ApplyLoggingMask(content)
351351
}
352352
j, _ := json.MarshalIndent(content, "", " ")
353353
bufs = append(bufs, string(j))
@@ -359,7 +359,9 @@ func DebugString(c *C, filterPrivate bool) string {
359359
return strings.Join(bufs, "\n")
360360
}
361361

362-
func applyLoggingMask(c interface{}) {
362+
// ApplyLoggingMask redacts the values of keys that might
363+
// contain sensitive data (password, passphrase, etc.).
364+
func ApplyLoggingMask(c interface{}) {
363365
switch cfg := c.(type) {
364366
case map[string]interface{}:
365367
for k, v := range cfg {
@@ -372,13 +374,13 @@ func applyLoggingMask(c interface{}) {
372374
cfg[k] = mask
373375
}
374376
} else {
375-
applyLoggingMask(v)
377+
ApplyLoggingMask(v)
376378
}
377379
}
378380

379381
case []interface{}:
380382
for _, elem := range cfg {
381-
applyLoggingMask(elem)
383+
ApplyLoggingMask(elem)
382384
}
383385
}
384386
}

0 commit comments

Comments
 (0)