Skip to content

Commit 884a878

Browse files
fix(security): remove logging of api-key for debug logs (#1978)
1 parent 6ca760d commit 884a878

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/backend/telemetryapi/harvester.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"encoding/json"
1010
"errors"
1111
"fmt"
12-
"io/ioutil"
12+
"io"
1313
"math/rand"
1414
"net/http"
1515
"sync"
@@ -67,6 +67,7 @@ func NewHarvester(options ...func(*Config)) (*Harvester, error) {
6767
}
6868

6969
if cfg.APIKey == "" {
70+
cancel()
7071
return nil, errAPIKeyUnset
7172
}
7273

@@ -100,7 +101,6 @@ func NewHarvester(options ...func(*Config)) (*Harvester, error) {
100101

101102
h.config.logDebug(map[string]interface{}{
102103
"event": "harvester created",
103-
"api-key": h.config.APIKey,
104104
"harvest-period-seconds": h.config.HarvestPeriod.Seconds(),
105105
"metrics-url-override": h.config.MetricsURLOverride,
106106
"spans-url-override": h.config.SpansURLOverride,
@@ -293,9 +293,9 @@ func postData(req *http.Request, client *http.Client) response {
293293

294294
// On success, metrics ingest returns 202, span ingest returns 200.
295295
if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusAccepted {
296-
r.body, _ = ioutil.ReadAll(resp.Body)
296+
r.body, _ = io.ReadAll(resp.Body)
297297
} else {
298-
_, _ = ioutil.ReadAll(resp.Body)
298+
_, _ = io.ReadAll(resp.Body)
299299
r.err = fmt.Errorf("unexpected post response code: %d: %s",
300300
resp.StatusCode, http.StatusText(resp.StatusCode))
301301
}
@@ -441,7 +441,7 @@ func harvestRequest(req request, cfg *Config) {
441441

442442
// Reattach request body because the original one has already been read
443443
// and closed.
444-
req.Request.Body = ioutil.NopCloser(bytes.NewBuffer(req.compressedBody))
444+
req.Request.Body = io.NopCloser(bytes.NewBuffer(req.compressedBody))
445445
}
446446
}
447447

0 commit comments

Comments
 (0)