mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 09:05:04 -05:00
Plugins: Requests validator (#30445)
* Introduce PluginRequestValidator abstraction with a NoOp implementation * Update PluginRequestValidator abstraction to use the dsURL instead * Inject PluginRequestValidator into the HTTPServer and validate requests going through data source proxy * Inject PluginRequestValidator into the BackendPluginManager and validate requests going through it * Validate requests going through QueryMetrics & QueryMetricsV2 * Validate BackendPluginManager health requests * Fix backend plugins manager tests * Validate requests going through alerting service * Fix tests * fix tests * goimports Co-authored-by: Leonard Gram <leo@xlson.com>
This commit is contained in:
co-authored by
Leonard Gram
parent
4a324e3d74
commit
6415d2802e
@@ -119,6 +119,11 @@ func (c *QueryCondition) executeQuery(context *alerting.EvalContext, timeRange *
|
||||
return nil, fmt.Errorf("could not find datasource: %w", err)
|
||||
}
|
||||
|
||||
err := context.RequestValidator.Validate(getDsInfo.Result.Url, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("access denied: %w", err)
|
||||
}
|
||||
|
||||
req := c.getRequestForAlertRule(getDsInfo.Result, timeRange, context.IsDebug)
|
||||
result := make(tsdb.TimeSeriesSlice, 0)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/validations"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
@@ -235,7 +237,8 @@ func queryConditionScenario(desc string, fn queryConditionScenarioFunc) {
|
||||
|
||||
ctx := &queryConditionTestContext{}
|
||||
ctx.result = &alerting.EvalContext{
|
||||
Rule: &alerting.Rule{},
|
||||
Rule: &alerting.Rule{},
|
||||
RequestValidator: &validations.OSSPluginRequestValidator{},
|
||||
}
|
||||
|
||||
fn(ctx)
|
||||
|
||||
Reference in New Issue
Block a user