def exist_sen_func_full_match(class_func, function_real_list): api_positions = set() for function_real in function_real_list: if class_func[0] == function_real['class'] and class_func[ 1] == function_real['method']: if len(class_func) == 2: # 无参数的情况 api_positions = add_api_position_single_api( api_positions, function_real['exception_positions']) else: match_args = class_func[2] for single_call in function_real['call_list']: args_real = single_call['args'] flag = True for match_positon in match_args.keys(): try: if args_real[int(match_positon)] != match_args.get( match_positon): flag = False break except IndexError as err: flag = False break if flag: api_positions = add_api_position_single_api( api_positions, single_call['exception_positions']) return list(api_positions)
def has_call_args_contain(function_real_list, call_info): api_positions = set() for function_real in function_real_list: if function_real['class'] == call_info['class'] and function_real[ 'method'] == call_info['method']: try: match_args = call_info['args'] except KeyError as err: api_positions = add_api_position_single_api( api_positions, function_real['exception_positions']) continue for single_call in function_real['call_list']: args_real = single_call['args'] flag = True for match_position in match_args.keys(): try: args_real[int(match_position)].index( match_args.get(match_position)) except ValueError as err: flag = False break if flag: api_positions = add_api_position_single_api( api_positions, single_call['exception_positions']) return list(api_positions)
def has_call_exist_args(function_real_list, call_info): api_positions = set() for function_real in function_real_list: if function_real['class'] == call_info['class'] and function_real[ 'method'] == call_info['method']: for single_call in function_real['call_list']: if single_call['args']: api_positions = add_api_position_single_api( api_positions, single_call['exception_positions']) return list(api_positions)
def exist_sen_func_uri_contain(class_func, function_real_list): api_positions = set() for function_real in function_real_list: if class_func[0] == function_real['class'] and class_func[ 1] == function_real['method']: match_args = class_func[2] for single_call in function_real['call_list']: args_real = single_call['args'] flag = True for match_positon in match_args.keys(): if match_args.get(match_positon) not in args_real[int( match_positon)]['uriString']: flag = False break if flag: api_positions = add_api_position_single_api( api_positions, single_call['exception_positions']) return list(api_positions)
def has_call_first_args_same(function_real_list, call_info): api_positions = set() for function_real in function_real_list: if function_real['class'] == call_info['class'] and function_real[ 'method'] == call_info['method']: if len(function_real['call_list']) == 1: continue flag = True first_args = function_real['call_list'][0]['args'][0] for single_call in function_real['call_list'][1:]: args_real = single_call['args'] if args_real[0] != first_args: flag = False break if flag: api_positions = add_api_position_single_api( api_positions, function_real['exception_positions']) return list(api_positions)