Skip to content

Commit 9f90fed

Browse files
committed
Don't output error in HTTP response body
The exporter allows arbitrary URLs as targets, so we should avoid returning detailed error information in the response body in case an attacker were to use the exporter to attempt to discover/query HTTP servers in networks with poor isolation between services. Instead, the user should check the exporters logs, which do include the detailed error message.
1 parent 7ba7191 commit 9f90fed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"encoding/json"
5+
"errors"
56
"flag"
67
"fmt"
78
"io/ioutil"
@@ -90,14 +91,14 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) {
9091
metrics, err := c.queryOpenTSDB()
9192
if err != nil {
9293
log.Errorf("Error scraping target %s: %s", c.target, err)
93-
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "Error scraping target", nil, nil), err)
94+
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "", nil, nil), errors.New("Error scraping target, check exporter logs"))
9495
return
9596
}
9697
for _, m := range *metrics {
9798
value, err := m.Value.Float64()
9899
if err != nil {
99100
log.Errorf("Error scraping target %s: %s", c.target, err)
100-
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "Error scraping target", nil, nil), err)
101+
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "", nil, nil), errors.New("Error scraping target, check exporter logs"))
101102
return
102103
}
103104

0 commit comments

Comments
 (0)