Code Duplication    Length = 20-20 lines in 2 locations

spike/views/rulesets.py 1 location

@@ 75-94 (lines=20) @@
72
    return render_template("rules/index.html", rules=_rules, selection=_selection)
73
74
75
def __get_rules_for_ruleset(ruleset):
76
    if not ruleset:
77
        return ''
78
79
    _rules = NaxsiRules.query.filter(
80
        NaxsiRules.ruleset == ruleset.name,
81
        NaxsiRules.active == 1
82
    ).all()
83
84
    nxruleset = NaxsiRuleSets.query.filter(NaxsiRuleSets.name == ruleset.name).first()
85
    db.session.add(nxruleset)
86
    db.session.commit()
87
88
    text_rules = ''.join([r.fullstr() for r in _rules])
89
90
    header = current_app.config["RULESET_HEADER"]
91
    header = header.replace("RULESET_DESC", ruleset.name)
92
    header = header.replace("RULESET_DATE", strftime("%F - %H:%M", localtime(time())))
93
94
    return header + text_rules
95

spike/views/whitelistsets.py 1 location

@@ 71-90 (lines=20) @@
68
    return redirect(url_for("whitelistsets.index"))
69
70
71
def __get_whitelist_for_whitelistset(whitelistset):
72
    if not whitelistset:
73
        return ''
74
75
    _rules = NaxsiWhitelist.query.filter(
76
        NaxsiWhitelist.whitelistset == whitelistset.name,
77
        NaxsiWhitelist.active == 1
78
    ).all()
79
80
    nxruleset = NaxsiWhitelistSets.query.filter(NaxsiWhitelistSets.name == whitelistset.name).first()
81
    db.session.add(nxruleset)
82
    db.session.commit()
83
84
    text_rules = ''.join(map(str, _rules))
85
86
    header = current_app.config["RULESET_HEADER"]
87
    header = header.replace("RULESET_DESC", whitelistset.name)
88
    header = header.replace("RULESET_DATE", strftime("%F - %H:%M", localtime(time())))
89
90
    return header + text_rules
91