Exemple #1
0
def explain_whitelist():
    whitelist_get = request.args.get("whitelist", "")
    whitelist_post = request.form.get("whitelist", "")
    if whitelist_get.isdigit():  # explain a whitelist by id
        _wl = NaxsiWhitelist.query.filter(NaxsiWhitelist.id == whitelist_get).first()
        if _wl is None:
            flash("Not rule with id %s" % whitelist_get)
            return redirect(url_for("sandbox.index"))
    elif whitelist_get is not "":
        flash("Please provide a numeric id")
        return redirect(url_for("sandbox.index"))
    elif not whitelist_post:
        flash("Please provide a whitelist")
        return redirect(url_for("sandbox.index"))
    else:
        _wl = NaxsiWhitelist()
        errors, warnings, rdict = _wl.parse(whitelist_post)
        _wl = NaxsiWhitelist()
        _wl.from_dict(rdict)
        _wl.errors = errors
        _wl.warnings = warnings

    if _wl.errors:
        for error in _wl.errors:
            flash(error, category="error")
            return render_template("misc/sandbox.html", whitelist=_wl)
    if _wl.warnings:
        for warnings in _wl.warnings:
            flash(warnings, category="warning")

    return render_template("misc/sandbox.html", whitelist_explaination=_wl.explain(), whitelist=_wl)
Exemple #2
0
def explain_whitelist():
    whitelist_get = request.args.get('whitelist', '')
    whitelist_post = request.form.get('whitelist', '')
    if whitelist_get.isdigit():  # explain a whitelist by id
        _wl = NaxsiWhitelist.query.filter(NaxsiWhitelist.id == whitelist_get).first()
        if _wl is None:
            flash('Not rule with id %s' % whitelist_get)
            return redirect(url_for("sandbox.index"))
    elif whitelist_get is not '':
        flash('Please provide a numeric id')
        return redirect(url_for("sandbox.index"))
    elif not whitelist_post:
        flash('Please provide a whitelist')
        return redirect(url_for("sandbox.index"))
    else:
        _wl = NaxsiWhitelist()
        errors, warnings, rdict = _wl.parse(whitelist_post)
        _wl = NaxsiWhitelist()
        _wl.from_dict(rdict)
        _wl.errors = errors
        _wl.warnings = warnings

    if _wl.errors:
        for error in _wl.errors:
            flash(error, category='error')
            return render_template("misc/sandbox.html", whitelist=_wl)
    if _wl.warnings:
        for warnings in _wl.warnings:
            flash(warnings, category='warning')

    return render_template("misc/sandbox.html", whitelist_explaination=_wl.explain(), whitelist=_wl)