Skip to content

Commit

Permalink
receive: Add extra validation for tenant label name. (#4404)
Browse files Browse the repository at this point in the history
Fixes: #4396

Signed-off-by: Bartlomiej Plotka <[email protected]>
  • Loading branch information
bwplotka authored Jul 2, 2021
1 parent 55d2775 commit 06ae3b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func registerReceive(app *extkingpin.App) {
return errors.Wrap(err, "parse labels")
}

if !model.LabelName.IsValid(model.LabelName(conf.tenantLabelName)) {
return errors.Errorf("unsupported format for tenant label name, got %s", conf.tenantLabelName)
}
if len(lset) == 0 {
return errors.New("no external labels configured for receive, uniquely identifying external labels must be configured (ideally with `receive_` prefix); see https://thanos.io/tip/thanos/storage.md#external-labels for details.")
}
Expand Down Expand Up @@ -681,8 +684,8 @@ type receiveConfig struct {
refreshInterval *model.Duration
endpoint string
tenantHeader string
defaultTenantID string
tenantLabelName string
defaultTenantID string
replicaHeader string
replicationFactor uint64
forwardTimeout *model.Duration
Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ func parseFlagLabels(s []string) (labels.Labels, error) {
if len(parts) != 2 {
return nil, errors.Errorf("unrecognized label %q", l)
}
if !model.LabelName.IsValid(model.LabelName(string(parts[0]))) {
if !model.LabelName.IsValid(model.LabelName(parts[0])) {
return nil, errors.Errorf("unsupported format for label %s", l)
}
val, err := strconv.Unquote(parts[1])
Expand Down

0 comments on commit 06ae3b8

Please sign in to comment.