monkey patch for express' own csrf method, so we can ignore specific url patterns
969029
function (options) {
    var ignore = options.ignore || [],
        csrf = csurf(options),
        always = {OPTIONS: 1, GET: 1, HEAD: 1};

    return function (req, res, next) {
      if (always[req.method]) {
        return csrf(req, res, next);
      } else {
        var url = parse(req.url);
        var skipCSRF = false;
        ignore.forEach(function(matcher) {
          if (typeof matcher === 'string') {
            if (matcher === url.pathname) {
              skipCSRF = true;
            }
          } else {
            // regular expression matcher
            if (url.pathname.match(matcher)) {
              skipCSRF = true;
            }
          }
        });

        if (skipCSRF) {
          next();
        } else {
          return csrf(req, res, next);
        }
      }
    };
  }
58735
function checkPostOrPutOrPatchRequest(req, res, cb) {
            if (req.body) {
                for(var i in req.body) {
                    for(var j in _patternSql){
                        if (_patternSql[j].test(req.body[i]) && _blocker.blockHost) {
                            _config.attack.handle(req, res);
                            cb = undefined;
                            break;
                        }
                    }
                    if(!cb){
                        break;
                    }
                }
            }
            if (cb) {
                cb();
            }
        }
272142
function patchMakeErrFromCode() {
  const func = errors.makeErrFromCode;
  function makeErrFromCodeHook() {
    const err = func.apply(null, arguments);
    patchErrorBody(err, {});
    return err;
  }
  errors.makeErrFromCode = makeErrFromCodeHook;

  // Deprecated.
  // See https://github.com/restify/errors/blob/master/lib/index.js#L126
  errors.codeToHttpError = makeErrFromCodeHook;
}
360361
function securityAssert(ctx) {
      // all disabled. don't need check
      if (!csrfEnable && !validateReferrer) return;

      // pass referrer check
      const referrer = ctx.get('referrer');
      if (validateReferrer && validateReferrer(referrer)) return;
      if (csrfEnable && validateCsrf(ctx)) return;

      const err = new Error('jsonp request security validate failed');
      err.referrer = referrer;
      err.status = 403;
      throw err;
    }
167848
def compress_monkey_patch():
    
    from compressor.templatetags import compress as compress_tags
    from compressor import base as compress_base

    compress_base.Compressor.filter_input = filter_input
    compress_base.Compressor.output = output
    compress_base.Compressor.hunks = hunks
    compress_base.Compressor.precompile = precompile

    compress_tags.CompressorMixin.render_compressed = render_compressed

    from django_pyscss import compressor as pyscss_compressor

    pyscss_compressor.DjangoScssFilter.input = input
377763
function presignRequest (presignUrl, token) {
  return new Promise((resolve, reject) => {
    request
      .post(presignUrl)
      .set({
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'X-CSRF-Token': token
      })
      .end((err, res) => {
        // throw a custom error message
        if (err) return reject(customError('presignRequest', err))
        resolve(res)
      })
  })
}
247575
async function( req, res, next ) {
    try { 
      var csrfToken = 'default'
      if ( req.cookies && req.cookies[ 'pong-security' ] ) {
        var token = req.cookies[ 'pong-security' ]
        if ( gui.getCsrfTokenForUser ) {
          csrfToken = await gui.getCsrfTokenForUser( token )
        } else if ( gui.userTokens[ token ] && gui.userTokens[ token ].csrfToken ) {
          csrfToken = gui.userTokens[ token ].csrfToken
        }
      }
    } catch ( exc ) { log.warn('easy-web-app CSRF token, exc') }
    res.header( 'X-Protect', csrfToken );
    next();
  }
456347
function(router, target) {
    // By default, just patch the router's own methods.
    // If a target is given, then patch the router to call the target's methods
    target = target || router;

    // get(setting), which is different than get(path, fn)
    var get = router.get;

    // Wrap all of these methods to convert Swagger-style paths to Express-style paths
    var fns = {};
    ['use', 'route', 'all'].concat(swaggerMethods).forEach(function(method) {
      fns[method] = target[method];
      router[method] = function(path) {
        var args = _.drop(arguments, 0);

        // Special-case for `app.get(setting)`
        if (args.length === 1 && method === 'get') {
          return get.call(router, path);
        }

        // Convert Swagger-style path to Express-style path
        if (_.isString(path)) {
          args[0] = path.replace(util.swaggerParamRegExp, ':$1');
        }

        // Pass-through to the corresponding Express method
        var ret = fns[method].apply(target, args);

        if (router.__sortMiddleWare) {
          router.__sortMiddleWare();
        }

        return ret;
      };
    });
  }
1307226
function handler(req, res) {

        var path = cog.getConfig('options.api_data');
        var urlRegex = cog.getConfig('options.api_url_regex');
        var url = req.url.replace(/^\//, '').replace(/\/$/, '');

        console.log(req.method + ' ' + req.url);

        // Find the JSON-data file and serve it, if URL points to the API.
        if (path && urlRegex && urlRegex.test(url)) {
            var file = path + '/' + url + '.json';
            if (grunt.file.exists(file)) {
                res.end(grunt.file.read(file));
                return;
            }
        }

        if (req.method == 'POST') {
            // TODO: This needs fixing, since it throws an error.
            res.end('{"message": "OK"}');
        }

    }
614266
function applyAxiosDefaults(authenticatedAPIClient) {
  /* eslint-disable no-param-reassign */
  authenticatedAPIClient.defaults.withCredentials = true;
  authenticatedAPIClient.defaults.headers.common['USE-JWT-COOKIE'] = true;
  /* eslint-enable no-param-reassign */
}
371614
def chomp_protocol(url):
        
        if '+' in url:
            url = url.split('+', 1)[1]
        scheme, netloc, path, query, frag = urlparse.urlsplit(url)
        rev = None
        if '@' in path:
            path, rev = path.rsplit('@', 1)
        url = urlparse.urlunsplit((scheme, netloc, path, query, ''))
        if url.startswith('ssh://git@github.com/'):
            url = url.replace('ssh://', 'git+ssh://')
        elif '://' not in url:
            assert 'file:' not in url
            url = url.replace('git+', 'git+ssh://')
            url = url.replace('ssh://', '')
        return url
175430
function fixRelativeUrls(cssText, href) {
	var base = resolveRelativeUrl(href, document.baseURI);
	return cssText.replace(URL_VALUE_REGEXP, function(match, quote, url1, url2) {
		var url = url1 || url2;
		if (!url) {
			return match;
		}
		return 'url(' + (quote || '"') + resolveRelativeUrl(url, base) + (quote || '"') + ')';
	});
}
596431
def patch(self, url, headers=None, body=None, kwargs=None):
        
        return self._request(
            method='patch',
            url=url,
            headers=headers,
            body=body,
            kwargs=kwargs
        )
866283
def js_reverse_inline(context):
    
    if 'request' in context:
        default_urlresolver = get_resolver(getattr(context['request'], 'urlconf', None))
    else:
        default_urlresolver = get_resolver(None)
    return mark_safe(generate_js(default_urlresolver))
421664
function intercept(req, res, next) {
    if (
         !route.test(req.url)           // Incorrect URL.
      || !req.headers.authorization     // Missing authorization.
      || options.method !== req.method  // Invalid method.
    ) return next();

    //
    // Handle unauthorized requests.
    //
    if (authorization !== req.headers.authorization) {
      res.statusCode = 401;
      res.setHeader('Content-Type', 'application/json');

      return res.end(JSON.stringify({
        ok: false,
        reason: [
          'I am programmed to protect, and sacrifice if necessary.',
          'Feel the power of my lazers! Pew pew!'
        ].join(' ')
      }));
    }

    var primus = this
      , buff = '';

    if (typeof options.middleware === 'function') {
      options.middleware(primus, parse, req, res, next);
    } else {
      //
      // Receive the data from the socket. The `setEncoding` ensures that Unicode
      // chars are correctly buffered and parsed before the `data` event is
      // emitted.
      //
      req.setEncoding('utf8');
      req.on('data', function data(chunk) {
        buff += chunk;
      }).once('end', function end() {
        parse(primus, buff, res);
      });
    }
  }
529614
function(number, params, headers, callback) {
        var url;
        url = this.client.url() + ("posts/" + (number || ''));
        return this.client.patch(url, params, headers, callback);
      }
667432
def csrf_protect(f):
    """"""

    @wraps(f)
    def wrapper(*args, **kwargs):
        token = session.get("csrf_token", None)
        if token is None or token != request.environ.get("HTTP_X_CSRFTOKEN"):
            logger.warning("Received invalid csrf token. Aborting")
            abort(403)
        # call original request handler
        return f(*args, **kwargs)

    return wrapper