def populate_db(db_connection, list): db.create_table(db_connection) # convert list elements to tuple rows = [(elm, ) for elm in list] db.insert_rows(db_connection, rows)
def interactions(): # Selects the dataset you want to seee dataset = request.form.get('dataset') if (dataset == "Actual"): filter_method_calls.filter("new_trial.txt") else: filter_method_calls.filter("callblocker_new_trial.txt") # filter_method_calls.filter("roughrough_new_trial.txt") # filter_method_calls.filter("r4.txt") file_name = "roughrough_only_method_calls.txt" if (dataset == "Actual"): file_name = 'only_method_calls.txt' else: file_name = 'callblocker_only_method_calls.txt' thread_id = [] if (len(file_name) > 0): if (dataset == "Actual"): run_remove_non_start.remove_non_start('only_method_calls.txt') else: run_remove_non_start.remove_non_start( 'callblocker_only_method_calls.txt') # run_remove_non_start.remove_non_start('roughrough_only_method_calls.txt') run_remove_non_start.removeAPI('hello.txt') data = filter_method_calls.parse() database.create_database() database.insert_rows(data) after_insertion_data = database.select_all() # Get all the methods in the log without init all_methods = database.get_all_methods() #Get the security calls in the log full_lines, only_methods, counts_interesting_methods = security_calls.get_all_common_security_methods( ) counts = [] a = zip(counts_interesting_methods, only_methods) a = sorted(a, key=lambda x: x[0]) a.reverse() b = list(zip(*a)) interesting_security_methods = [] for i in range(0, len(only_methods)): temp = b[1][i] + ' (' + str(b[0][i][0][0]) + ')' interesting_security_methods.append(temp) thread = database.get_distinct_thread() for i in range(0, len(thread)): thread_id.append(thread[i]) thread_id.reverse() thread_id.append("All") starting, ending, timeline_data = database.get_thread_line_nos(thread_id) startEnds = [] for i in range(0, len(starting)): temp = [] temp.append(starting[i]) temp.append(ending[i]) startEnds.append(temp) threadIDForThreadView = thread_id[:-1] threadIDForThreadView.insert(0, 'All') timeline_data = calcColPos_py.computeColumnPositions( startEnds, threadIDForThreadView) # Selects the thread you want to view select = request.form.get('comp_select') # Selects which function to view function = request.form.get('functionarea') data = database.get_interactions(select, function, thread_id) precomputed_pos, rect_data, maximum_height, maximum_width = precalc.precalc( after_insertion_data) # fromletstryworking = letstryworking.precalc(after_insertion_data) first_selected = next((sub for sub in rect_data if sub['Function'] == '1'), None) autoscroll_position_index = -1 if (first_selected != None): temp = first_selected['Line_no'] i = 0 for p in range(0, len(precomputed_pos)): if (precomputed_pos[p][0] == temp): i = p break autoscroll_position_index = i for i in range(0, len(precomputed_pos)): precomputed_pos[i].pop(0) # Flowchart without click elem = [] theThread = "-1" nameApp = 0 if (dataset == "Actual"): nameApp = 1 return render_template('trial.html', thread=thread_id, precomputed_pos=precomputed_pos, rectangle_data=rect_data, maximum_height=maximum_height, maximum_width=maximum_width, top_5=interesting_security_methods, elem=elem, timeline_data=timeline_data, autoscroll_position_index=autoscroll_position_index, all_methods=all_methods, theThread=theThread, dataset=nameApp)
def save(self, data): conn = self.access_db() db.insert_rows(conn, data) conn.close()