Commit b8c1a19d authored by Alexandre Dulaunoy's avatar Alexandre Dulaunoy
Browse files

Merge pull request #145 from adulau/master

Major web interface clean-up + some fixes for the minimal part
parents 18e99746 7fea47c9
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
#

# Copyright (c) 2013-2014 	Alexandre Dulaunoy - a@foo.be
# Copyright (c) 2014-2015 	Pieter-Jan Moreels - pieterjan.moreels@gmail.com
# Copyright (c) 2014-2016 	Pieter-Jan Moreels - pieterjan.moreels@gmail.com

# imports
import os
@@ -151,6 +151,18 @@ def adminStats():
    return db.getDBStats()


def filterUpdateField(data):
    if not data: return data
    returnvalue = []
    for line in data.split("\n"):
        print(line)
        if (not line.startswith("[+]Success to create index") and
            not line == "Not modified" and
            not line.startswith("Starting")):
                returnvalue.append(line)
    return "\n".join(returnvalue)


def filter_logic(blacklist, whitelist, unlisted, timeSelect, startDate, endDate,
                 timeTypeSelect, cvssSelect, cvss, rejectedSelect, hideSeen, limit, skip):
    query = []
@@ -491,7 +503,7 @@ def admin():
            separator="==========================\n"
            output=updateFile.read().split(separator)[-2:]
            output=separator+separator.join(output)
    return render_template('admin.html', status=status, stats=adminStats(), updateOutput=output)
    return render_template('admin.html', status=status, stats=adminStats(), updateOutput=filterUpdateField(output))


@app.route('/admin/updatedb')
@@ -501,7 +513,7 @@ def updatedb():
    out, err = process.communicate()
    output="%s\n\nErrors:\n%s"%(str(out,'utf-8'),str(err,'utf-8')) if err else str(out,'utf-8')
    status = ["db_updated", "success"]
    return render_template('admin.html', status=status, stats=adminStats(), updateOutput=output)
    return render_template('admin.html', status=status, stats=adminStats(), updateOutput=filterUpdateField(output))


@app.route('/admin/whitelist/import', methods=['POST'])
+3 −3
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ def index():
    rejectedSelect = "hide"
    cve = filter_logic(unlisted, timeSelect, startDate, endDate,
                       timeTypeSelect, cvssSelect, cvss, rejectedSelect, pageLength, 0)
    return render_template('index-minimal.html', cve=cve, r=0, pageLength=pageLength)
    return render_template('index-minimal.html', cve=cve, r=0, pageLength=pageLength,  minimal=True)

@app.route('/', methods=['POST'])
def filterPost():
@@ -138,7 +138,7 @@ def filterPost():
    # retrieving data
    cve = filter_logic(unlisted, timeSelect, startDate, endDate,
                       timeTypeSelect, cvssSelect, cvss, rejectedSelect, pageLength, 0)
    return render_template('index-minimal.html', settings=settings, cve=cve, r=0, pageLength=pageLength)
    return render_template('index-minimal.html', settings=settings, cve=cve, r=0, pageLength=pageLength,  minimal=True)


@app.route('/r/<int:r>', methods=['POST', 'GET'])
@@ -163,7 +163,7 @@ def filterLast(r):
    # retrieving data
    cve = filter_logic(unlisted, timeSelect, startDate, endDate,
                       timeTypeSelect, cvssSelect, cvss, rejectedSelect, pageLength, r)
    return render_template('index-minimal.html', settings=settings, cve=cve, r=r, pageLength=pageLength)
    return render_template('index-minimal.html', settings=settings, cve=cve, r=r, pageLength=pageLength, minimal=True)

@app.route('/api/cpe2.3/<path:cpe>', methods=['GET'])
def cpe23(cpe):
+9 −29
Original line number Diff line number Diff line
<!doctype html>
<html lang="en">
<head>
  <title>404</title>
  <!-- defaults -->
  {% include 'defaultHead.html' %}
</head>
<body>
  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-12">
        <!-- Nav -->
        {% if minimal %}
          {% include 'menu-minimal.html' %}
        {% else %}
          {% include 'menu.html' %}
        {% endif %}
        <!-- End Nav -->
        <!-- Content -->
{% extends 'layouts/master-page' %}
{% block title %}404{% endblock %}

{% block content %}
  <div class="well">
    <h1>404</h1>
    <h2>This means page not found</h2>
    <p>You navigated to a page that cannot be recreated by the server. Check the URL or try something else.</p>
  </div>
        <!-- end content -->
      </div>
    </div>
  </div>
</body>
</html>
{% endblock %}
+114 −131
Original line number Diff line number Diff line
<!doctype html>
<html lang="en">
<head>
  <title>Admin page</title>
  <!-- defaults -->
  {% include 'defaultHead.html' %}
{% extends 'layouts/master-page' %}
{% block title %}Admin page{% endblock %}
{% block head %}
  <!-- css -->
  <link href="/static/css/custom/admin.css" rel="stylesheet" />

  <!-- javascript -->
  <script type="text/javascript" src="/static/js/custom/admin.js"></script>
</head>

<body>
  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-12">
        <!-- Nav -->
        {% include 'menu.html' %}
        <!-- End Nav -->
        <!-- Content -->
        <div>
{% endblock %}
{% block content %}
  <!-- Status -->
  <div>
    <!-- type -->
@@ -131,9 +119,4 @@
    <button onclick="location.href='/admin/blacklist'">View</button>
  </div>
  <a href="#" class="back-to-top">Back to Top</a>
        </div>
        <!-- end content -->
      </div>
    </div>
  </div>
</body>
{% endblock %}
+12 −35
Original line number Diff line number Diff line
<!doctype html>
<html lang="en">
<head>
  <title>Bookmarked CVEs</title>
  <!-- defaults -->
  {% include 'defaultHead.html' %}

{% extends 'layouts/master-page' %}
{% block title %}Bookmarked CVEs{% endblock %}
{% block head %}
  <!-- css -->
  <link href="/static/css/custom/filter.css" rel="stylesheet" />
</head>

<body>
  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-12">
        <!-- Nav -->
        {% if minimal %}
          {% include 'menu-minimal.html' %}
        {% else %}
          {% include 'menu.html' %}
        {% endif %}
        <!-- End Nav -->
        <!-- Content -->
        <div>
{% endblock %}
{% block content %}
  <!-- breadcrumb -->
  <ol class="breadcrumb">
    <li><a href="/">Home</a></li>
    <li class="active">Bookmarked</li>
  </ol>
          {% include 'table.html' %}
        </div>
        <!-- end content -->
      </div>
    </div>
  </div>
</body>
</html>
  {% include 'subpages/table.html' %}
{% endblock %}
Loading