Find all route functions and taint all of their arguments.

        Yields:
            CFG of each route function, with args marked as tainted.
772244
def find_route_functions_taint_args(self):
        
        for definition in _get_func_nodes():
            if self.is_route_function(definition.node):
                yield self.get_func_cfg_with_tainted_args(definition)
272870
function collectExtraArgs(argv) {
    const parsed = parseArgv(argv, {
      configuration: {
        'boolean-negation': false,
        'camel-case-expansion': false,
        'dot-notation': false,
        'parse-numbers': false,
        'duplicate-arguments-array': false
      }
    });

    const passthrough = _.chain(parsed)
      .omitBy((_value, key) => blacklistedArgs.has(key))
      .entries()
      .map(([key, value]) => {
        return value === true ? `--${key}` : `--${key} ${value}`;
      })
      .concat(parsed['_'])
      .value();

    return passthrough;
  }
113555
def _get_arg_names(func):
    '''  '''
    args, varargs, keywords, defaults = inspect.getargspec(func)
    return(tuple(args))
417245
def wrmap(func, iterable, *args):
    ''
    for it in iterable:
        try:
            yield func(it, *args)
        except Exception as e:
            pass
857898
def all_solidity_variables_used_as_args(self):
        
        if self._all_solidity_variables_used_as_args is None:
            self._all_solidity_variables_used_as_args = self._explore_functions(
                lambda x: self._explore_func_nodes(x, self._solidity_variable_in_internal_calls))
        return self._all_solidity_variables_used_as_args
363353
def clean(self, argslist):
        """"""
        result = []
        for arg in argslist:
            if type(arg) == type([]):
                if len(result) > 0:
                    result[-1] = result[-1] + "(*{})".format(len(self.clean(arg)))
                elif "/" not in arg[0]:
                    msg.warn("argument to function call unrecognized. {}".format(arg))
            else:
                cleaner = re.sub("[:,]+", "", arg).strip()
                if len(cleaner) > 0:
                    result.append(cleaner)
        
        return result
182471
def get_functarguments(func):
    
    argspec = inspect.getargspec(func)
    if argspec.defaults is not None:
        args = argspec.args[:-len(argspec.defaults)]
        kwargs = dict(
            zip(argspec.args[-len(argspec.defaults):], argspec.defaults))
    else:
        args = argspec.args
        kwargs = {}
    if args and args[0] == 'self':
        args.pop(0)
    func.__named__ = []
    arguments = []
    shared = get_shared(func)
    for arg in args:
        if has_shared(arg, shared) is not False:
            continue
        if has_argument(arg, func.__cls__) is not False:
            continue
        arguments.append(([arg], {}, ))
        func.__named__.append(arg)
    for key, val in kwargs.items():
        if has_shared(key, shared) is not False:
            continue
        if has_argument(key, func.__cls__) is not False:
            continue
        if isinstance(val, dict):
            flags = [val.pop('lflag', '--%s' % key)]
            short = val.pop('flag', None)
            dest = val.get('dest', key).replace('-', '_')
            if short:
                flags.insert(0, short)
        else:
            flags = ['--%s' % key]
            val = dict(default=val)
            dest = key.replace('-', '_')
        func.__named__.append(dest)
        arguments.append((flags, val, ))
    return arguments
726262
def construct_routes(self):
        
        modules = self.evernode_app.get_modules()
        for module_name in modules:
            with self.app.app_context():
                module = importlib.import_module(
                    'modules.%s.routes' % (module_name))
                for route in module.routes:
                    self.routes.append(self.make_route(route))
        if self.app.config['DEBUG']:
            print('--- Loaded Modules ---')
            print("Loaded Modules: " + str(modules))
296284
def _visit_handlers(handlers, visitor, prefix, suffixes):
    

    results = []
    for handler in handlers:
        for suffix in suffixes:
            func = getattr(handler, '{}_{}'.format(prefix, suffix).lower(), None)
            if func:
                results.append(visitor(suffix, func))

    return results
369261
def parse_route(cls, template):
        
        regex = ''
        last_pos = 0

        for match in cls.ROUTES_RE.finditer(template):
            regex += re.escape(template[last_pos:match.start()])
            var_name = match.group(1)
            expr = match.group(2) or '[^/]+'
            expr = '(?P<%s>%s)' % (var_name, expr)
            regex += expr
            last_pos = match.end()

        regex += re.escape(template[last_pos:])
        regex = '^%s$' % regex

        return re.compile(regex)
442585
def _parse_decorated_functions(self, code):
        """"""
        matches = re.finditer(r"""
                # @rest decorators
                (?P<decorators>
                    (?:@rest\(.+?\)\n)+  # one or more @rest decorators inside
                )
                # docstring delimited by 3 double quotes
                .+?"{3}(?P<docstring>.+?)"{3}
                """, code, re.VERBOSE | re.DOTALL)

        for function_match in matches:
            m_dict = function_match.groupdict()
            self._parse_docstring(m_dict['docstring'])
            self._add_function_paths(m_dict['decorators'])
121130
def functions(self):
        
        out = {}
        for key in self._func_names:
            out[key[len(self._prefix):]] = getattr(self, key)
        return out
480682
def _get_args(self):
        
        if not hasattr(self, '_args_evaled'):
            # cache the args in case handler is re-invoked due to flags change
            self._args_evaled = list(chain.from_iterable(self._args))
        return self._args_evaled
341425
def _get_default_route_args(
            self,
            namespace,  # pylint: disable=unused-argument
            route,
            tag=False):
        """"""
        data_type, _ = unwrap_nullable(route.arg_data_type)
        if is_struct_type(data_type):
            arg_list = []
            for field in data_type.all_fields:
                if not field.has_default and not is_nullable_type(
                        field.data_type):
                    arg_list.append((fmt_var(field.name), fmt_type(
                        field.data_type, tag=tag)))

            doc_list = ([(fmt_var(f.name), self.process_doc(f.doc, self._docf))
                         for f in data_type.fields
                         if f.doc and not f.has_default and
                         not is_nullable_type(f.data_type)])
        else:
            arg_list = []
            doc_list = []

        return arg_list, doc_list
1339755
def route(route_str):  # decorator param
    

    def ilog(elapsed):
        # statistic
        last_stat = _routes_stat.get(route_str, {"count": 0, "min": sys.maxint, "max": 0, "avg": 0})
        last_count = last_stat["count"]
        _routes_stat[route_str] = {
            "count": last_count + 1,
            "min": min(elapsed, last_stat["min"]),
            "max": max(elapsed, last_stat["max"]),
            "avg": (last_count * last_stat["avg"] + elapsed) / (last_count + 1)
        }
        # log.debug('Route Time: {0} took {1} ms'.format(route_str, elapsed))

    def wrapper(f):  # decorated function
        @wraps(f)
        def wrapped_func(*args, **kwargs):  # params of function
            self = args[0]
            method, url = route_str.split(" ")

            def defaults_dict():
                f_args, varargs, keywords, defaults = inspect.getargspec(f)
                defaults = defaults or []
                return dict(zip(f_args[-len(defaults):], defaults))

            defs = defaults_dict()

            route_args = dict(defs.items() + kwargs.items())

            def get_destination_url():
                try:
                    return url.format(**route_args)
                except KeyError as e:
                    # KeyError in format have a message with key
                    raise AttributeError("Define {0} as named argument for route.".format(e))

            destination_url = self.base_url + get_destination_url()
            f(*args, **kwargs)  # generally this is "pass"

            bypass_args = dict([
                                   (param, route_args[param]) for param in
                                   ["data", "json", "cookies", "auth", "files", "content_type", "params"] if
                                   param in route_args
                                   ])

            # add json content type for:
            # - unless files are sent
            # - private that ends with .json
            # - all public api with POST/PUT method, meaning have basic auth
            # - json parameter is present
            if "files" not in bypass_args and (destination_url.endswith('.json') or "json" in route_args or (
                            "auth" in bypass_args and method in ["POST", "PUT"])):
                bypass_args['headers'] = {'Content-Type': 'application/json'}

            if "content_type" in bypass_args and bypass_args['content_type'] == "yaml":
                del bypass_args["content_type"]
                bypass_args['headers'] = {'Content-Type': 'application/x-yaml'}

            start = time.time()
            try:
                response = self._session.request(method, destination_url, verify=self.verify_ssl, **bypass_args)
            except requests.ConnectionError:
                log.info('ConnectionError caught. Trying again: \n %s:%s ' % (method, destination_url))
                import traceback
                def log_exception(exc_class, exc, tb):
                    log.info('Got exception: %s' % exc)
                    log.info('Class: %s' % exc_class)
                    log.info('Trace: %s' % traceback.format_tb(tb))
                    log.error('Got exception while executing: %s' % exc)

                log_exception(*sys.exc_info())
                time.sleep(2)
                response = self._session.request(method, destination_url, verify=self.verify_ssl, **bypass_args)

            end = time.time()
            elapsed = int((end - start) * 1000.0)
            ilog(elapsed)

            if self.verify_codes:
                if response.status_code is not 200:
                    msg = "Route {0} {1} returned code={2} and error: {3}".format(method,
                                                                                  get_destination_url(),
                                                                                  response.status_code,
                                                                                  response.text)
                    if response.status_code in api_http_code_errors.keys():
                        raise api_http_code_errors[response.status_code](msg)
                    else:
                        log.debug(response.text)
                        log.debug(response.request.body)
                        raise ApiError(msg)
            return response

        return wrapped_func

    return wrapper
433218
def _apply_args_to_func(global_args, func):
    
    global_args = vars(global_args)
    local_args = dict()
    for argument in inspect.getargspec(func).args:
        local_args[argument] = global_args[argument]
    return func(**local_args)
1126304
def get_args(self, func):
        
        def reverse(iterable):
            if iterable:
                iterable = list(iterable)
                while len(iterable):
                    yield iterable.pop()

        args, varargs, varkw, defaults = inspect.getargspec(func)
        result = {}
        for default in reverse(defaults):
            result[args.pop()] = default

        for arg in reverse(args):
            if arg == 'self':
                continue
            result[arg] = None

        return result