AzureMonitorDatasource: Add bounds check to fix panics (#110879)
(azure-monitor-datasource): add bounds check to fix panics
This commit is contained in:
@@ -573,6 +573,10 @@ func addTraceDataLinksToFields(query *AzureLogAnalyticsQuery, azurePortalBaseUrl
|
||||
return err
|
||||
}
|
||||
|
||||
if len(queryJSONModel.AzureTraces.Resources) == 0 {
|
||||
return fmt.Errorf("no resources specified for Azure traces data link")
|
||||
}
|
||||
|
||||
traceIdVariable := "${__data.fields.traceID}"
|
||||
resultFormat := dataquery.ResultFormatTrace
|
||||
queryJSONModel.AzureTraces.ResultFormat = &resultFormat
|
||||
@@ -668,6 +672,9 @@ func (e *AzureLogAnalyticsDatasource) createRequest(ctx context.Context, queryUR
|
||||
if query.AppInsightsQuery {
|
||||
// If the query type is traces then we only need the first resource as the rest are specified in the query
|
||||
if query.QueryType == dataquery.AzureQueryTypeAzureTraces {
|
||||
if len(query.Resources) == 0 {
|
||||
return nil, fmt.Errorf("no resources specified for Azure traces Application Insights query")
|
||||
}
|
||||
body["applications"] = []string{query.Resources[0]}
|
||||
} else {
|
||||
body["applications"] = query.Resources
|
||||
|
||||
Reference in New Issue
Block a user