diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-21 18:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-21 18:10:03 +0300 |
commit | d5098d9fe3a5f05d9b90996851ab753f8b40cf65 (patch) | |
tree | 6f909667e89a3ad70e10c39b48fc417459b759fd /lib | |
parent | 4ea7a80898d3266d386ca928d7c253d4bf588e1c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/conan_packages.rb | 4 | ||||
-rw-r--r-- | lib/api/entities/milestone.rb | 1 | ||||
-rw-r--r-- | lib/api/helpers/packages/conan/api_helpers.rb | 1 | ||||
-rw-r--r-- | lib/api/maven_packages.rb | 3 | ||||
-rw-r--r-- | lib/api/nuget_packages.rb | 7 | ||||
-rw-r--r-- | lib/api/pypi_packages.rb | 7 | ||||
-rw-r--r-- | lib/carrier_wave_string_file.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/ci/features.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/email/receiver.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/metrics/instrumentation.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/setup_helper.rb | 20 |
11 files changed, 73 insertions, 9 deletions
diff --git a/lib/api/conan_packages.rb b/lib/api/conan_packages.rb index 6923d252fbd..3a55128781b 100644 --- a/lib/api/conan_packages.rb +++ b/lib/api/conan_packages.rb @@ -293,7 +293,7 @@ module API route_setting :authentication, job_token_allowed: true, basic_auth_personal_access_token: true put 'authorize' do - authorize_workhorse!(subject: project) + authorize_workhorse!(subject: project, maximum_size: project.actual_limits.conan_max_file_size) end end @@ -320,7 +320,7 @@ module API route_setting :authentication, job_token_allowed: true, basic_auth_personal_access_token: true put 'authorize' do - authorize_workhorse!(subject: project) + authorize_workhorse!(subject: project, maximum_size: project.actual_limits.conan_max_file_size) end desc 'Upload package files' do diff --git a/lib/api/entities/milestone.rb b/lib/api/entities/milestone.rb index 5a0c222d691..b191210a234 100644 --- a/lib/api/entities/milestone.rb +++ b/lib/api/entities/milestone.rb @@ -10,6 +10,7 @@ module API expose :state, :created_at, :updated_at expose :due_date expose :start_date + expose :expired?, as: :expired expose :web_url do |milestone, _options| Gitlab::UrlBuilder.build(milestone) diff --git a/lib/api/helpers/packages/conan/api_helpers.rb b/lib/api/helpers/packages/conan/api_helpers.rb index a5fde1af41e..d86b80a7e66 100644 --- a/lib/api/helpers/packages/conan/api_helpers.rb +++ b/lib/api/helpers/packages/conan/api_helpers.rb @@ -155,6 +155,7 @@ module API def upload_package_file(file_type) authorize_upload!(project) + bad_request!('File is too large') if project.actual_limits.exceeded?(:conan_max_file_size, params['file.size'].to_i) current_package = find_or_create_package diff --git a/lib/api/maven_packages.rb b/lib/api/maven_packages.rb index 32a45c59cfa..caaeabf7061 100644 --- a/lib/api/maven_packages.rb +++ b/lib/api/maven_packages.rb @@ -200,7 +200,7 @@ module API status 200 content_type Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE - ::Packages::PackageFileUploader.workhorse_authorize(has_length: true) + ::Packages::PackageFileUploader.workhorse_authorize(has_length: true, maximum_size: user_project.actual_limits.maven_max_file_size) end desc 'Upload the maven package file' do @@ -214,6 +214,7 @@ module API route_setting :authentication, job_token_allowed: true, deploy_token_allowed: true put ':id/packages/maven/*path/:file_name', requirements: MAVEN_ENDPOINT_REQUIREMENTS do authorize_upload! + bad_request!('File is too large') if user_project.actual_limits.exceeded?(:maven_max_file_size, params[:file].size) file_name, format = extract_format(params[:file_name]) diff --git a/lib/api/nuget_packages.rb b/lib/api/nuget_packages.rb index 56c4de2071d..87290cd07d9 100644 --- a/lib/api/nuget_packages.rb +++ b/lib/api/nuget_packages.rb @@ -92,6 +92,7 @@ module API put do authorize_upload!(authorized_user_project) + bad_request!('File is too large') if authorized_user_project.actual_limits.exceeded?(:nuget_max_file_size, params[:package].size) file_params = params.merge( file: params[:package], @@ -118,7 +119,11 @@ module API route_setting :authentication, deploy_token_allowed: true, job_token_allowed: :basic_auth, basic_auth_personal_access_token: true put 'authorize' do - authorize_workhorse!(subject: authorized_user_project, has_length: false) + authorize_workhorse!( + subject: authorized_user_project, + has_length: false, + maximum_size: authorized_user_project.actual_limits.nuget_max_file_size + ) end params do diff --git a/lib/api/pypi_packages.rb b/lib/api/pypi_packages.rb index 739928a61ed..b3668a88204 100644 --- a/lib/api/pypi_packages.rb +++ b/lib/api/pypi_packages.rb @@ -120,6 +120,7 @@ module API route_setting :authentication, deploy_token_allowed: true, basic_auth_personal_access_token: true post do authorize_upload!(authorized_user_project) + bad_request!('File is too large') if authorized_user_project.actual_limits.exceeded?(:pypi_max_file_size, params[:content].size) track_event('push_package') @@ -136,7 +137,11 @@ module API route_setting :authentication, deploy_token_allowed: true, basic_auth_personal_access_token: true post 'authorize' do - authorize_workhorse!(subject: authorized_user_project, has_length: false) + authorize_workhorse!( + subject: authorized_user_project, + has_length: false, + maximum_size: authorized_user_project.actual_limits.pypi_max_file_size + ) end end end diff --git a/lib/carrier_wave_string_file.rb b/lib/carrier_wave_string_file.rb index c9a64d9e631..b6bc3d986ca 100644 --- a/lib/carrier_wave_string_file.rb +++ b/lib/carrier_wave_string_file.rb @@ -4,4 +4,12 @@ class CarrierWaveStringFile < StringIO def original_filename "" end + + def self.new_file(file_content:, filename:, content_type: "application/octet-stream") + { + "tempfile" => StringIO.new(file_content), + "filename" => filename, + "content_type" => content_type + } + end end diff --git a/lib/gitlab/ci/features.rb b/lib/gitlab/ci/features.rb index 934d1a4c9f1..895daf65d0d 100644 --- a/lib/gitlab/ci/features.rb +++ b/lib/gitlab/ci/features.rb @@ -83,6 +83,10 @@ module Gitlab def self.project_transactionless_destroy?(project) Feature.enabled?(:project_transactionless_destroy, project, default_enabled: false) end + + def self.coverage_report_view?(project) + ::Feature.enabled?(:coverage_report_view, project) + end end end end diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index bf6c28b9f90..f5e47b43a9a 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -54,7 +54,8 @@ module Gitlab def key_from_additional_headers(mail) find_key_from_references(mail) || find_key_from_delivered_to_header(mail) || - find_key_from_envelope_to_header(mail) + find_key_from_envelope_to_header(mail) || + find_key_from_x_envelope_to_header(mail) end def ensure_references_array(references) @@ -91,6 +92,13 @@ module Gitlab end end + def find_key_from_x_envelope_to_header(mail) + Array(mail[:x_envelope_to]).find do |header| + key = Gitlab::IncomingEmail.key_from_address(header.value) + break key if key + end + end + def ignore_auto_reply!(mail) if auto_submitted?(mail) || auto_replied?(mail) raise AutoGeneratedEmailError diff --git a/lib/gitlab/metrics/instrumentation.rb b/lib/gitlab/metrics/instrumentation.rb index ff3fffe7b95..66361529546 100644 --- a/lib/gitlab/metrics/instrumentation.rb +++ b/lib/gitlab/metrics/instrumentation.rb @@ -120,9 +120,6 @@ module Gitlab def self.instrument(type, mod, name) return unless ::Gitlab::Metrics.enabled? - name = name.to_sym - target = type == :instance ? mod : mod.singleton_class - if type == :instance target = mod method_name = "##{name}" @@ -154,6 +151,8 @@ module Gitlab '*args' end + method_visibility = method_visibility_for(target, name) + proxy_module.class_eval <<-EOF, __FILE__, __LINE__ + 1 def #{name}(#{args_signature}) if trans = Gitlab::Metrics::Instrumentation.transaction @@ -163,11 +162,23 @@ module Gitlab super end end + #{method_visibility} :#{name} EOF target.prepend(proxy_module) end + def self.method_visibility_for(mod, name) + if mod.private_method_defined?(name) + :private + elsif mod.protected_method_defined?(name) + :protected + else + :public + end + end + private_class_method :method_visibility_for + # Small layer of indirection to make it easier to stub out the current # transaction. def self.transaction diff --git a/lib/gitlab/setup_helper.rb b/lib/gitlab/setup_helper.rb index 64a30fbe16c..47c685f1bc8 100644 --- a/lib/gitlab/setup_helper.rb +++ b/lib/gitlab/setup_helper.rb @@ -28,6 +28,26 @@ module Gitlab end # rubocop:enable Rails/Output + module Workhorse + extend Gitlab::SetupHelper + class << self + def configuration_toml(dir, _) + config = { redis: { URL: redis_url } } + + TomlRB.dump(config) + end + + def redis_url + data = YAML.load_file(Rails.root.join('config/resque.yml')) + data.dig(Rails.env, 'url') + end + + def get_config_path(dir) + File.join(dir, 'config.toml') + end + end + end + module Gitaly extend Gitlab::SetupHelper class << self |