Commit 67ceed36 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 84a491ba e7d9d32a
...@@ -347,7 +347,7 @@ GEM ...@@ -347,7 +347,7 @@ GEM
gitlab-markup (1.7.0) gitlab-markup (1.7.0)
gitlab-sidekiq-fetcher (0.4.0) gitlab-sidekiq-fetcher (0.4.0)
sidekiq (~> 5) sidekiq (~> 5)
gitlab-styles (2.7.0) gitlab-styles (2.8.0)
rubocop (~> 0.69.0) rubocop (~> 0.69.0)
rubocop-gitlab-security (~> 0.1.0) rubocop-gitlab-security (~> 0.1.0)
rubocop-performance (~> 1.1.0) rubocop-performance (~> 1.1.0)
...@@ -469,7 +469,7 @@ GEM ...@@ -469,7 +469,7 @@ GEM
jaeger-client (0.10.0) jaeger-client (0.10.0)
opentracing (~> 0.3) opentracing (~> 0.3)
thrift thrift
jaro_winkler (1.5.2) jaro_winkler (1.5.3)
jira-ruby (1.4.1) jira-ruby (1.4.1)
activesupport activesupport
multipart-post multipart-post
...@@ -868,7 +868,7 @@ GEM ...@@ -868,7 +868,7 @@ GEM
ruby-fogbugz (0.2.1) ruby-fogbugz (0.2.1)
crack (~> 0.4) crack (~> 0.4)
ruby-prof (0.17.0) ruby-prof (0.17.0)
ruby-progressbar (1.10.0) ruby-progressbar (1.10.1)
ruby-saml (1.7.2) ruby-saml (1.7.2)
nokogiri (>= 1.5.10) nokogiri (>= 1.5.10)
ruby_parser (3.13.1) ruby_parser (3.13.1)
......
...@@ -42,9 +42,9 @@ class ApplicationSetting < ApplicationRecord ...@@ -42,9 +42,9 @@ class ApplicationSetting < ApplicationRecord
validates :uuid, presence: true validates :uuid, presence: true
validates :outbound_local_requests_whitelist, validates :outbound_local_requests_whitelist,
length: { maximum: 1_000, message: N_('is too long (maximum is 1000 entries)') } length: { maximum: 1_000, message: N_('is too long (maximum is 1000 entries)') },
allow_nil: false,
validates :outbound_local_requests_whitelist, qualified_domain_array: true, allow_blank: true qualified_domain_array: true
validates :session_expire_delay, validates :session_expire_delay,
presence: true, presence: true,
......
...@@ -163,6 +163,8 @@ module ApplicationSettingImplementation ...@@ -163,6 +163,8 @@ module ApplicationSettingImplementation
def outbound_local_requests_whitelist_arrays def outbound_local_requests_whitelist_arrays
strong_memoize(:outbound_local_requests_whitelist_arrays) do strong_memoize(:outbound_local_requests_whitelist_arrays) do
next [[], []] unless self.outbound_local_requests_whitelist
ip_whitelist = [] ip_whitelist = []
domain_whitelist = [] domain_whitelist = []
...@@ -284,6 +286,8 @@ module ApplicationSettingImplementation ...@@ -284,6 +286,8 @@ module ApplicationSettingImplementation
end end
def domain_strings_to_array(values) def domain_strings_to_array(values)
return [] unless values
values values
.split(DOMAIN_LIST_SEPARATOR) .split(DOMAIN_LIST_SEPARATOR)
.reject(&:empty?) .reject(&:empty?)
......
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
module TokenAuthenticatable module TokenAuthenticatable
extend ActiveSupport::Concern extend ActiveSupport::Concern
private
class_methods do class_methods do
private # rubocop:disable Lint/UselessAccessModifier private
def add_authentication_token_field(token_field, options = {}) def add_authentication_token_field(token_field, options = {})
if token_authenticatable_fields.include?(token_field) if token_authenticatable_fields.include?(token_field)
......
...@@ -23,9 +23,9 @@ class QualifiedDomainArrayValidator < ActiveModel::EachValidator ...@@ -23,9 +23,9 @@ class QualifiedDomainArrayValidator < ActiveModel::EachValidator
private private
def validate_value_present(record, attribute, value) def validate_value_present(record, attribute, value)
return unless value.blank? return unless value.nil?
record.errors.add(attribute, _('entries cannot be blank')) record.errors.add(attribute, _('entries cannot be nil'))
end end
def validate_host_length(record, attribute, value) def validate_host_length(record, attribute, value)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= _('Whitelist to allow requests to the local network from hooks and services') = _('Whitelist to allow requests to the local network from hooks and services')
= f.text_area :outbound_local_requests_whitelist_raw, placeholder: "example.com, 192.168.1.1", class: 'form-control', rows: 8 = f.text_area :outbound_local_requests_whitelist_raw, placeholder: "example.com, 192.168.1.1", class: 'form-control', rows: 8
%span.form-text.text-muted %span.form-text.text-muted
= _('Requests to these domain(s)/address(es) on the local network will be allowed when local requests from hooks and services are disabled. IP ranges such as 1:0:0:0:0:0:0:0/124 or 127.0.0.0/28 are supported. Domain wildcards are not supported currently. Use comma, semicolon, or newline to separate multiple entries. The whitelist can hold a maximum of 4000 entries. Domains should use IDNA encoding. Ex: domain.com, 192.168.1.1, 127.0.0.0/28.') = _('Requests to these domain(s)/address(es) on the local network will be allowed when local requests from hooks and services are not allowed. IP ranges such as 1:0:0:0:0:0:0:0/124 or 127.0.0.0/28 are supported. Domain wildcards are not supported currently. Use comma, semicolon, or newline to separate multiple entries. The whitelist can hold a maximum of 1000 entries. Domains should use IDNA encoding. Ex: example.com, 192.168.1.1, 127.0.0.0/28, xn--itlab-j1a.com.')
.form-group .form-group
.form-check .form-check
......
...@@ -17403,10 +17403,10 @@ msgstr "" ...@@ -17403,10 +17403,10 @@ msgstr ""
msgid "encrypted: needs to be a :required, :optional or :migrating!" msgid "encrypted: needs to be a :required, :optional or :migrating!"
msgstr "" msgstr ""
msgid "entries cannot be blank" msgid "entries cannot be larger than 255 characters"
msgstr "" msgstr ""
msgid "entries cannot be larger than 255 characters" msgid "entries cannot be nil"
msgstr "" msgstr ""
msgid "entries cannot contain HTML tags" msgid "entries cannot contain HTML tags"
......
...@@ -45,7 +45,7 @@ describe ApplicationSetting do ...@@ -45,7 +45,7 @@ describe ApplicationSetting do
it { is_expected.to allow_value(['xn--itlab-j1a.com']).for(:outbound_local_requests_whitelist) } it { is_expected.to allow_value(['xn--itlab-j1a.com']).for(:outbound_local_requests_whitelist) }
it { is_expected.not_to allow_value(['<h1></h1>']).for(:outbound_local_requests_whitelist) } it { is_expected.not_to allow_value(['<h1></h1>']).for(:outbound_local_requests_whitelist) }
it { is_expected.to allow_value(['gitlab.com']).for(:outbound_local_requests_whitelist) } it { is_expected.to allow_value(['gitlab.com']).for(:outbound_local_requests_whitelist) }
it { is_expected.to allow_value(nil).for(:outbound_local_requests_whitelist) } it { is_expected.not_to allow_value(nil).for(:outbound_local_requests_whitelist) }
it { is_expected.to allow_value([]).for(:outbound_local_requests_whitelist) } it { is_expected.to allow_value([]).for(:outbound_local_requests_whitelist) }
context "when user accepted let's encrypt terms of service" do context "when user accepted let's encrypt terms of service" do
......
...@@ -40,6 +40,11 @@ RSpec.shared_examples 'string of domains' do |attribute| ...@@ -40,6 +40,11 @@ RSpec.shared_examples 'string of domains' do |attribute|
setting.method("#{attribute}_raw=").call("example;34543:garbage:fdh5654;") setting.method("#{attribute}_raw=").call("example;34543:garbage:fdh5654;")
expect(setting.method(attribute).call).to contain_exactly('example', '34543:garbage:fdh5654') expect(setting.method(attribute).call).to contain_exactly('example', '34543:garbage:fdh5654')
end end
it 'does not raise error with nil' do
setting.method("#{attribute}_raw=").call(nil)
expect(setting.method(attribute).call).to eq([])
end
end end
RSpec.shared_examples 'application settings examples' do RSpec.shared_examples 'application settings examples' do
...@@ -75,6 +80,12 @@ RSpec.shared_examples 'application settings examples' do ...@@ -75,6 +80,12 @@ RSpec.shared_examples 'application settings examples' do
expect(setting.outbound_local_requests_whitelist_arrays).to contain_exactly(ip_whitelist, domain_whitelist) expect(setting.outbound_local_requests_whitelist_arrays).to contain_exactly(ip_whitelist, domain_whitelist)
end end
it 'does not raise error with nil' do
setting.outbound_local_requests_whitelist = nil
expect(setting.outbound_local_requests_whitelist_arrays).to contain_exactly([], [])
end
end end
describe 'usage ping settings' do describe 'usage ping settings' do
......
...@@ -19,20 +19,19 @@ describe QualifiedDomainArrayValidator do ...@@ -19,20 +19,19 @@ describe QualifiedDomainArrayValidator do
subject { validator.validate(record) } subject { validator.validate(record) }
shared_examples 'cannot be blank' do shared_examples 'can be nil' do
it 'returns error when attribute is blank' do it 'allows when attribute is nil' do
record.domain_array = [] record.domain_array = nil
subject subject
expect(record.errors).to be_present expect(record.errors).to be_empty
expect(record.errors.first[1]).to eq 'entries cannot be blank'
end end
end end
shared_examples 'can be nil' do shared_examples 'can be blank' do
it 'allows when attribute is nil' do it 'allows when attribute is blank' do
record.domain_array = nil record.domain_array = []
subject subject
...@@ -43,7 +42,7 @@ describe QualifiedDomainArrayValidator do ...@@ -43,7 +42,7 @@ describe QualifiedDomainArrayValidator do
describe 'validations' do describe 'validations' do
let(:validator) { described_class.new(attributes: [:domain_array]) } let(:validator) { described_class.new(attributes: [:domain_array]) }
it_behaves_like 'cannot be blank' it_behaves_like 'can be blank'
it 'returns error when attribute is nil' do it 'returns error when attribute is nil' do
record.domain_array = nil record.domain_array = nil
...@@ -51,6 +50,7 @@ describe QualifiedDomainArrayValidator do ...@@ -51,6 +50,7 @@ describe QualifiedDomainArrayValidator do
subject subject
expect(record.errors).to be_present expect(record.errors).to be_present
expect(record.errors.first[1]).to eq('entries cannot be nil')
end end
it 'allows when domain is valid' do it 'allows when domain is valid' do
...@@ -91,21 +91,13 @@ describe QualifiedDomainArrayValidator do ...@@ -91,21 +91,13 @@ describe QualifiedDomainArrayValidator do
let(:validator) { described_class.new(attributes: [:domain_array], allow_nil: true) } let(:validator) { described_class.new(attributes: [:domain_array], allow_nil: true) }
it_behaves_like 'can be nil' it_behaves_like 'can be nil'
it_behaves_like 'can be blank'
it_behaves_like 'cannot be blank'
end end
context 'when allow_blank is set to true' do context 'when allow_blank is set to true' do
let(:validator) { described_class.new(attributes: [:domain_array], allow_blank: true) } let(:validator) { described_class.new(attributes: [:domain_array], allow_blank: true) }
it_behaves_like 'can be nil' it_behaves_like 'can be nil'
it_behaves_like 'can be blank'
it 'allows when attribute is blank' do
record.domain_array = []
subject
expect(record.errors).to be_empty
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment