summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-08-13 12:07:23 +0000
committerJose Vargas <jvargas@gitlab.com>2018-08-24 15:07:17 -0500
commitda80e899ec5a2a9b07b46162cbdb693ef4a13d59 (patch)
tree279bc6a8e8a8494525e38cf4e9b1a52416245a83 /spec
parent4fe832271e99f2d56ddaf649ea53bed614019830 (diff)
downloadgitlab-ce-da80e899ec5a2a9b07b46162cbdb693ef4a13d59.tar.gz
Merge branch 'sh-block-link-local-master-11-0-port' into 'security-11-0'
Block link-local addresses in URLBlocker (11.0 port) See merge request gitlab/gitlabhq!2462
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/url_blocker_spec.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb
index 6f5f9938eca..624e2add860 100644
--- a/spec/lib/gitlab/url_blocker_spec.rb
+++ b/spec/lib/gitlab/url_blocker_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
require 'spec_helper'
describe Gitlab::UrlBlocker do
@@ -82,6 +83,17 @@ describe Gitlab::UrlBlocker do
expect(described_class).not_to be_blocked_url("http://#{ip}")
end
end
+
+ it 'allows IPv4 link-local endpoints' do
+ expect(described_class).not_to be_blocked_url('http://169.254.169.254')
+ expect(described_class).not_to be_blocked_url('http://169.254.168.100')
+ end
+
+ # This is blocked due to the hostname check: https://gitlab.com/gitlab-org/gitlab-ce/issues/50227
+ it 'blocks IPv6 link-local endpoints' do
+ expect(described_class).to be_blocked_url('http://[::ffff:169.254.169.254]')
+ expect(described_class).to be_blocked_url('http://[::ffff:169.254.168.100]')
+ end
end
context 'false' do
@@ -96,10 +108,21 @@ describe Gitlab::UrlBlocker do
expect(described_class).to be_blocked_url("http://#{ip}", allow_local_network: false)
end
end
+
+ it 'blocks IPv4 link-local endpoints' do
+ expect(described_class).to be_blocked_url('http://169.254.169.254', allow_local_network: false)
+ expect(described_class).to be_blocked_url('http://169.254.168.100', allow_local_network: false)
+ end
+
+ it 'blocks IPv6 link-local endpoints' do
+ expect(described_class).to be_blocked_url('http://[::ffff:169.254.169.254]', allow_local_network: false)
+ expect(described_class).to be_blocked_url('http://[::ffff:169.254.168.100]', allow_local_network: false)
+ expect(described_class).to be_blocked_url('http://[FE80::C800:EFF:FE74:8]', allow_local_network: false)
+ end
end
def stub_domain_resolv(domain, ip)
- allow(Addrinfo).to receive(:getaddrinfo).with(domain, any_args).and_return([double(ip_address: ip, ipv4_private?: true)])
+ allow(Addrinfo).to receive(:getaddrinfo).with(domain, any_args).and_return([double(ip_address: ip, ipv4_private?: true, ipv6_link_local?: false)])
end
def unstub_domain_resolv