Beispiel #1
0
def retrieve_file(filename,column,direction):
    # determine which checkboxes selected
    params = request.args
    selected = []
    for key in params.keys():
        if params[key] == 'on':
            selected.append(key)
    if len(selected) == 0:
        return ''
    
    # get metadata for selected file
    metadata = broutils.get_metadata(filename)
    # reorder selected columns per normal Bro log file order
    ordered_columns = [item for item in metadata['fields'] if item in selected]
    
    selected_columns = ','.join(ordered_columns)
    #q = 'select %s from %s' % (selected_columns,metadata['path'][0])
    q = 'select %s from %s order by %s %s' % (selected_columns,metadata['path'][0],column,direction)
    print q
    #r = broutils.query(metadata,'test.db',q)
    r = broutils.query('test.db',q,factory=True)
    column_names = r[0].keys()
    try:
        args = request.url.rsplit('?')[1]
    except:
        args = ''
    return render_template('query_results.html',
                            column_names=column_names,
                            rows = r,
                            url=request.url.rsplit('/',2)[0],
                            args=args,
                            )
Beispiel #2
0
def conn_detail(detail_type,column,direction):
    
    if detail_type in broutils.PROTOCOLS:
        detail_column = 'proto'
    else:
        detail_column = 'service'
    q = 'select %s from conn where %s = "%s" order by %s %s' % (JOINED_BASIC_COLUMNS,detail_column,detail_type,column,direction)
    r = broutils.query('test.db',q,factory=True)
    column_names = r[0].keys()
    try:
        args = request.url.rsplit('?')[1]
    except:
        args = ''
    return render_template('query_results.html',
                            column_names=column_names,
                            rows = r,
                            url=request.url.rsplit('/',2)[0],
                            args=args,
                          )