|
@@ 26-47 (lines=22) @@
|
| 23 |
|
errors = warnings = list() |
| 24 |
|
rule_get = request.args.get('rule', '') |
| 25 |
|
rule_post = request.form.get("rule", '') |
| 26 |
|
if rule_get.isdigit(): # explain a rule by id |
| 27 |
|
_rule = NaxsiRules.query.filter(NaxsiRules.sid == rule_get).first() |
| 28 |
|
if _rule is None: |
| 29 |
|
flash('Not rule with id %s' % rule_get) |
| 30 |
|
return redirect(url_for("sandbox.index")) |
| 31 |
|
elif rule_get is not '': |
| 32 |
|
flash('Please provide a numeric id') |
| 33 |
|
return redirect(url_for("sandbox.index")) |
| 34 |
|
elif not rule_post: |
| 35 |
|
flash('Please provide a rule') |
| 36 |
|
return redirect(url_for("sandbox.index")) |
| 37 |
|
else: |
| 38 |
|
_rule = NaxsiRules() |
| 39 |
|
errors, warnings, rdict = _rule.parse_rule(rule_post) |
| 40 |
|
_rule = NaxsiRules() |
| 41 |
|
_rule.from_dict(rdict) |
| 42 |
|
_rule.errors = errors |
| 43 |
|
_rule.warnings = warnings |
| 44 |
|
|
| 45 |
|
if _rule.errors: |
| 46 |
|
flash('You rule is wrong', 'error') |
| 47 |
|
return render_template("misc/sandbox.html") |
| 48 |
|
|
| 49 |
|
if 'visualise_rule' in request.form: |
| 50 |
|
if _rule.detection.startswith('rx:'): |
|
@@ 69-86 (lines=18) @@
|
| 66 |
|
def explain_whitelist(): |
| 67 |
|
whitelist_get = request.args.get('whitelist', '') |
| 68 |
|
whitelist_post = request.form.get('whitelist', '') |
| 69 |
|
if whitelist_get.isdigit(): # explain a whitelist by id |
| 70 |
|
_wl = NaxsiWhitelist.query.filter(NaxsiWhitelist.id == whitelist_get).first() |
| 71 |
|
if _wl is None: |
| 72 |
|
flash('Not rule with id %s' % whitelist_get) |
| 73 |
|
return redirect(url_for("sandbox.index")) |
| 74 |
|
elif whitelist_get is not '': |
| 75 |
|
flash('Please provide a numeric id') |
| 76 |
|
return redirect(url_for("sandbox.index")) |
| 77 |
|
elif not whitelist_post: |
| 78 |
|
flash('Please provide a whitelist') |
| 79 |
|
return redirect(url_for("sandbox.index")) |
| 80 |
|
else: |
| 81 |
|
_wl = NaxsiWhitelist() |
| 82 |
|
errors, warnings, rdict = _wl.parse(whitelist_post) |
| 83 |
|
_wl = NaxsiWhitelist() |
| 84 |
|
_wl.from_dict(rdict) |
| 85 |
|
_wl.errors = errors |
| 86 |
|
_wl.warnings = warnings |
| 87 |
|
|
| 88 |
|
if _wl.errors: |
| 89 |
|
for error in _wl.errors: |