Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 22:01:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 22:01:26 +0300
commit1ff28a8d8d370efef8bbac2da1edb85b758d4643 (patch)
tree906de1dd9c7637330f2eaea9c1a4217decd9a749 /app/services/grafana
parenta876afc5fd85a4ccae6947941884f3913f472ab0 (diff)
Add latest changes from gitlab-org/security/gitlab@15-2-stable-ee
Diffstat (limited to 'app/services/grafana')
-rw-r--r--app/services/grafana/proxy_service.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/services/grafana/proxy_service.rb b/app/services/grafana/proxy_service.rb
index ac4c3cc091c..37272c85638 100644
--- a/app/services/grafana/proxy_service.rb
+++ b/app/services/grafana/proxy_service.rb
@@ -15,6 +15,10 @@ module Grafana
self.reactive_cache_work_type = :external_dependency
self.reactive_cache_worker_finder = ->(_id, *args) { from_cache(*args) }
+ SUPPORTED_DATASOURCE_PATTERN = %r{\A\d+\z}.freeze
+
+ SUPPORTED_PROXY_PATH = Gitlab::Metrics::Dashboard::Stages::GrafanaFormatter::PROXY_PATH
+
attr_accessor :project, :datasource_id, :proxy_path, :query_params
# @param project_id [Integer] Project id for which grafana is configured.
@@ -38,6 +42,7 @@ module Grafana
end
def execute
+ return cannot_proxy_response unless can_proxy?
return cannot_proxy_response unless client
with_reactive_cache(*cache_key) { |result| result }
@@ -69,6 +74,11 @@ module Grafana
private
+ def can_proxy?
+ SUPPORTED_PROXY_PATH == proxy_path &&
+ SUPPORTED_DATASOURCE_PATTERN.match?(datasource_id)
+ end
+
def client
project.grafana_integration&.client
end