pep8

parent 78699ba9
......@@ -17,12 +17,14 @@ from burpui.api import api
from burpui.api.settings import ServerSettings, ClientSettings
from burpui.api.servers import ServersStats, Live
@login_manager.user_loader
def load_user(userid):
if bui.auth != 'none':
return bui.uhandler.user(userid)
return None
@app.route('/settings', methods=['GET', 'POST'])
@app.route('/<server>/settings', methods=['GET', 'POST'])
@app.route('/settings/<client>', methods=['GET', 'POST'])
......@@ -56,6 +58,7 @@ app.jinja_env.globals.update(ClientSettings=ClientSettings)
app.jinja_env.globals.update(ServersStats=ServersStats)
app.jinja_env.globals.update(Live=Live)
@app.route('/api/render-live-template', methods=['GET'])
@app.route('/api/<server>/render-live-template', methods=['GET'])
@app.route('/api/render-live-template/<name>')
......@@ -76,9 +79,9 @@ def render_live_tpl(server=None, name=None):
if not name:
abort(500)
# Manage ACL
if bui.acl_handler \
and (not bui.acl_handler.acl.is_client_allowed(current_user.name, name, server) \
or not bui.acl_handler.acl.is_admin(current_user.name)):
if (bui.acl_handler and
(not bui.acl_handler.acl.is_client_allowed(current_user.name, name, server) or
not bui.acl_handler.acl.is_admin(current_user.name))):
abort(403)
if isinstance(bui.cli.running, dict):
if server and name not in bui.cli.running[server]:
......@@ -101,8 +104,10 @@ def render_live_tpl(server=None, name=None):
"""
Here are some custom filters
"""
@app.template_filter()
def mypad (s):
def mypad(s):
"""
Filter: used to pad 0's to backup numbers as in the burp's status monitor
"""
......@@ -110,6 +115,7 @@ def mypad (s):
return '0000000'
return '{0:07d}'.format(int(s))
@app.template_filter()
def time_human(d):
s = ''
......@@ -120,6 +126,7 @@ def time_human(d):
s = '%02dH' % hours
return '%s %02dm %02ds' % (s, minutes, seconds)
@app.template_filter()
def bytes_human(b):
return '{0:.1eM}'.format(_hr(b))
......@@ -128,6 +135,7 @@ def bytes_human(b):
And here is the main site
"""
@app.route('/live-monitor')
@app.route('/<server>/live-monitor')
@app.route('/live-monitor/<name>')
......@@ -150,9 +158,10 @@ def live_monitor(server=None, name=None):
if not run:
flash('Sorry, there are no running backups', 'warning')
return redirect(url_for('home'))
return render_template('live-monitor.html', live=True, cname=name, server=server)
@app.route('/client-browse/<name>', methods=['GET'])
@app.route('/<server>/client-browse/<name>', methods=['GET'])
@app.route('/client-browse/<name>/<int:backup>')
......@@ -173,6 +182,7 @@ def client_browse(server=None, name=None, backup=None, encrypted=None):
return redirect(url_for('client_browse', name=name, backup=bkp, encrypted=encrypted, server=server))
return render_template('client-browse.html', tree=True, backup=True, overview=True, cname=name, nbackup=backup, encrypted=encrypted, server=server)
@app.route('/client-report/<name>')
@app.route('/<server>/client-report/<name>')
@login_required
......@@ -190,6 +200,7 @@ def client_report(server=None, name=None):
return redirect(url_for('backup_report', name=name, backup=l[0]['number'], server=server))
return render_template('client-report.html', client=True, report=True, cname=name, server=server)
@app.route('/clients-report')
@app.route('/<server>/clients-report')
@login_required
......@@ -201,6 +212,7 @@ def clients_report(server=None):
server = request.args.get('server')
return render_template('clients-report.html', clients=True, report=True, server=server)
@app.route('/backup-report/<name>', methods=['GET'])
@app.route('/<server>/backup-report/<name>', methods=['GET'])
@app.route('/backup-report/<name>/<int:backup>', methods=['GET'])
......@@ -216,6 +228,7 @@ def backup_report(server=None, name=None, backup=None):
server = request.args.get('server')
return render_template('backup-report.html', client=True, backup=True, report=True, cname=name, nbackup=backup, server=server)
@app.route('/client', methods=['GET'])
@app.route('/<server>/client', methods=['GET'])
@app.route('/client/<name>')
......@@ -235,6 +248,7 @@ def client(server=None, name=None):
return redirect(url_for('live_monitor', name=c, server=server))
return render_template('client.html', client=True, overview=True, cname=c, server=server)
@app.route('/clients', methods=['GET'])
@app.route('/<server>/clients', methods=['GET'])
@login_required
......@@ -243,11 +257,13 @@ def clients(server=None):
server = request.args.get('server')
return render_template('clients.html', clients=True, overview=True, server=server)
@app.route('/servers', methods=['GET'])
@login_required
def servers():
return render_template('servers.html', servers=True, overview=True)
@app.route('/login', methods=['POST', 'GET'])
def login():
form = LoginForm(request.form)
......@@ -261,12 +277,14 @@ def login():
flash('Wrong username or password', 'danger')
return render_template('login.html', form=form, login=True)
@app.route('/logout')
@login_required
def logout():
logout_user()
return redirect(url_for('home'))
@app.route('/')
@login_required
def home():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment