diff --git a/pkg/tsdb/testdatasource/csv_data.go b/pkg/tsdb/testdatasource/csv_data.go index e45ded815b4..6cb812e0ee5 100644 --- a/pkg/tsdb/testdatasource/csv_data.go +++ b/pkg/tsdb/testdatasource/csv_data.go @@ -8,6 +8,7 @@ import ( "io" "os" "path/filepath" + "regexp" "strconv" "strings" "time" @@ -72,7 +73,9 @@ func (s *Service) handleCsvFileScenario(ctx context.Context, req *backend.QueryD } func (s *Service) loadCsvFile(fileName string) (*data.Frame, error) { - if filepath.Ext(fileName) != ".csv" || strings.Contains(fileName, "..") { + validFileName := regexp.MustCompile(`^\w+\.csv$`) + + if !validFileName.MatchString(fileName) { return nil, fmt.Errorf("invalid csv file name: %q", fileName) }