Check CROS requests
495918
public static function checkCORS()
    {
        Logger::log('Checking CORS');
        $corsEnabled = Config::getParam('cors.enabled');
        $request = Request::getInstance();
        if (NULL !== $corsEnabled) {
            if ($corsEnabled === '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) {
                if (!headers_sent()) {
                    // TODO include this headers in Template class output method
                    header('Access-Control-Allow-Credentials: true');
                    header('Access-Control-Allow-Origin: ' . Request::getInstance()->getServer('HTTP_ORIGIN', '*'));
                    header('Vary: Origin');
                    header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS');
                    header('Access-Control-Allow-Headers: ' . implode(', ', self::getCorsHeaders()));
                }
                if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) {
                    Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG);
                    header('HTTP/1.1 200 OK');
                    exit();
                }
            }
        }
    }
450329
def index(request):
    ""
    
    service_list = Service.objects.all()
    
    event_list = list(Event.objects\
                             .filter(Q(status__gt=0) | Q(date_updated__gte=datetime.datetime.now()-datetime.timedelta(days=1)))\
                             .order_by('-date_created')[0:6])
    
    if event_list:
        latest_event, event_list = event_list[0], event_list[1:]
    else:
        latest_event = None
    
    return respond('overseer/index.html', {
        'service_list': service_list,
        'event_list': event_list,
        'latest_event': latest_event,
    }, request)
1169275
def get_pull_requests(self):
        ""
        g = self.github
        query = {'state': 'all'}
        if self.args.github_token:
            query['access_token'] = g['token']

        def f(pull):
            if self.args.ignore_closed:
                return (pull['state'] == 'opened' or
                        (pull['state'] == 'closed' and pull['merged_at']))
            else:
                return True
        pulls = filter(f,
                       self.get(g['url'] + "/repos/" + g['repo'] + "/pulls",
                                query, self.args.cache))
        return dict([(str(pull['number']), pull) for pull in pulls])
1277285
def verify_request(self, uri, http_method='GET', body=None, headers=None,
                       scopes=None):
        """"""
        request = Request(uri, http_method, body, headers)
        request.token_type = self.find_token_type(request)
        request.scopes = scopes
        token_type_handler = self.tokens.get(request.token_type,
                                             self.default_token_type_handler)
        log.debug('Dispatching token_type %s request to %r.',
                  request.token_type, token_type_handler)
        return token_type_handler.validate_request(request), request
1365600
function (req, res) {
    User.find().exec(function (err, users) {
      if(err) return res.json({ err: err }, 500);
      else res.json(users);
    });
  }
672098
def get_reqs(which="main"):
    """"""
    reqs = []
    for req in all_reqs[which]:
        req_str = req + ">=" + ver_tuple_to_str(min_versions[req])
        if req in version_strictly:
            req_str += ",<" + ver_tuple_to_str(min_versions[req][:-1]) + "." + str(min_versions[req][-1] + 1)
        reqs.append(req_str)
    return reqs
991514
def get_current_status(self):
        """"""
        url = get_url("/remote/status.json")
        params = {"oauth": self._oauth_token, "csrf": self._csrf_token}
        r = self._request(url=url, params=params)
        return r.json()
928223
def __pre_check(self, requestedUrl):
		'''
		
		'''
		components = urllib.parse.urlsplit(requestedUrl)

		netloc_l = components.netloc.lower()
		if netloc_l in Domain_Constants.SUCURI_GARBAGE_SITE_NETLOCS:
			self.__check_suc_cookie(components)
		elif netloc_l in Domain_Constants.CF_GARBAGE_SITE_NETLOCS:
			self.__check_cf_cookie(components)
		elif components.path == '/sucuri_shit_2':
			self.__check_suc_cookie(components)
		elif components.path == '/sucuri_shit_3':
			self.__check_suc_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_2':
			self.__check_cf_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_3':
			self.__check_cf_cookie(components)
711721
def query(conn_type, option, post_data=None):
    '''
    
    '''
    if ticket is None or csrf is None or url is None:
        log.debug('Not authenticated yet, doing that now..')
        _authenticate()

    full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, option)

    log.debug('%s: %s (%s)', conn_type, full_url, post_data)

    httpheaders = {'Accept': 'application/json',
                   'Content-Type': 'application/x-www-form-urlencoded',
                   'User-Agent': 'salt-cloud-proxmox'}

    if conn_type == 'post':
        httpheaders['CSRFPreventionToken'] = csrf
        response = requests.post(full_url, verify=verify_ssl,
                                 data=post_data,
                                 cookies=ticket,
                                 headers=httpheaders)
    elif conn_type == 'put':
        httpheaders['CSRFPreventionToken'] = csrf
        response = requests.put(full_url, verify=verify_ssl,
                                data=post_data,
                                cookies=ticket,
                                headers=httpheaders)
    elif conn_type == 'delete':
        httpheaders['CSRFPreventionToken'] = csrf
        response = requests.delete(full_url, verify=verify_ssl,
                                   data=post_data,
                                   cookies=ticket,
                                   headers=httpheaders)
    elif conn_type == 'get':
        response = requests.get(full_url, verify=verify_ssl,
                                cookies=ticket)

    response.raise_for_status()

    try:
        returned_data = response.json()
        if 'data' not in returned_data:
            raise SaltCloudExecutionFailure
        return returned_data['data']
    except Exception:
        log.error('Error in trying to process JSON')
        log.error(response)
1210774
def _check_version(self, request):
        """"""
        version = self._get_version(request)
        if version and version != self.version:
            raise Error('OAuth version %s not supported.' % str(version))
171019
def CheckRequestsForCompletion(self, requests):
    """"""

    subjects = [r.session_id.Add("state") for r in requests]

    statuses_found = {}

    for subject, result in self.MultiResolvePrefix(subjects,
                                                   self.FLOW_STATUS_PREFIX):
      for predicate, _, _ in result:
        request_nr = int(predicate.split(":")[-1], 16)
        statuses_found.setdefault(subject, set()).add(request_nr)

    status_available = set()
    for r in requests:
      if r.request_id in statuses_found.get(r.session_id.Add("state"), set()):
        status_available.add(r)

    return status_available
1289882
private void checkHttps(AmazonWebServiceRequest req) {
        if (req instanceof SSECustomerKeyProvider) {
            SSECustomerKeyProvider p = (SSECustomerKeyProvider) req;
            if (p.getSSECustomerKey() != null)
                assertHttps();
        } else if (req instanceof CopyObjectRequest) {
            CopyObjectRequest cor = (CopyObjectRequest) req;
            if (cor.getSourceSSECustomerKey() != null
            ||  cor.getDestinationSSECustomerKey() != null) {
                assertHttps();
            }
        } else if (req instanceof CopyPartRequest) {
            CopyPartRequest cpr = (CopyPartRequest) req;
            if (cpr.getSourceSSECustomerKey() != null
            ||  cpr.getDestinationSSECustomerKey() != null) {
                assertHttps();
            }
        }

        if (req instanceof SSEAwsKeyManagementParamsProvider) {
            SSEAwsKeyManagementParamsProvider p = (SSEAwsKeyManagementParamsProvider) req;
            if (p.getSSEAwsKeyManagementParams() != null)
                assertHttps();
        }
    }
737934
def check_key(request):
    '''
        
    '''
    api_objs = list(Api.objects.filter(name=request.POST['api']))
    if not api_objs:
        return HttpResponseBadRequest('Must specify valid API')

    # check the signature
    if get_signature(request.POST, api_objs[0].signing_key) != request.POST['signature']:
        return HttpResponseBadRequest('bad signature')

    get_object_or_404(Key, key=request.POST['key'], status='A')

    return HttpResponse('OK')
286349
public function checkRegistryRequestsAnswers()
    {
        if (! $this->db instanceof \Zend_Db_Adapter_Abstract) {
            return false;
        }

        $select = $this->db->select();
        $select->from(['nw'=> 'gems__tokens'], [
            'gtrp_id_token_new' => 'gto_id_token',
            'gtrp_created' => 'gto_created',
            'gtrp_created_by' => 'gto_created_by',
            ])->joinInner(
                    ['pr' => 'gems__tokens'],
                    "nw.gto_id_respondent_track = pr.gto_id_respondent_track AND
                     nw.gto_id_round            = pr.gto_id_round AND
                     nw.gto_round_order         = pr.gto_round_order AND
                     nw.gto_created             > pr.gto_created
                     ",
                    ['gtrp_id_token_old' => 'gto_id_token',]
                    )
                ->where('nw.gto_id_token NOT IN (SELECT gtrp_id_token_new FROM gems__token_replacements)')
                ->order('nw.gto_id_token')
                ->order('pr.gto_created');

        $this->_stmt = $this->db->query($select);

        return parent::checkRegistryRequestsAnswers();
    }
111857
def requests_list(self, status=None, **kwargs):
        ""
        api_path = "/api/v2/requests.json"
        api_query = {}
        if "query" in kwargs.keys():
            api_query.update(kwargs["query"])
            del kwargs["query"]
        if status:
            api_query.update({
                "status": status,
            })
        return self.call(api_path, query=api_query, **kwargs)
298254
def index(cls):
        
        res = requests.get(cls.URL, headers=HEADERS, verify=False)
        res.raise_for_status()
        return res.json()
386798
def list_my_requests_view(request):
    '''
    
    '''
    userProfile = UserProfile.objects.get(user=request.user)
    requests = Request.objects.filter(owner=userProfile)
    return render_to_response('list_requests.html', {
        'page_name': "Your Requests",
        'requests': requests,
        }, context_instance=RequestContext(request))