lib/gitlab/url_blocker.rb
# Validates the given url according to the constraints specified by arguments.
#
# ports - Raises error if the given URL port does is not between given ports.
# allow_localhost - Raises error if URL resolves to a localhost IP address and argument is false.
# allow_local_network - Raises error if URL resolves to a link-local address and argument is false.
# ascii_only - Raises error if URL has unicode characters and argument is true.
# enforce_user - Raises error if URL user doesn't start with alphanumeric characters and argument is true.
# enforce_sanitization - Raises error if URL includes any HTML/CSS/JS tags and argument is true.
#
# Returns an array with [<uri>, <original-hostname>].
# rubocop:disable Metrics/ParameterLists
Validates the given url according to the constraints specified by arguments.
ports - Raises error if the given URL port does is not between given ports.
allow_localhost - Raises error if URL resolves to a localhost IP address and argument is false.
allow_local_network - Raises error if URL resolves to a link-local address and argument is false.
ascii_only - Raises error if URL has unicode characters and argument is true.
enforce_user - Raises error if URL user doesn't start with alphanumeric characters and argument is true.
enforce_sanitization - Raises error if URL includes any HTML/CSS/JS tags and argument is true.

Returns an array with [, ].
Validates the given url according to the constraints specified by arguments . ports - Raises error if the given URL port does is not between given ports . allow_localhost - Raises error if URL resolves to a localhost IP address and argument is false . allow_local_network - Raises error if URL resolves to a link - local address and argument is false . ascii_only - Raises error if URL has unicode characters and argument is true . enforce_user - Raises error if URL user doesn ' t start with alphanumeric characters and argument is true . enforce_sanitization - Raises error if URL includes any HTML / CSS / JS tags and argument is true . Returns an array with [ ] .
def validate_link_local(addrs_info)
        netmask = IPAddr.new('169.254.0.0/16')
        return unless addrs_info.any? { |addr| addr.ipv6_linklocal? || netmask.include?(addr.ip_address) }
        raise BlockedUrlError, "Requests to the link local network are not allowed"
      end
def validate_link_local ( addrs_info ) netmask = IPAddr . new ( '169.254.0.0/16' ) return unless addrs_info . any? { | addr | addr . ipv6_linklocal? || netmask . include? ( addr . ip_address ) } raise BlockedUrlError , "Requests to the link local network are not allowed" end
Validates the given url according to the constraints specified by arguments.
Validates the given url according to the constraints specified by arguments .
addrs_info
<not_specific>