Ejemplo n.º 1
0
def host_edit_route(host_id):
    """edit host"""

    host = Host.query.get(host_id)
    form = HostForm(obj=host, return_url=relative_referrer())

    if form.validate_on_submit():
        form.populate_obj(host)
        db.session.commit()
        if valid_next_url(form.return_url.data):
            return redirect(form.return_url.data)

    return render_template('storage/host/addedit.html', form=form)
Ejemplo n.º 2
0
def note_edit_route(note_id):
    """edit note"""

    note = Note.query.get(note_id)
    form = NoteForm(obj=note, return_url=relative_referrer())

    if form.validate_on_submit():
        form.populate_obj(note)
        db.session.commit()
        if valid_next_url(form.return_url.data):
            return redirect(form.return_url.data)

    return render_template('storage/note/addedit.html', form=form, host=note.host, service=note.service)
Ejemplo n.º 3
0
def service_edit_route(service_id):
    """edit service"""

    service = Service.query.get(service_id)
    form = ServiceForm(obj=service, return_url=relative_referrer())

    if form.validate_on_submit():
        form.populate_obj(service)
        db.session.commit()
        if valid_next_url(form.return_url.data):
            return redirect(form.return_url.data)

    return render_template('storage/service/addedit.html', form=form, host=service.host)
Ejemplo n.º 4
0
def vuln_edit_route(vuln_id):
    """edit vuln"""

    vuln = Vuln.query.get(vuln_id)
    form = VulnForm(obj=vuln, return_url=relative_referrer())

    if form.validate_on_submit():
        form.populate_obj(vuln)
        db.session.commit()
        if valid_next_url(form.return_url.data):
            return redirect(form.return_url.data)

    return render_template('storage/vuln/addedit.html',
                           form=form,
                           host=vuln.host,
                           service=vuln.service)
Ejemplo n.º 5
0
def test_valid_next_url(app):  # pylint: disable=unused-argument
    """test next= and return_url= validator"""

    assert valid_next_url(url_for('index_route'))
    assert not valid_next_url('http://invalid_route')
    assert not valid_next_url('invalid_route')
Ejemplo n.º 6
0
def redirect_after_login():
    """handle next after successfull login"""

    if ('next' in request.args) and valid_next_url(request.args.get('next')):
        return redirect(request.args.get('next'))
    return redirect(url_for('index_route'))