Fix UrlBlocker for Ruby 3.1
https://gitlab.com/gitlab-org/gitlab/-/jobs/3919091814 is failing with:
RSpec::Retry: 2nd try ./spec/lib/gitlab/url_blocker_spec.rb:560
Failures:
1) Gitlab::UrlBlocker#blocked_url? when allow_local_network is false when local domain/IP is allowed with IPs in allowlist behaves like allows local requests does not block urls from private networks
Failure/Error: expect(described_class).not_to be_blocked_url("http://#{ip}", **url_blocker_attributes)
expected `Gitlab::UrlBlocker.blocked_url?("http://[::ffff:ac10:20]", {:allow_local_network=>false, :allow_localhost=>false, :schemes=>["http", "https"]})` to be falsey, got true
Shared Example Group: "allows local requests" called from ./spec/lib/gitlab/url_blocker_spec.rb:653
# ./spec/lib/gitlab/url_blocker_spec.rb:541:in `block (6 levels) in <main>'
# ./spec/lib/gitlab/url_blocker_spec.rb:536:in `each'
# ./spec/lib/gitlab/url_blocker_spec.rb:536:in `block (5 levels) in <main>'
# ./spec/spec_helper.rb:502:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:494:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:490:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:490:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:242:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:62:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (2 levels) in <main>'
2) Gitlab::UrlBlocker#blocked_url? when allow_local_network is false when local domain/IP is allowed with IPs in allowlist behaves like allows local requests allows IPv4 link-local endpoints
Failure/Error: expect(described_class).not_to be_blocked_url('http://169.254.169.254', **url_blocker_attributes)
expected `Gitlab::UrlBlocker.blocked_url?("http://169.254.169.254", {:allow_local_network=>false, :allow_localhost=>false, :schemes=>["http", "https"]})` to be falsey, got true
Shared Example Group: "allows local requests" called from ./spec/lib/gitlab/url_blocker_spec.rb:653
# ./spec/lib/gitlab/url_blocker_spec.rb:556:in `block (5 levels) in <main>'
# ./spec/spec_helper.rb:502:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:494:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:490:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:490:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:242:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:62:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (2 levels) in <main>'
3) Gitlab::UrlBlocker#blocked_url? when allow_local_network is false when local domain/IP is allowed with IPs in allowlist behaves like allows local requests allows IPv6 link-local endpoints
Failure/Error: expect(described_class).not_to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.169.254]', **url_blocker_attributes)
expected `Gitlab::UrlBlocker.blocked_url?("http://[0:0:0:0:0:ffff:169.254.169.254]", {:allow_local_network=>false, :allow_localhost=>false, :schemes=>["http", "https"]})` to be falsey, got true
Shared Example Group: "allows local requests" called from ./spec/lib/gitlab/url_blocker_spec.rb:653
# ./spec/lib/gitlab/url_blocker_spec.rb:561:in `block (5 levels) in <main>'
# ./spec/spec_helper.rb:502:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:494:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:490:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:490:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:242:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:62:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (2 levels) in <main>'
Finished in 3.61 seconds (files took 33.96 seconds to load)
3 examples, 3 failures
Failed examples:
rspec './spec/lib/gitlab/url_blocker_spec.rb[1:2:21:2:5:1:1:1]' # Gitlab::UrlBlocker#blocked_url? when allow_local_network is false when local domain/IP is allowed with IPs in allowlist behaves like allows local requests does not block urls from private networks
rspec './spec/lib/gitlab/url_blocker_spec.rb[1:2:21:2:5:1:1:4]' # Gitlab::UrlBlocker#blocked_url? when allow_local_network is false when local domain/IP is allowed with IPs in allowlist behaves like allows local requests allows IPv4 link-local endpoints
rspec './spec/lib/gitlab/url_blocker_spec.rb[1:2:21:2:5:1:1:5]' # Gitlab::UrlBlocker#blocked_url? when allow_local_network is false when local domain/IP is allowed with IPs in allowlist behaves like allows local requests allows IPv6 link-local endpoints
[TEST PROF INFO] Time spent in factories: 00:00.009 (0.18% of total time)