Skip to content

Commit acb1c61

Browse files
author
Linus Wallgren
committed
Document ID header properties
It needs to be cryptographically unique so that each client is uniquely identified and cannot be mistaken with another client. If it is not cryptographically unique one client could potentially guess the ID and thus send data as if it is was another client. Signed-off-by: Linus Wallgren <[email protected]>
1 parent 289f852 commit acb1c61

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: cmd/proxy/coordinator.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
"github.com/go-kit/kit/log"
2626
"github.com/go-kit/kit/log/level"
2727
"github.com/google/uuid"
28+
"github.com/prometheus-community/pushprox/util"
2829
"github.com/prometheus/client_golang/prometheus"
2930
"github.com/prometheus/client_golang/prometheus/promauto"
30-
"github.com/prometheus-community/pushprox/util"
3131
)
3232

3333
var (
@@ -73,6 +73,8 @@ func NewCoordinator(logger log.Logger) (*Coordinator, error) {
7373
}
7474

7575
// Generate a unique ID
76+
// It is important this ID is cryptographically unique to ensure clients can't
77+
// be mixed up.
7678
func (c *Coordinator) genID() (string, error) {
7779
id, err := uuid.NewRandom()
7880
return id.String(), err
@@ -114,6 +116,8 @@ func (c *Coordinator) DoScrape(ctx context.Context, r *http.Request) (*http.Resp
114116
return nil, err
115117
}
116118
level.Info(c.logger).Log("msg", "DoScrape", "scrape_id", id, "url", r.URL.String())
119+
// It is important this id is cryptographically generated as it is relied
120+
// upon to match the request and the response.
117121
r.Header.Add("Id", id)
118122
select {
119123
case <-ctx.Done():

0 commit comments

Comments
 (0)