mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
MySQL: Limit datasource error details returned from the backend (#19373)
Only return certain mysql errors from backend. The following errors is returned as is from backend: error code 1064 (parse error) error code 1054 (bad column/field selected) error code 1146 (table not exists) Any other errors is logged and returned as a generic error. Restrict use of certain functions: Do not allow usage of the following in query: system_user() session_user() current_user() or current_user user() show grants Fixes #19360
This commit is contained in:
committed by
GitHub
parent
7c499ffdd8
commit
3de693af49
@@ -38,11 +38,11 @@ func newMssqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
|
||||
MetricColumnTypes: []string{"VARCHAR", "CHAR", "NVARCHAR", "NCHAR"},
|
||||
}
|
||||
|
||||
rowTransformer := mssqlRowTransformer{
|
||||
queryResultTransformer := mssqlQueryResultTransformer{
|
||||
log: logger,
|
||||
}
|
||||
|
||||
return sqleng.NewSqlQueryEndpoint(&config, &rowTransformer, newMssqlMacroEngine(), logger)
|
||||
return sqleng.NewSqlQueryEndpoint(&config, &queryResultTransformer, newMssqlMacroEngine(), logger)
|
||||
}
|
||||
|
||||
func generateConnectionString(datasource *models.DataSource) (string, error) {
|
||||
@@ -62,11 +62,11 @@ func generateConnectionString(datasource *models.DataSource) (string, error) {
|
||||
return connStr, nil
|
||||
}
|
||||
|
||||
type mssqlRowTransformer struct {
|
||||
type mssqlQueryResultTransformer struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
func (t *mssqlRowTransformer) Transform(columnTypes []*sql.ColumnType, rows *core.Rows) (tsdb.RowValues, error) {
|
||||
func (t *mssqlQueryResultTransformer) TransformQueryResult(columnTypes []*sql.ColumnType, rows *core.Rows) (tsdb.RowValues, error) {
|
||||
values := make([]interface{}, len(columnTypes))
|
||||
valuePtrs := make([]interface{}, len(columnTypes))
|
||||
|
||||
@@ -100,3 +100,7 @@ func (t *mssqlRowTransformer) Transform(columnTypes []*sql.ColumnType, rows *cor
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func (t *mssqlQueryResultTransformer) TransformQueryError(err error) error {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user