diff options
Diffstat (limited to 'app/services/metrics/dashboard')
3 files changed, 10 insertions, 3 deletions
diff --git a/app/services/metrics/dashboard/base_service.rb b/app/services/metrics/dashboard/base_service.rb index c112d75a9b5..514793694ba 100644 --- a/app/services/metrics/dashboard/base_service.rb +++ b/app/services/metrics/dashboard/base_service.rb @@ -42,7 +42,7 @@ module Metrics def allowed? return false unless params[:environment] - Ability.allowed?(current_user, :read_environment, project) + project&.feature_available?(:metrics_dashboard, current_user) end # Returns a new dashboard Hash, supplemented with DB info diff --git a/app/services/metrics/dashboard/grafana_metric_embed_service.rb b/app/services/metrics/dashboard/grafana_metric_embed_service.rb index d58b80162f5..d9ce2c5e905 100644 --- a/app/services/metrics/dashboard/grafana_metric_embed_service.rb +++ b/app/services/metrics/dashboard/grafana_metric_embed_service.rb @@ -18,6 +18,7 @@ module Metrics self.reactive_cache_lease_timeout = 30.seconds self.reactive_cache_refresh_interval = 30.minutes self.reactive_cache_lifetime = 30.minutes + self.reactive_cache_work_type = :external_dependency self.reactive_cache_worker_finder = ->(_id, *args) { from_cache(*args) } class << self @@ -112,7 +113,7 @@ module Metrics end def parse_json(json) - JSON.parse(json, symbolize_names: true) + Gitlab::Json.parse(json, symbolize_names: true) rescue JSON::ParserError raise DashboardProcessingError.new('Grafana response contains invalid json') end diff --git a/app/services/metrics/dashboard/transient_embed_service.rb b/app/services/metrics/dashboard/transient_embed_service.rb index ce81f337e47..cb6ca215447 100644 --- a/app/services/metrics/dashboard/transient_embed_service.rb +++ b/app/services/metrics/dashboard/transient_embed_service.rb @@ -23,7 +23,9 @@ module Metrics override :get_raw_dashboard def get_raw_dashboard - JSON.parse(params[:embed_json]) + Gitlab::Json.parse(params[:embed_json]) + rescue JSON::ParserError => e + invalid_embed_json!(e.message) end override :sequence @@ -35,6 +37,10 @@ module Metrics def identifiers Digest::SHA256.hexdigest(params[:embed_json]) end + + def invalid_embed_json!(message) + raise DashboardProcessingError.new("Parsing error for param :embed_json. #{message}") + end end end end |