AzureMonitorDatasource: Add bounds check to fix panics (#110879)

(azure-monitor-datasource): add bounds check to fix panics
This commit is contained in:
Tim Mulqueen
2025-09-11 12:31:11 +02:00
committed by GitHub
parent 5ce13061d5
commit 01b5543121
4 changed files with 202 additions and 0 deletions
@@ -207,6 +207,10 @@ func buildAppInsightsQuery(ctx context.Context, query backend.DataQuery, dsInfo
resources = []string{fmt.Sprintf("/subscriptions/%s", subscription)}
}
if len(resources) == 0 {
return nil, fmt.Errorf("no resources specified for Azure traces query")
}
resourceOrWorkspace := resources[0]
appInsightsQuery := appInsightsRegExp.Match([]byte(resourceOrWorkspace))
resourcesMap := make(map[string]bool, 0)
@@ -236,6 +240,9 @@ func buildAppInsightsQuery(ctx context.Context, query backend.DataQuery, dsInfo
if query.QueryType == string(dataquery.AzureQueryTypeTraceExemplar) {
resources = queryResources
if len(resources) == 0 {
return nil, fmt.Errorf("no correlation resources found for trace exemplar query with operation ID: %s", operationId)
}
resourceOrWorkspace = resources[0]
}