diff options
Diffstat (limited to 'vendor')
24 files changed, 470 insertions, 57 deletions
diff --git a/vendor/Dockerfile/Ruby-alpine.Dockerfile b/vendor/Dockerfile/Ruby-alpine.Dockerfile index 0f748d84b5d..d115e7522b7 100644 --- a/vendor/Dockerfile/Ruby-alpine.Dockerfile +++ b/vendor/Dockerfile/Ruby-alpine.Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.5-alpine +FROM ruby:2.7-alpine # Edit with nodejs, mysql-client, postgresql-client, sqlite3, etc. for your needs. # Or delete entirely if not needed. @@ -9,7 +9,7 @@ RUN bundle config --global frozen 1 WORKDIR /usr/src/app -COPY Gemfile Gemfile.lock . +COPY Gemfile Gemfile.lock /usr/src/app/ # Install build dependencies - required for gems with native dependencies RUN apk add --no-cache --virtual build-deps build-base postgresql-dev && \ bundle install && \ @@ -24,4 +24,4 @@ COPY . . # For Rails ENV PORT 3000 EXPOSE 3000 -CMD ["bundle", "exec", "rails", "server"] +CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] diff --git a/vendor/Dockerfile/Ruby.Dockerfile b/vendor/Dockerfile/Ruby.Dockerfile index 289ed57bfa2..916e0dd99d3 100644 --- a/vendor/Dockerfile/Ruby.Dockerfile +++ b/vendor/Dockerfile/Ruby.Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.5 +FROM ruby:2.7 # Edit with nodejs, mysql-client, postgresql-client, sqlite3, etc. for your needs. # Or delete entirely if not needed. diff --git a/vendor/assets/javascripts/jasmine-jquery.js b/vendor/assets/javascripts/jasmine-jquery.js index 9b7b245009d..a1f1e892c57 100644 --- a/vendor/assets/javascripts/jasmine-jquery.js +++ b/vendor/assets/javascripts/jasmine-jquery.js @@ -33,7 +33,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (function (root, factory) { if (typeof module !== 'undefined' && module.exports) { - factory(root, root.jasmine, require('jquery')); + // The line below is patched from jquery => jquery/dist/jquery + // in order to load a jQuery with ajax, so that this testing library + // doesn't break + factory(root, root.jasmine, require('jquery/dist/jquery')); } else { factory(root, root.jasmine, root.jQuery); } diff --git a/vendor/assets/javascripts/jquery.endless-scroll.js b/vendor/assets/javascripts/jquery.endless-scroll.js index f022d9a5d06..fe0fe5b5a8e 100644 --- a/vendor/assets/javascripts/jquery.endless-scroll.js +++ b/vendor/assets/javascripts/jquery.endless-scroll.js @@ -19,7 +19,6 @@ * // using some custom options * $(document).endlessScroll({ * fireOnce: false, - * fireDelay: false, * loader: "<div class=\"loading\"><div>", * callback: function(){ * alert("test"); @@ -30,7 +29,6 @@ * * bottomPixels integer the number of pixels from the bottom of the page that triggers the event * fireOnce boolean only fire once until the execution of the current event is completed - * fireDelay integer delay the subsequent firing, in milliseconds, 0 or false to disable delay * loader string the HTML to be displayed during loading * data string|function plain HTML data, can be either a string or a function that returns a string, * when passed as a function it accepts one argument: fire sequence (the number @@ -55,7 +53,6 @@ var defaults = { bottomPixels : 50, fireOnce : true, - fireDelay : 150, loader : "<br />Loading...<br />", data : "", insertAfter : "div:last", @@ -102,21 +99,11 @@ data = typeof options.data == 'function' ? options.data.apply(this, [fireSequence]) : options.data; if (data !== false) { - $(options.insertAfter).after("<div id=\"endless_scroll_data\">" + data + "</div>"); - $("#endless_scroll_data").hide().fadeIn(250, function() {$(this).removeAttr("id");}); + $(options.insertAfter).after("<div>" + data + "</div>"); options.callback.apply(this, [fireSequence]); - if (options.fireDelay !== false || options.fireDelay !== 0) { - $("body").after("<div id=\"endless_scroll_marker\"></div>"); - // slight delay for preventing event firing twice - $("#endless_scroll_marker").fadeTo(options.fireDelay, 1, function() { - $(this).remove(); - fired = false; - }); - } - else - fired = false; + fired = false; } $("#endless_scroll_loader").remove(); diff --git a/vendor/gems/mail-smtp_pool/.gitignore b/vendor/gems/mail-smtp_pool/.gitignore new file mode 100644 index 00000000000..1fbdf80cd36 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/.gitignore @@ -0,0 +1,3 @@ +Gemfile.lock +*.gem +.bundle diff --git a/vendor/gems/mail-smtp_pool/.gitlab-ci.yml b/vendor/gems/mail-smtp_pool/.gitlab-ci.yml new file mode 100644 index 00000000000..56eff5b30a7 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/.gitlab-ci.yml @@ -0,0 +1,29 @@ +workflow: + rules: + - if: $CI_MERGE_REQUEST_ID + +.rspec: + cache: + key: mail-smtp_pool-ruby + paths: + - vendor/gems/mail-smtp_pool/vendor/ruby + before_script: + - cd vendor/gems/mail-smtp_pool + - ruby -v # Print out ruby version for debugging + - gem install bundler --no-document # Bundler is not installed with the image + - bundle config set --local path 'vendor' # Install dependencies into ./vendor/ruby + - bundle install -j $(nproc) + script: + - bundle exec rspec + +rspec-2.6: + image: "ruby:2.6" + extends: .rspec + +rspec-2.7: + image: "ruby:2.7" + extends: .rspec + +rspec-3.0: + image: "ruby:3.0" + extends: .rspec diff --git a/vendor/gems/mail-smtp_pool/Gemfile b/vendor/gems/mail-smtp_pool/Gemfile new file mode 100644 index 00000000000..7f4f5e950d1 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/Gemfile @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +gemspec diff --git a/vendor/shims/mimemagic/LICENSE.txt b/vendor/gems/mail-smtp_pool/LICENSE index 568df6132bc..e6de2f90864 100644 --- a/vendor/shims/mimemagic/LICENSE.txt +++ b/vendor/gems/mail-smtp_pool/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 GitLab B.V. +Copyright (c) 2016-2021 GitLab B.V. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/gems/mail-smtp_pool/README.md b/vendor/gems/mail-smtp_pool/README.md new file mode 100644 index 00000000000..bdb2be97663 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/README.md @@ -0,0 +1,57 @@ +# Mail::SMTPPool + +This gem is an extension to `Mail` that allows delivery of emails using an SMTP connection pool + +## Installation + +Add this line to your application's Gemfile: + +```ruby +gem 'mail-smtp_pool' +``` + +And then execute: + +```shell +bundle +``` + +Or install it yourself as: + +```shell +gem install mail-smtp_pool +``` + +## Usage with ActionMailer + +```ruby +# config/environments/development.rb + +Rails.application.configure do + ... + + ActionMailer::Base.add_delivery_method :smtp_pool, Mail::SMTPPool + + config.action_mailer.perform_deliveries = true + config.action_mailer.smtp_pool_settings = { + pool: Mail::SMTPPool.create_pool( + pool_size: 5, + pool_timeout: 5, + address: 'smtp.gmail.com', + port: 587, + domain: 'example.com', + user_name: '<username>', + password: '<password>', + authentication: 'plain', + enable_starttls_auto: true + ) + } +end +``` + +Configuration options: + +* `pool_size` - The maximum number of SMTP connections in the pool. Connections are created lazily as needed. +* `pool_timeout` - The number of seconds to wait for a connection in the pool to be available. A `Timeout::Error` exception is raised when this is exceeded. + +This also accepts all options supported by `Mail::SMTP`. See https://www.rubydoc.info/gems/mail/2.6.1/Mail/SMTP for more information. diff --git a/vendor/gems/mail-smtp_pool/lib/mail/smtp_pool.rb b/vendor/gems/mail-smtp_pool/lib/mail/smtp_pool.rb new file mode 100644 index 00000000000..ab8a7652058 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/lib/mail/smtp_pool.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'connection_pool' +require 'mail/smtp_pool/connection' + +module Mail + class SMTPPool + POOL_DEFAULTS = { + pool_size: 5, + pool_timeout: 5 + }.freeze + + class << self + def create_pool(settings = {}) + pool_settings = POOL_DEFAULTS.merge(settings) + smtp_settings = settings.reject { |k, v| POOL_DEFAULTS.keys.include?(k) } + + ConnectionPool.new(size: pool_settings[:pool_size], timeout: pool_settings[:pool_timeout]) do + Mail::SMTPPool::Connection.new(smtp_settings) + end + end + end + + def initialize(settings) + raise ArgumentError, 'pool is required. You can create one using Mail::SMTPPool.create_pool.' if settings[:pool].nil? + + @pool = settings[:pool] + end + + def deliver!(mail) + @pool.with { |conn| conn.deliver!(mail) } + end + end +end diff --git a/vendor/gems/mail-smtp_pool/lib/mail/smtp_pool/connection.rb b/vendor/gems/mail-smtp_pool/lib/mail/smtp_pool/connection.rb new file mode 100644 index 00000000000..ab0d20153d8 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/lib/mail/smtp_pool/connection.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +# A connection object that can be used to deliver mail. +# +# This is meant to be used in a pool so the main difference between this +# and Mail::SMTP is that this expects deliver! to be called multiple times. +# +# SMTP connection reset and error handling is handled by this class and +# the SMTP connection is not closed after a delivery. + +require 'mail' + +module Mail + class SMTPPool + class Connection < Mail::SMTP + def initialize(values) + super + + @smtp_session = nil + end + + def deliver!(mail) + response = Mail::SMTPConnection.new(connection: smtp_session, return_response: true).deliver!(mail) + + settings[:return_response] ? response : self + end + + def finish + finish_smtp_session if @smtp_session && @smtp_session.started? + end + + private + + def smtp_session + return start_smtp_session if @smtp_session.nil? || !@smtp_session.started? + return @smtp_session if reset_smtp_session + + finish_smtp_session + start_smtp_session + end + + def start_smtp_session + @smtp_session = build_smtp_session.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication]) + end + + def reset_smtp_session + !@smtp_session.instance_variable_get(:@error_occurred) && @smtp_session.rset.success? + rescue Net::SMTPError, IOError + false + end + + def finish_smtp_session + @smtp_session.finish + rescue Net::SMTPError, IOError + ensure + @smtp_session = nil + end + end + end +end diff --git a/vendor/gems/mail-smtp_pool/mail-smtp_pool.gemspec b/vendor/gems/mail-smtp_pool/mail-smtp_pool.gemspec new file mode 100644 index 00000000000..3d9036f19b1 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/mail-smtp_pool.gemspec @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +lib = File.expand_path('lib', __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +Gem::Specification.new do |spec| + spec.name = 'mail-smtp_pool' + spec.version = '0.1.0' + spec.authors = ['Heinrich Lee Yu'] + spec.email = ['heinrich@gitlab.com'] + + spec.summary = 'Mail extension for sending using an SMTP connection pool' + spec.homepage = 'https://gitlab.com/gitlab-org/gitlab/-/tree/master/vendor/gems/mail-smtp_pool' + spec.metadata = { 'source_code_uri' => 'https://gitlab.com/gitlab-org/gitlab/-/tree/master/vendor/gems/mail-smtp_pool' } + spec.license = 'MIT' + + spec.files = Dir['lib/**/*.rb'] + spec.require_paths = ['lib'] + + # Please maintain alphabetical order for dependencies + spec.add_runtime_dependency 'connection_pool', '~> 2.0' + spec.add_runtime_dependency 'mail', '~> 2.7' + + # Please maintain alphabetical order for dev dependencies + spec.add_development_dependency 'rspec', '~> 3.10.0' +end diff --git a/vendor/gems/mail-smtp_pool/spec/lib/mail/smtp_pool/connection_spec.rb b/vendor/gems/mail-smtp_pool/spec/lib/mail/smtp_pool/connection_spec.rb new file mode 100644 index 00000000000..78426296406 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/spec/lib/mail/smtp_pool/connection_spec.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Mail::SMTPPool::Connection do + let(:connection) { described_class.new({}) } + let(:mail) do + Mail.new do + from 'mikel@test.lindsaar.net' + to 'you@test.lindsaar.net' + subject 'This is a test email' + body 'Test body' + end + end + + after do + MockSMTP.clear_deliveries + end + + describe '#deliver!' do + it 'delivers mail using the same SMTP connection' do + mock_smtp = MockSMTP.new + + expect(Net::SMTP).to receive(:new).once.and_return(mock_smtp) + expect(mock_smtp).to receive(:sendmail).twice.and_call_original + expect(mock_smtp).to receive(:rset).once.and_call_original + + connection.deliver!(mail) + connection.deliver!(mail) + + expect(MockSMTP.deliveries.size).to eq(2) + end + + context 'when RSET fails' do + let(:mock_smtp) { MockSMTP.new } + let(:mock_smtp_2) { MockSMTP.new } + + before do + expect(Net::SMTP).to receive(:new).twice.and_return(mock_smtp, mock_smtp_2) + end + + context 'with an IOError' do + before do + expect(mock_smtp).to receive(:rset).once.and_raise(IOError) + end + + it 'creates a new SMTP connection' do + expect(mock_smtp).to receive(:sendmail).once.and_call_original + expect(mock_smtp).to receive(:finish).once.and_call_original + expect(mock_smtp_2).to receive(:sendmail).once.and_call_original + + connection.deliver!(mail) + connection.deliver!(mail) + + expect(MockSMTP.deliveries.size).to eq(2) + end + end + + context 'with an SMTP error' do + before do + expect(mock_smtp).to receive(:rset).once.and_raise(Net::SMTPServerBusy) + end + + it 'creates a new SMTP connection' do + expect(mock_smtp).to receive(:sendmail).once.and_call_original + expect(mock_smtp).to receive(:finish).once.and_call_original + expect(mock_smtp_2).to receive(:sendmail).once.and_call_original + + connection.deliver!(mail) + connection.deliver!(mail) + + expect(MockSMTP.deliveries.size).to eq(2) + end + + context 'and closing the old connection fails' do + before do + expect(mock_smtp).to receive(:finish).once.and_raise(IOError) + end + + it 'creates a new SMTP connection' do + expect(mock_smtp).to receive(:sendmail).once.and_call_original + expect(mock_smtp_2).to receive(:sendmail).once.and_call_original + + connection.deliver!(mail) + connection.deliver!(mail) + + expect(MockSMTP.deliveries.size).to eq(2) + end + end + end + end + end +end diff --git a/vendor/gems/mail-smtp_pool/spec/lib/mail/smtp_pool_spec.rb b/vendor/gems/mail-smtp_pool/spec/lib/mail/smtp_pool_spec.rb new file mode 100644 index 00000000000..aa2a0e19ac8 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/spec/lib/mail/smtp_pool_spec.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Mail::SMTPPool do + describe '.create_pool' do + it 'sets the default pool settings' do + expect(ConnectionPool).to receive(:new).with(size: 5, timeout: 5).once + + described_class.create_pool + end + + it 'allows overriding pool size and timeout' do + expect(ConnectionPool).to receive(:new).with(size: 3, timeout: 2).once + + described_class.create_pool(pool_size: 3, pool_timeout: 2) + end + + it 'creates an SMTP connection with the correct settings' do + settings = { address: 'smtp.example.com', port: '465' } + + smtp_pool = described_class.create_pool(settings) + + expect(Mail::SMTPPool::Connection).to receive(:new).with(settings).once.and_call_original + + smtp_pool.checkout + end + end + + describe '#initialize' do + it 'raises an error if a pool is not specified' do + expect { described_class.new({}) }.to raise_error( + ArgumentError, 'pool is required. You can create one using Mail::SMTPPool.create_pool.' + ) + end + end + + describe '#deliver!' do + let(:mail) do + Mail.new do + from 'mikel@test.lindsaar.net' + to 'you@test.lindsaar.net' + subject 'This is a test email' + body 'Test body' + end + end + + after do + MockSMTP.clear_deliveries + end + + it 'delivers mail using a connection from the pool' do + connection_pool = double(ConnectionPool) + connection = double(Mail::SMTPPool::Connection) + + expect(connection_pool).to receive(:with).and_yield(connection) + expect(connection).to receive(:deliver!).with(mail) + + described_class.new(pool: connection_pool).deliver!(mail) + end + + it 'delivers mail' do + described_class.new(pool: described_class.create_pool).deliver!(mail) + + expect(MockSMTP.deliveries.size).to eq(1) + end + end +end diff --git a/vendor/gems/mail-smtp_pool/spec/spec_helper.rb b/vendor/gems/mail-smtp_pool/spec/spec_helper.rb new file mode 100644 index 00000000000..4d339850381 --- /dev/null +++ b/vendor/gems/mail-smtp_pool/spec/spec_helper.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true + +require 'mail/smtp_pool' + +# Original mockup from ActionMailer +# Based on https://github.com/mikel/mail/blob/22a7afc23f253319965bf9228a0a430eec94e06d/spec/spec_helper.rb#L74-L138 +class MockSMTP + def self.deliveries + @@deliveries + end + + def self.security + @@security + end + + def initialize + @@deliveries = [] + @@security = nil + @started = false + end + + def sendmail(mail, from, to) + @@deliveries << [mail, from, to] + 'OK' + end + + def rset + Net::SMTP::Response.parse('250 OK') + end + + def start(*args) + @started = true + + if block_given? + result = yield(self) + @started = false + + return result + else + return self + end + end + + def started? + @started + end + + def finish + @started = false + return true + end + + def self.clear_deliveries + @@deliveries = [] + end + + def self.clear_security + @@security = nil + end + + def enable_tls(context) + raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @@security && @@security != :enable_tls + @@security = :enable_tls + context + end + + def enable_starttls(context = nil) + raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @@security == :enable_tls + @@security = :enable_starttls + context + end + + def enable_starttls_auto(context) + raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @@security == :enable_tls + @@security = :enable_starttls_auto + context + end +end + +class Net::SMTP + def self.new(*args) + MockSMTP.new + end +end diff --git a/vendor/project_templates/gatsby.tar.gz b/vendor/project_templates/gatsby.tar.gz Binary files differindex a4ae5f99047..52bb056630e 100644 --- a/vendor/project_templates/gatsby.tar.gz +++ b/vendor/project_templates/gatsby.tar.gz diff --git a/vendor/project_templates/learn_gitlab.tar.gz b/vendor/project_templates/learn_gitlab.tar.gz Binary files differindex 0eca66b064a..2596d9bade0 100644 --- a/vendor/project_templates/learn_gitlab.tar.gz +++ b/vendor/project_templates/learn_gitlab.tar.gz diff --git a/vendor/project_templates/learn_gitlab_ultimate_trial.tar.gz b/vendor/project_templates/learn_gitlab_ultimate_trial.tar.gz Binary files differindex 2ec47956706..89d69de52dc 100644 --- a/vendor/project_templates/learn_gitlab_ultimate_trial.tar.gz +++ b/vendor/project_templates/learn_gitlab_ultimate_trial.tar.gz diff --git a/vendor/shims/mimemagic/Gemfile b/vendor/shims/mimemagic/Gemfile deleted file mode 100644 index ef48903d334..00000000000 --- a/vendor/shims/mimemagic/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -# Specify your gem's dependencies in mimemagic.gemspec -gemspec - -gem "rake", "~> 12.0" diff --git a/vendor/shims/mimemagic/README.md b/vendor/shims/mimemagic/README.md deleted file mode 100644 index 57ef8dc41e1..00000000000 --- a/vendor/shims/mimemagic/README.md +++ /dev/null @@ -1 +0,0 @@ -This is a fake gem to prevent mimemagic from being included into GitLab. diff --git a/vendor/shims/mimemagic/Rakefile b/vendor/shims/mimemagic/Rakefile deleted file mode 100644 index 43022f711e2..00000000000 --- a/vendor/shims/mimemagic/Rakefile +++ /dev/null @@ -1,2 +0,0 @@ -require "bundler/gem_tasks" -task :default => :spec diff --git a/vendor/shims/mimemagic/lib/mimemagic.rb b/vendor/shims/mimemagic/lib/mimemagic.rb deleted file mode 100644 index 1deab5d90a7..00000000000 --- a/vendor/shims/mimemagic/lib/mimemagic.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "mimemagic/version" - -module MimeMagic - class Error < StandardError; end - raise Error, 'This gem should never be required' -end diff --git a/vendor/shims/mimemagic/lib/mimemagic/version.rb b/vendor/shims/mimemagic/lib/mimemagic/version.rb deleted file mode 100644 index eab707147e7..00000000000 --- a/vendor/shims/mimemagic/lib/mimemagic/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module MimeMagic - VERSION = "0.3.7" -end diff --git a/vendor/shims/mimemagic/mimemagic.gemspec b/vendor/shims/mimemagic/mimemagic.gemspec deleted file mode 100644 index 86f7f824923..00000000000 --- a/vendor/shims/mimemagic/mimemagic.gemspec +++ /dev/null @@ -1,18 +0,0 @@ -require_relative 'lib/mimemagic/version' - -Gem::Specification.new do |spec| - spec.name = "mimemagic" - spec.version = MimeMagic::VERSION - spec.authors = ["Marc Shaw"] - spec.email = ["mshaw@gitlab.com"] - - spec.summary = %q{MimeMagic shim} - spec.description = %q{A shim for mimemagic} - spec.homepage = "https://gitlab.com/gitlab-org/gitlab/-/tree/master/vendor/shims/mimemagic" - spec.license = "MIT" - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") - - spec.files = %w[lib/mimemagic.rb lib/mimemagic/version.rb] - - spec.require_paths = ["lib"] -end |