Ensure user is stripped out of logs in influx input

The returned error may contain sensitive information if older versions
of go are used to build. (1.12+ are ok)
This commit is contained in:
greg linton
2019-10-30 17:05:13 -06:00
parent 9efc37606f
commit c01e6ae2ff
+10 -3
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"
"sync"
"time"
@@ -72,10 +73,16 @@ func (i *InfluxDB) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
for _, u := range i.URLs {
wg.Add(1)
go func(url string) {
go func(u string) {
defer wg.Done()
if err := i.gatherURL(acc, url); err != nil {
acc.AddError(fmt.Errorf("[url=%s]: %s", url, err))
if err := i.gatherURL(acc, u); err != nil {
yourl, err2 := url.Parse(u)
if err2 != nil || yourl == nil {
acc.AddError(err)
} else {
yourl.User = nil
acc.AddError(fmt.Errorf("[url=%s]: %s", yourl.String(), err.Error()))
}
}
}(u)
}