Skip to content
Snippets Groups Projects
Commit 5883ce95 authored by Sean McGivern's avatar Sean McGivern
Browse files

`current_application_settings` belongs on `Gitlab::CurrentSettings`

The initializers including this were doing so at the top level, so every object
loaded after them had a `current_application_settings` method. However, if
someone had rack-attack enabled (which was loaded before these initializers), it
would try to load the API, and fail, because `Gitlab::CurrentSettings` didn't
have that method.

To fix this:

1. Don't include `Gitlab::CurrentSettings` at the top level. We do not need
   `Object.new.current_application_settings` to work.
2. Make `Gitlab::CurrentSettings` explicitly `extend self`, as we already use it
   like that in several places.
3. Change the initializers to use that new form.
parent bf51ab88
No related branches found
No related tags found
No related merge requests found
Showing
with 36 additions and 12 deletions
module RequiresWhitelistedMonitoringClient
extend ActiveSupport::Concern
include Gitlab::CurrentSettings
included do
before_action :validate_ip_whitelisted_or_valid_token!
end
Loading
Loading
Loading
Loading
@@ -202,7 +202,7 @@ module ApplicationHelper
end
 
def support_url
current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/'
Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/'
end
 
def page_filter_path(options = {})
Loading
Loading
module ApplicationSettingsHelper
extend self
include Gitlab::CurrentSettings
delegate :gravatar_enabled?,
:signup_enabled?,
:password_authentication_enabled?,
Loading
Loading
module AuthHelper
include Gitlab::CurrentSettings
PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze
FORM_BASED_PROVIDERS = [/\Aldap/, 'crowd'].freeze
 
Loading
Loading
module ProjectsHelper
include Gitlab::CurrentSettings
def link_to_project(project)
link_to [project.namespace.becomes(Namespace), project], title: h(project.name) do
title = content_tag(:span, project.name, class: 'project-name')
Loading
Loading
class BaseMailer < ActionMailer::Base
include Gitlab::CurrentSettings
around_action :render_with_default_locale
 
helper ApplicationHelper
helper MarkupHelper
 
attr_accessor :current_user
helper_method :current_user, :can?
helper_method :current_user, :can?, :current_application_settings
 
default from: proc { default_sender_address.format }
default reply_to: proc { default_reply_to_address.format }
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ module Spammable
 
def submittable_as_spam?
if user_agent_detail
user_agent_detail.submittable? && current_application_settings.akismet_enabled
user_agent_detail.submittable? && Gitlab::CurrentSettings.current_application_settings.akismet_enabled
else
false
end
Loading
Loading
Loading
Loading
@@ -19,6 +19,7 @@ class Project < ActiveRecord::Base
include Routable
 
extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings
 
BoardLimitExceeded = Class.new(StandardError)
 
Loading
Loading
Loading
Loading
@@ -2,6 +2,8 @@ class ProtectedBranch < ActiveRecord::Base
include Gitlab::ShellAdapter
include ProtectedRef
 
extend Gitlab::CurrentSettings
protected_ref_access_levels :merge, :push
 
# Check if branch name is marked as protected in the system
Loading
Loading
Loading
Loading
@@ -10,6 +10,8 @@ class Snippet < ActiveRecord::Base
include Spammable
include Editable
 
extend Gitlab::CurrentSettings
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description
cache_markdown_field :content
Loading
Loading
Loading
Loading
@@ -2,6 +2,7 @@ require 'carrierwave/orm/activerecord'
 
class User < ActiveRecord::Base
extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings
 
include Gitlab::ConfigHelper
include Gitlab::CurrentSettings
Loading
Loading
require_dependency 'declarative_policy'
 
class BasePolicy < DeclarativePolicy::Base
include Gitlab::CurrentSettings
desc "User is an instance admin"
with_options scope: :user, score: 0
condition(:admin) { @user&.admin? }
Loading
Loading
@@ -15,6 +13,6 @@ class BasePolicy < DeclarativePolicy::Base
 
desc "The application is restricted from public visibility"
condition(:restricted_public_level, scope: :global) do
current_application_settings.restricted_visibility_levels.include?(Gitlab::VisibilityLevel::PUBLIC)
Gitlab::CurrentSettings.current_application_settings.restricted_visibility_levels.include?(Gitlab::VisibilityLevel::PUBLIC)
end
end
class AkismetService
include Gitlab::CurrentSettings
attr_accessor :owner, :text, :options
 
def initialize(owner, text, options = {})
Loading
Loading
module Auth
class ContainerRegistryAuthenticationService < BaseService
include Gitlab::CurrentSettings
extend Gitlab::CurrentSettings
 
AUDIENCE = 'container_registry'.freeze
 
Loading
Loading
module Projects
class UpdatePagesService < BaseService
include Gitlab::CurrentSettings
BLOCK_SIZE = 32.kilobytes
MAX_SIZE = 1.terabyte
SITE_PATH = 'public/'.freeze
Loading
Loading
class UploadService
include Gitlab::CurrentSettings
def initialize(model, file, uploader_class = FileUploader)
@model, @file, @uploader_class = model, file, uploader_class
end
Loading
Loading
module Users
class BuildService < BaseService
include Gitlab::CurrentSettings
def initialize(current_user, params = {})
@current_user = current_user
@params = params.dup
Loading
Loading
# Be sure to restart your server when you modify this file.
 
require 'gitlab/current_settings'
include Gitlab::CurrentSettings
 
if Rails.env.production?
# allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done
begin
sentry_enabled = current_application_settings.sentry_enabled
sentry_enabled = Gitlab::CurrentSettings.current_application_settings.sentry_enabled
rescue
sentry_enabled = false
end
 
if sentry_enabled
Raven.configure do |config|
config.dsn = current_application_settings.sentry_dsn
config.dsn = Gitlab::CurrentSettings.current_application_settings.sentry_dsn
config.release = Gitlab::REVISION
 
# Sanitize fields based on those sanitized from Rails.
Loading
Loading
# Be sure to restart your server when you modify this file.
 
require 'gitlab/current_settings'
include Gitlab::CurrentSettings
 
# allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done
begin
Settings.gitlab['session_expire_delay'] = current_application_settings.session_expire_delay || 10080
Settings.gitlab['session_expire_delay'] = Gitlab::CurrentSettings.current_application_settings.session_expire_delay || 10080
rescue
Settings.gitlab['session_expire_delay'] ||= 10080
end
Loading
Loading
module API
module Helpers
module Runner
include Gitlab::CurrentSettings
JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN'.freeze
JOB_TOKEN_PARAM = :token
UPDATE_RUNNER_EVERY = 10 * 60
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment