diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-29 09:08:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-29 09:08:45 +0300 |
commit | 4bc1e04a7adb4b183c713e5faff726579e909d1c (patch) | |
tree | 1a77e5900059f9c89f74741fa7f2da151b1b58cc /lib/gitlab/url_blockers | |
parent | 06253b6c70d1770d842edb884dfecac20bcfec6c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/url_blockers')
-rw-r--r-- | lib/gitlab/url_blockers/domain_allowlist_entry.rb (renamed from lib/gitlab/url_blockers/domain_whitelist_entry.rb) | 2 | ||||
-rw-r--r-- | lib/gitlab/url_blockers/ip_allowlist_entry.rb (renamed from lib/gitlab/url_blockers/ip_whitelist_entry.rb) | 2 | ||||
-rw-r--r-- | lib/gitlab/url_blockers/url_allowlist.rb (renamed from lib/gitlab/url_blockers/url_whitelist.rb) | 24 |
3 files changed, 13 insertions, 15 deletions
diff --git a/lib/gitlab/url_blockers/domain_whitelist_entry.rb b/lib/gitlab/url_blockers/domain_allowlist_entry.rb index b94e8ee3f69..b65bd9e1a92 100644 --- a/lib/gitlab/url_blockers/domain_whitelist_entry.rb +++ b/lib/gitlab/url_blockers/domain_allowlist_entry.rb @@ -2,7 +2,7 @@ module Gitlab module UrlBlockers - class DomainWhitelistEntry + class DomainAllowlistEntry attr_reader :domain, :port def initialize(domain, port: nil) diff --git a/lib/gitlab/url_blockers/ip_whitelist_entry.rb b/lib/gitlab/url_blockers/ip_allowlist_entry.rb index 88c76574d3d..b293afe166c 100644 --- a/lib/gitlab/url_blockers/ip_whitelist_entry.rb +++ b/lib/gitlab/url_blockers/ip_allowlist_entry.rb @@ -2,7 +2,7 @@ module Gitlab module UrlBlockers - class IpWhitelistEntry + class IpAllowlistEntry attr_reader :ip, :port # Argument ip should be an IPAddr object diff --git a/lib/gitlab/url_blockers/url_whitelist.rb b/lib/gitlab/url_blockers/url_allowlist.rb index 59f74dde7fc..60238bea75a 100644 --- a/lib/gitlab/url_blockers/url_whitelist.rb +++ b/lib/gitlab/url_blockers/url_allowlist.rb @@ -2,43 +2,41 @@ module Gitlab module UrlBlockers - class UrlWhitelist + class UrlAllowlist class << self - def ip_whitelisted?(ip_string, port: nil) + def ip_allowed?(ip_string, port: nil) return false if ip_string.blank? - ip_whitelist, _ = outbound_local_requests_whitelist_arrays + ip_allowlist, _ = outbound_local_requests_allowlist_arrays ip_obj = Gitlab::Utils.string_to_ip_object(ip_string) - ip_whitelist.any? do |ip_whitelist_entry| - ip_whitelist_entry.match?(ip_obj, port) + ip_allowlist.any? do |ip_allowlist_entry| + ip_allowlist_entry.match?(ip_obj, port) end end - def domain_whitelisted?(domain_string, port: nil) + def domain_allowed?(domain_string, port: nil) return false if domain_string.blank? - _, domain_whitelist = outbound_local_requests_whitelist_arrays + _, domain_allowlist = outbound_local_requests_allowlist_arrays - domain_whitelist.any? do |domain_whitelist_entry| - domain_whitelist_entry.match?(domain_string, port) + domain_allowlist.any? do |domain_allowlist_entry| + domain_allowlist_entry.match?(domain_string, port) end end private - attr_reader :ip_whitelist, :domain_whitelist - # We cannot use Gitlab::CurrentSettings as ApplicationSetting itself # calls this class. This ends up in a cycle where # Gitlab::CurrentSettings creates an ApplicationSetting which then # calls this method. # # See https://gitlab.com/gitlab-org/gitlab/issues/9833 - def outbound_local_requests_whitelist_arrays + def outbound_local_requests_allowlist_arrays return [[], []] unless ApplicationSetting.current - ApplicationSetting.current.outbound_local_requests_whitelist_arrays + ApplicationSetting.current.outbound_local_requests_allowlist_arrays end end end |