make sure the request came from a whitelisted ip, or uses a publically accessible request method
500200
def verify_request_method env
        allowed = ALLOWED_METHODS
        allowed |= ALLOWED_METHODS_PRIVATE if whitelisted?(env)
        if !allowed.include?(env[METHOD])
          raise "Request method #{env[METHOD]} not allowed"
        end
      end
1007281
public OvhWhitelist serviceName_whitelist_ip_GET(String serviceName, String ip) throws IOException {
		String qPath = "/hosting/privateDatabase/{serviceName}/whitelist/{ip}";
		StringBuilder sb = path(qPath, serviceName, ip);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhWhitelist.class);
	}
1170867
def _permission_denied_check(request):
    '''

    '''
    allowed_ips = settings.EUL_INDEXER_ALLOWED_IPS
    if allowed_ips != "ANY" and not request.META['REMOTE_ADDR'] in allowed_ips:
        return True

    return False
832399
def _check_ip_available(ip_addr):
    '''
    
    '''
    for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=True)):
        vm_config = vm_details['config']
        if ip_addr in vm_config['ip_address'] or vm_config['ip_address'] == ip_addr:
            log.debug('IP "%s" is already defined', ip_addr)
            return False

    log.debug('IP \'%s\' is available to be defined', ip_addr)
    return True
1122126
def _waitForIP(cls, instance):
        
        logger.debug('Waiting for ip...')
        while True:
            time.sleep(a_short_time)
            instance.update()
            if instance.ip_address or instance.public_dns_name or instance.private_ip_address:
                logger.debug('...got ip')
                break
1313993
private void checkHttpMethod(R pRequest) {
        if (!restrictor.isHttpMethodAllowed(pRequest.getHttpMethod())) {
            throw new SecurityException("HTTP method " + pRequest.getHttpMethod().getMethod() +
                    " is not allowed according to the installed security policy");
        }
    }
15938
def disassociate_public_ip(self, public_ip_id):
        """"""
        floating_ip = self.client.floating_ips.get(public_ip_id)
        floating_ip = floating_ip.to_dict()
        instance_id = floating_ip.get('instance_id')
        address = floating_ip.get('ip')

        self.client.servers.remove_floating_ip(instance_id, address)

        return True
417236
def build_url_request(self):
        
        # Check if the ip is LAN or WAN
        if net.IPAddress(self.ip).is_private():
            url = "http://{}".format(self.ip)
            self.authentication_type = BboxConstant.AUTHENTICATION_TYPE_LOCAL
        else:
            url = "https://{}:{}".format(self.ip,
                                         BboxConstant.DEFAULT_REMOTE_PORT)
            self.authentication_type = BboxConstant.AUTHENTICATION_TYPE_REMOTE

        if self.api_class is None:
            url = "{}/{}".format(url, self.API_PREFIX)
        else:
            url = "{}/{}/{}".format(url, self.API_PREFIX, self.api_class)

        if self.api_method is None:
            self.url = url
        else:
            self.url = "{}/{}".format(url, self.api_method)
1240791
def ip_verification_required(func):
    

    def wrapper(request, *args, **kwargs):

        slug = kwargs.get('slug', "")
        if not slug:
            return kickoutt_404("Not found.", content_type="application/json")

        try:
            wip = WriteAPIIP.objects.get(slug=slug)
            ip = get_client_ip(request)
            if ip not in wip.allowable_ips() and "0.0.0.0" not in wip.allowable_ips():
                msg = "The IP %s is not authorized to make the API call." % (
                    ip)
                return kickout_401(msg)

        except WriteAPIIP.DoesNotExist:
            return HttpResponse(unauthorized_json_response(),
                                content_type="application/json")

        return func(request, *args, **kwargs)

    return update_wrapper(wrapper, func)
1282302
def endpoint_access(self, method):
        
        if method == 'OPTIONS':
            # The CORS pre-flight checks should not require authentication
            return self.UNAUTHENTICATED_ACCESS
        elif method not in self.METHOD_ACCESS:
            logging.error('Cannot determine access needed for %s method', method)
            raise HTTPError(500, 'Internal Server Error')

        return self.METHOD_ACCESS[method]
406732
def get_server_public_ip(server, cached_rules=nil, cached_nat=nil)
      return nil unless server
      # find the public ip
      nic = get_server_default_nic(server)

      ssh_rule = get_ssh_port_forwarding_rule(server, cached_rules)
      return ssh_rule['ipaddress'] if ssh_rule

      winrm_rule = get_winrm_port_forwarding_rule(server, cached_rules)
      return winrm_rule['ipaddress'] if winrm_rule

      #check for static NAT
      if cached_nat
        ip_addr = cached_nat.find {|v| v['virtualmachineid'] == server['id']}
      else
        ip_addr = list_public_ip_addresses.find {|v| v['virtualmachineid'] == server['id']}
      end
      if ip_addr
        return ip_addr['ipaddress']
      end
      if nic.empty?
        return []
      end
      nic['ipaddress'] || []
    end
444085
def get_public_ip(self, addr_family=None, *args, **kwargs):
        """"""
        return self.get_ip('public', addr_family, *args, **kwargs)
1304355
def _access_rule(method,
                ip=None,
                port=None,
                proto='tcp',
                direction='in',
                port_origin='d',
                ip_origin='d',
                comment=''):
    '''
    
    '''
    if _status_csf():
        if ip is None:
            return {'error': 'You must supply an ip address or CIDR.'}
        if port is None:
            args = _build_args(method, ip, comment)
            return __csf_cmd(args)
        else:
            if method not in ['allow', 'deny']:
                return {'error': 'Only allow and deny rules are allowed when specifying a port.'}
            return _access_rule_with_port(method=method,
                                            ip=ip,
                                            port=port,
                                            proto=proto,
                                            direction=direction,
                                            port_origin=port_origin,
                                            ip_origin=ip_origin,
                                            comment=comment)
1260557
def _make_request(self, conn, method, url, timeout=_Default,
                      **httplib_request_kw):
        
        self.num_requests += 1

        if timeout is _Default:
            timeout = self.timeout

        conn.request(method, url, **httplib_request_kw)
        conn.sock.settimeout(timeout)
        httplib_response = conn.getresponse()

        log.debug("\"%s %s %s\" %s %s" %
                  (method, url,
                   conn._http_vsn_str, # pylint: disable-msg=W0212
                   httplib_response.status, httplib_response.length))

        return httplib_response
367945
def detect(self):
        
        if self.opts_url and self.opts_parser:
            url = self.opts_url
            parser = self.opts_parser
        else:
            url, parser = choice(self.urls)  # noqa: S311
        parser = globals().get("_parser_" + parser)
        theip = _get_ip_from_url(url, parser)
        if theip is None:
            LOG.info("Could not detect IP using webcheck! Offline?")
        self.set_current_value(theip)
        return theip
613921
def _request(self, proxy, timeout):
        
        return request.WPToolsRequest(self.flags['silent'],
                                      self.flags['verbose'],
                                      proxy, timeout)
836333
private function isIpWhitelisted()
    {
        $whitelist = $this->config->get('RateLimitWhitelist', [], true);
        if (in_array($this->ip, $whitelist)) {
            return true;
        }

        return false;
    }