Chore: Validate batch query refIds (#63018)

This commit is contained in:
Andres Martinez Gotor
2023-02-09 10:11:16 +01:00
committed by GitHub
parent 2a34293689
commit 00b692c0f9
4 changed files with 36 additions and 2 deletions
+15
View File
@@ -32,6 +32,21 @@ func (pr parsedRequest) getFlattenedQueries() []parsedQuery {
}
func (pr parsedRequest) validateRequest(ctx context.Context) error {
refIds := make(map[string]bool)
for _, pq := range pr.parsedQueries {
for _, q := range pq {
if refIds[q.query.RefID] {
return ErrDuplicateRefId
}
refIds[q.query.RefID] = true
}
}
// Skip header validation. See https://github.com/grafana/grafana/pull/58871
if true {
return nil
}
reqCtx := contexthandler.FromContext(ctx)
if reqCtx == nil || reqCtx.Req == nil {