Skip to content

Commit

Permalink
[receiver/collectd] Sanitize string recorded in log (#7577)
Browse files Browse the repository at this point in the history
As per CWE-117 recommendations.
  • Loading branch information
Alex Boten authored Feb 7, 2022
1 parent 6cfac22 commit c05fd29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion receiver/collectdreceiver/collectd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (

metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/sanitize"
)

const (
Expand Down Expand Up @@ -93,7 +95,7 @@ func (r *collectDRecord) appendToMetrics(metrics []*metricspb.Metric, defaultLab

metric, err := r.newMetric(metricName, dsType, val, labels)
if err != nil {
return metrics, fmt.Errorf("error processing metric %s: %v", metricName, err)
return metrics, fmt.Errorf("error processing metric %s: %v", sanitize.String(metricName), err)
}
metrics = append(metrics, metric)

Expand Down
3 changes: 2 additions & 1 deletion receiver/collectdreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ require (

)

require github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.43.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -24,7 +26,6 @@ require (
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.43.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
go.opentelemetry.io/collector/model v0.44.0 // indirect
Expand Down

0 comments on commit c05fd29

Please sign in to comment.