Exemplo n.º 1
0
def printFilterForm(case):
    oSize = helper.getDirectorySize(CASES_DIR+case.caseName+ORIGIN_DIR)
    fSize = helper.getDirectorySize(CASES_DIR+case.caseName+PCAP_DIR)
    eTime = helper.getFilterFileTime(oSize)
    aTime = helper.getFilterFileTime(fSize)
    eTitle = 'Apply filters on files may take up to ' + helper.getReadableTimeInfo(eTime)
    aTitle = 'Apply filters on files may take up to ' + helper.getReadableTimeInfo(aTime)

    filterContent = helper.getFilter(case.caseName)
    timeFilter = helper.getTimeFilter(case.caseName)
    print '<h2>Edit inicial filter</h2>'
    formStr = '<form class="form-horizontal" action="main.py" method="post">'
    formStr += '<div class="form-group"><label class="col-md-2">Description:</label>'
    formStr += '<p class="col-md-10 form-control-static">'+case.description+'</p></div>'
    formStr += '<input type="hidden" name="actions" value="editFilter">'
    formStr += '<input type="hidden" name="pagesToRender" value="case:saveFile">'
    formStr += '<div class="form-group"><label class="col-md-2">Time window:</label>'
    formStr += '<div class="col-md-2"><label>From:</label><input type="text" title="Enter date and time in format: YYYY-MM-DD HH:MM:SS" class="form-control" name="start" value="'+timeFilter[0]+'"/></div>'
    formStr += '<div class="col-md-2"><label>To:</label><input type="text" title="Enter date and time in format: YYYY-MM-DD HH:MM:SS" class="form-control" name="end" value="'+timeFilter[1]+'"/></div></div>'
    formStr += '<div class="form-group">'
    formStr += '<label class="col-md-2">Inicial filter:</label>'
    formStr += '<div class="col-md-4"><textarea class="form-control" name="filterContent">'+filterContent+'</textarea></div></div>'
    formStr += '<input type="hidden" name="caseName" value="'+case.caseName+'">'
    formStr += '<div class="form-group">'
    formStr += '<div class="col-md-6"><input type="submit" value="Apply on Filtered" class="btn btn-default pull-right" title="'+aTitle+'" onclick="startProgresBar('+str(aTime)+')" name="Append">'
    formStr += '<input type="submit" value="Apply" class="btn btn-default pull-right" title="'+eTitle+'" onclick="startProgresBar('+str(eTime)+')" name="Edit"></div></div></form>'
    print formStr
    print '<hr/>'
    print htmlGen.generateProgresBar()
Exemplo n.º 2
0
def render():
    # load all cases from file and create links to them
    cases = loadCases()
    print '<h1>Cases:</h1>'
    print '<hr/>'
    print '<h2>Available cases</h2>'
    print '<div class="col-md-3">'
    print '<div class="form-group">'
    for case in cases:
        sizeOfNewFiles = getSizeOfNewFilesInCase(case.caseName)
        syslog.syslog("PCAP APP: CASES OWERWRITE FILE  ended: " +
                      str(sizeOfNewFiles))
        title = "No new files."
        if sizeOfNewFiles:
            style = 'style="color:red;"'
            approximateTime = helper.getFilterFileTime(sizeOfNewFiles)
            s = ' - ' + helper.sizeof_fmt(sizeOfNewFiles) + ' of new files.'
            title = 'Apply filters on new files may take up to ' + helper.getReadableTimeInfo(
                approximateTime)
            print '<a href = "main.py?caseName=' + case.caseName + '&pagesToRender=case:saveFile"' + style + 'class="list-group-item" onclick="startProgresBar(' + str(
                approximateTime
            ) + ')" title="' + title + '">' + case.caseName + s + '</a>'
        else:
            print '<a href = "main.py?caseName=' + case.caseName + '&pagesToRender=case:saveFile"class="list-group-item" title="' + title + '">' + case.caseName + '</a>'
    print '</div>'
    print htmlGen.generateProgresBar()
    print '<hr/>'
    print '<h2>Add new case</h2>'
    # form which is used for adding new case
    formStr = '<form action="main.py" method="post">\n'
    formStr += '<div class="form-group">'
    formStr += '<label>Case Name:</label>'
    formStr += '<input type="text" name="caseName" class="form-control" placeholder="Please enter: Case Name"></div>\n'
    formStr += '<div class="form-group">'
    formStr += '<label>Case Description:</label></div>'
    formStr += '<div class="form-group">'
    formStr += '<textarea name="caseDescription" class="form-control" placeholder="Please enter: Case Description"></textarea></div>\n'
    formStr += '<input type="hidden" name="pagesToRender" value="cases">\n'
    formStr += '<input type="hidden" name="actions" value="addCase">\n'
    formStr += '<input type="submit" value="Submit" class="btn btn-default pull-right"></a></form>\n'
    print formStr
Exemplo n.º 3
0
def render():
    # load all cases from file and create links to them
    cases = loadCases()
    print '<h1>Cases:</h1>'
    print '<hr/>'
    print '<h2>Available cases</h2>'
    print '<div class="col-md-3">'
    print '<div class="form-group">'
    for case in cases:
        sizeOfNewFiles = getSizeOfNewFilesInCase(case.caseName)
        syslog.syslog("PCAP APP: CASES OWERWRITE FILE  ended: "+str(sizeOfNewFiles))
        title = "No new files."
        if sizeOfNewFiles:
            style = 'style="color:red;"'
            approximateTime = helper.getFilterFileTime(sizeOfNewFiles)
            s = ' - ' + helper.sizeof_fmt(sizeOfNewFiles) + ' of new files.'
            title = 'Apply filters on new files may take up to ' + helper.getReadableTimeInfo(approximateTime)
            print '<a href = "main.py?caseName='+case.caseName+'&pagesToRender=case:saveFile"'+style+'class="list-group-item" onclick="startProgresBar('+str(approximateTime)+')" title="'+title+'">' + case.caseName + s +'</a>'
        else:
            print '<a href = "main.py?caseName='+case.caseName+'&pagesToRender=case:saveFile"class="list-group-item" title="'+title+'">' + case.caseName + '</a>'
    print '</div>'
    print htmlGen.generateProgresBar()
    print '<hr/>'
    print '<h2>Add new case</h2>'
    # form which is used for adding new case
    formStr = '<form action="main.py" method="post">\n'
    formStr += '<div class="form-group">'
    formStr += '<label>Case Name:</label>'
    formStr += '<input type="text" name="caseName" class="form-control" placeholder="Please enter: Case Name"></div>\n'
    formStr += '<div class="form-group">'
    formStr += '<label>Case Description:</label></div>'
    formStr += '<div class="form-group">'
    formStr += '<textarea name="caseDescription" class="form-control" placeholder="Please enter: Case Description"></textarea></div>\n'
    formStr += '<input type="hidden" name="pagesToRender" value="cases">\n'
    formStr += '<input type="hidden" name="actions" value="addCase">\n'
    formStr += '<input type="submit" value="Submit" class="btn btn-default pull-right"></a></form>\n'
    print formStr