Compare commits

...

3 Commits

Author SHA1 Message Date
nmarrs b5b5a3ec16 apply backport 2025-04-07 09:14:29 -05:00
Yuri Tseretyan 52e65459b7 require editor to fetch config 2025-04-07 09:14:29 -05:00
Andres Martinez Gotor 6d3b159e63 Sanitize paths before evaluating access to route 2025-04-07 09:14:29 -05:00
4 changed files with 20 additions and 3 deletions
+9 -1
View File
@@ -301,7 +301,15 @@ func (proxy *DataSourceProxy) validateRequest() error {
}
// route match
if !strings.HasPrefix(proxy.proxyPath, route.Path) {
r1, err := util.CleanRelativePath(proxy.proxyPath)
if err != nil {
return err
}
r2, err := util.CleanRelativePath(route.Path)
if err != nil {
return err
}
if !strings.HasPrefix(r1, r2) {
continue
}
+8
View File
@@ -257,6 +257,14 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
err = proxy.validateRequest()
require.NoError(t, err)
})
t.Run("path with slashes and user is editor", func(t *testing.T) {
ctx, _ := setUp()
proxy, err := setupDSProxyTest(t, ctx, ds, routes, "//api//admin")
require.NoError(t, err)
err = proxy.validateRequest()
require.Error(t, err)
})
})
t.Run("plugin route with RBAC protection user is allowed", func(t *testing.T) {
@@ -39,7 +39,7 @@
{
"method": "GET",
"path": "api/v1/alerts",
"reqRole": "Admin"
"reqRole": "Editor"
}
],
"info": {
@@ -641,7 +641,8 @@ function fieldValueColors(f: Field, theme: GrafanaTheme2): FieldColorValues {
let lasti = steps.length - 1;
for (let i = lasti; i > 0; i--) {
conds += `v >= ${steps[i].value} ? ${i} : `;
let rhs = Number(steps[i].value);
conds += `v >= ${rhs} ? ${i} : `;
}
conds += '0';