mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: Fix unsafe code snippets (#57641)
* return an error if we can't extract queries from a panel * check for null or undefined
This commit is contained in:
@@ -61,6 +61,10 @@ var (
|
||||
Reason: "bad Request",
|
||||
StatusCode: 400,
|
||||
}
|
||||
ErrNoPanelQueriesFound = PublicDashboardErr{
|
||||
Reason: "failed to extract queries from panel",
|
||||
StatusCode: 400,
|
||||
}
|
||||
)
|
||||
|
||||
type PublicDashboard struct {
|
||||
|
||||
@@ -131,7 +131,7 @@ func (pd *PublicDashboardServiceImpl) GetQueryDataResponse(ctx context.Context,
|
||||
}
|
||||
|
||||
if len(metricReq.Queries) == 0 {
|
||||
return nil, nil
|
||||
return nil, models.ErrNoPanelQueriesFound
|
||||
}
|
||||
|
||||
anonymousUser := buildAnonymousUser(ctx, dashboard)
|
||||
|
||||
@@ -59,7 +59,7 @@ export class PublicDashboardDataSource extends DataSourceApi<DataQuery, DataSour
|
||||
}
|
||||
|
||||
private static isMixedDatasource(datasource: DataSourceRef | string | DataSourceApi | null): boolean {
|
||||
if (typeof datasource === 'string' || datasource === null) {
|
||||
if (typeof datasource === 'string' || datasource == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export class PublicDashboardDataSource extends DataSourceApi<DataQuery, DataSour
|
||||
}
|
||||
|
||||
private static resolveInterval(datasource: DataSourceRef | string | DataSourceApi | null): string {
|
||||
if (typeof datasource === 'string' || datasource === null) {
|
||||
if (typeof datasource === 'string' || datasource == null) {
|
||||
return DEFAULT_INTERVAL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user