Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
1adb4373ba
commit
18a102a5b9
|
|
@ -1,7 +1,9 @@
|
|||
# Tell the Rack::Attack Rack middleware to maintain an IP blacklist.
|
||||
# We update the blacklist in Gitlab::Auth::IpRateLimiter.
|
||||
Rack::Attack.blocklist('Git HTTP Basic Auth') do |req|
|
||||
next false unless Gitlab.config.rack_attack.git_basic_auth.enabled
|
||||
rate_limiter = Gitlab::Auth::IpRateLimiter.new(req.ip)
|
||||
|
||||
next false if !rate_limiter.enabled? || rate_limiter.trusted_ip?
|
||||
|
||||
Rack::Attack::Allow2Ban.filter(req.ip, Gitlab.config.rack_attack.git_basic_auth) do
|
||||
# This block only gets run if the IP was not already banned.
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ GitLab supports:
|
|||
- Creating a new GKE cluster using the GitLab UI.
|
||||
- Providing credentials to add an [existing Kubernetes cluster](#add-existing-cluster).
|
||||
|
||||
Starting from [GitLab 12.4](https://gitlab.com/gitlab-org/gitlab/issues/25925), all the GKE clusters provisioned by GitLab are [VPC-Native](https://cloud.google.com/kubernetes-engine/docs/how-to/alias-ips).
|
||||
|
||||
NOTE: **Note:**
|
||||
The [Google authentication integration](../../../integration/google.md) must
|
||||
be enabled in GitLab at the instance level. If that's not the case, ask your
|
||||
|
|
|
|||
|
|
@ -21,11 +21,12 @@ module Gitlab
|
|||
end
|
||||
|
||||
def register_fail!
|
||||
return false if trusted_ip?
|
||||
|
||||
# Allow2Ban.filter will return false if this IP has not failed too often yet
|
||||
@banned = Rack::Attack::Allow2Ban.filter(ip, config) do
|
||||
# If we return false here, the failure for this IP is ignored by Allow2Ban
|
||||
# If we return true here, the count for the IP is incremented.
|
||||
ip_can_be_banned?
|
||||
# We return true to increment the count for this IP
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -33,20 +34,16 @@ module Gitlab
|
|||
@banned
|
||||
end
|
||||
|
||||
def trusted_ip?
|
||||
trusted_ips.any? { |netmask| netmask.include?(ip) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def config
|
||||
Gitlab.config.rack_attack.git_basic_auth
|
||||
end
|
||||
|
||||
def ip_can_be_banned?
|
||||
!trusted_ip?
|
||||
end
|
||||
|
||||
def trusted_ip?
|
||||
trusted_ips.any? { |netmask| netmask.include?(ip) }
|
||||
end
|
||||
|
||||
def trusted_ips
|
||||
strong_memoize(:trusted_ips) do
|
||||
config.ip_whitelist.map do |proxy|
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::ExclusiveLeaseHelpers, :clean_gitlab_redis_shared_state do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::ExternalAuthorization, :request_store do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::FakeApplicationSettings do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Gitlab::Favicon, :request_store do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::FileDetector do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::FileFinder do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::GitAccess do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::GitAccessWiki do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::GitRefValidator do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Git do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
# We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::GithubImport do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe ::Gitlab::GlRepository do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Gpg do
|
||||
|
|
@ -63,7 +65,7 @@ describe Gitlab::Gpg do
|
|||
it 'downcases the email' do
|
||||
public_key = double(:key)
|
||||
fingerprints = double(:fingerprints)
|
||||
uid = double(:uid, name: 'Nannie Bernhard', email: 'NANNIE.BERNHARD@EXAMPLE.COM')
|
||||
uid = double(:uid, name: +'Nannie Bernhard', email: +'NANNIE.BERNHARD@EXAMPLE.COM')
|
||||
raw_key = double(:raw_key, uids: [uid])
|
||||
allow(Gitlab::Gpg::CurrentKeyChain).to receive(:fingerprints_from_key).with(public_key).and_return(fingerprints)
|
||||
allow(GPGME::Key).to receive(:find).with(:public, anything).and_return([raw_key])
|
||||
|
|
@ -78,8 +80,8 @@ describe Gitlab::Gpg do
|
|||
it 'rejects non UTF-8 names and addresses' do
|
||||
public_key = double(:key)
|
||||
fingerprints = double(:fingerprints)
|
||||
email = "\xEEch@test.com".force_encoding('ASCII-8BIT')
|
||||
uid = double(:uid, name: 'Test User', email: email)
|
||||
email = (+"\xEEch@test.com").force_encoding('ASCII-8BIT')
|
||||
uid = double(:uid, name: +'Test User', email: email)
|
||||
raw_key = double(:raw_key, uids: [uid])
|
||||
allow(Gitlab::Gpg::CurrentKeyChain).to receive(:fingerprints_from_key).with(public_key).and_return(fingerprints)
|
||||
allow(GPGME::Key).to receive(:find).with(:public, anything).and_return([raw_key])
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::GroupSearchResults do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Highlight do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::HttpIO do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::HTTP do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::I18n do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Identifier do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::ImportSources do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe Gitlab::IncomingEmail do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::InsecureKeyFingerprint do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::IssuableMetadata do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::IssuableSorter do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::IssuablesCountForState do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::JobWaiter do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::JsonLogger do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Kubernetes do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::LanguageDetection do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Lazy do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::VisibilityLevelChecker do
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ describe 'Git HTTP requests' do
|
|||
context "when authentication fails" do
|
||||
context "when the user is IP banned" do
|
||||
before do
|
||||
stub_rack_attack_setting(enabled: true)
|
||||
stub_rack_attack_setting(enabled: true, ip_whitelist: [])
|
||||
end
|
||||
|
||||
it "responds with status 403" do
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ describe 'Rack Attack global throttles' do
|
|||
expect(response).to have_http_status 200
|
||||
end
|
||||
|
||||
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return('1.2.3.4')
|
||||
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4')
|
||||
|
||||
# would be over limit for the same IP
|
||||
get url_that_does_not_require_authentication
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do
|
|||
expect(response).to have_http_status 200
|
||||
end
|
||||
|
||||
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return('1.2.3.4')
|
||||
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4')
|
||||
|
||||
expect_rejection { get(*get_args) }
|
||||
end
|
||||
|
|
@ -194,7 +194,7 @@ shared_examples_for 'rate-limited web authenticated requests' do
|
|||
expect(response).to have_http_status 200
|
||||
end
|
||||
|
||||
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return('1.2.3.4')
|
||||
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4')
|
||||
|
||||
expect_rejection { get url_that_requires_authentication }
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue