| @@ 57-68 (lines=12) @@ | ||
| 54 | return render_template("whitelistsets/index.html", whitelistsets=wls, selection=_selection) |
|
| 55 | ||
| 56 | ||
| 57 | @whitelistsets.route("/del/<int:wid>", methods=["POST"]) |
|
| 58 | def remove(wid): |
|
| 59 | _wlset = NaxsiWhitelistSets.query.filter(NaxsiWhitelistSets.id == wid).first() |
|
| 60 | if _wlset is None: |
|
| 61 | flash("The whitelist set %s doesn't exist." % wid, "error") |
|
| 62 | return redirect(url_for("whitelistsets.index")) |
|
| 63 | ||
| 64 | db.session.delete(_wlset) |
|
| 65 | db.session.commit() |
|
| 66 | ||
| 67 | flash("Successfully deleted %s " % _wlset.name, "success") |
|
| 68 | return redirect(url_for("whitelistsets.index")) |
|
| 69 | ||
| 70 | ||
| 71 | def __get_whitelist_for_whitelistset(whitelistset): |
|
| @@ 54-65 (lines=12) @@ | ||
| 51 | return redirect(url_for("rulesets.index")) |
|
| 52 | ||
| 53 | ||
| 54 | @rulesets.route("/del/<int:rname>", methods=["POST"]) |
|
| 55 | def remove(rname): |
|
| 56 | _rset = NaxsiRuleSets.query.filter(NaxsiRuleSets.id == rname).first() |
|
| 57 | if _rset is None: |
|
| 58 | flash("The ruleset %s doesn't exists." % rname, "error") |
|
| 59 | return redirect(url_for("rulesets.index")) |
|
| 60 | ||
| 61 | db.session.delete(_rset) |
|
| 62 | db.session.commit() |
|
| 63 | ||
| 64 | flash("OK deleted: %s " % rname, "success") |
|
| 65 | return redirect(url_for("rulesets.index")) |
|
| 66 | ||
| 67 | ||
| 68 | @rulesets.route("/select/<string:selector>", methods=["GET"]) |
|
| @@ 41-53 (lines=13) @@ | ||
| 38 | ||
| 39 | @rulesets.route("/new", methods=["POST"]) |
|
| 40 | def new(): # TODO filter parameter |
|
| 41 | rname = request.form["rname"].strip().upper() |
|
| 42 | ||
| 43 | if NaxsiRuleSets.query.filter(NaxsiRuleSets.name == rname).first(): |
|
| 44 | flash("Ruleset %s is already existing" % rname, "error") |
|
| 45 | return redirect(url_for("rulesets.index")) |
|
| 46 | ||
| 47 | db.session.add(NaxsiRuleSets(rname, "naxsi-ruleset: %s" % rname, int(time()))) |
|
| 48 | db.session.commit() |
|
| 49 | ||
| 50 | flash("OK created: %s " % rname, "success") |
|
| 51 | return redirect(url_for("rulesets.index")) |
|
| 52 | ||
| 53 | ||
| 54 | @rulesets.route("/del/<int:rname>", methods=["POST"]) |
|
| 55 | def remove(rname): |
|
| 56 | _rset = NaxsiRuleSets.query.filter(NaxsiRuleSets.id == rname).first() |
|
| @@ 50-60 (lines=11) @@ | ||
| 47 | return redirect(url_for('whitelists.new')) |
|
| 48 | ||
| 49 | ||
| 50 | @whitelists.route("/del/<string:wid>", methods=["GET"]) |
|
| 51 | def del_sid(wid): |
|
| 52 | _wlist = NaxsiWhitelist.query.filter(NaxsiWhitelist.id == wid).first() |
|
| 53 | if not _wlist: |
|
| 54 | return redirect(url_for('whitelists.index')) |
|
| 55 | ||
| 56 | db.session.delete(_wlist) |
|
| 57 | db.session.commit() |
|
| 58 | ||
| 59 | flash("Successfully deleted %s" % wid, "success") |
|
| 60 | return redirect(url_for('whitelists.index')) |
|
| 61 | ||
| 62 | ||
| 63 | @whitelists.route("/generate", methods=["GET", "POST"]) |
|
| @@ 158-168 (lines=11) @@ | ||
| 155 | if errors: |
|
| 156 | flash(",".join(errors), 'error') |
|
| 157 | return redirect("/rules/edit/%s" % sid) |
|
| 158 | elif warnings: |
|
| 159 | flash(",".join(warnings), 'warning') |
|
| 160 | ||
| 161 | db.session.add(nrule) |
|
| 162 | db.session.commit() |
|
| 163 | ||
| 164 | return redirect("/rules/edit/%s" % sid) |
|
| 165 | ||
| 166 | ||
| 167 | @rules.route("/del/<int:sid>", methods=["GET"]) |
|
| 168 | def del_sid(sid=''): |
|
| 169 | nrule = NaxsiRules.query.filter(NaxsiRules.sid == sid).first() |
|
| 170 | if not nrule: |
|
| 171 | return redirect(url_for("rules.index")) |
|