From ddd899e35b89f4833337e87e1ec852b3d902ddef Mon Sep 17 00:00:00 2001 From: wufeifei Date: Sat, 10 Sep 2016 12:33:50 +0800 Subject: [PATCH 1/3] add log --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index a6ad6869..9cb29580 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,3 +20,4 @@ smmap==0.9.0 SQLAlchemy==1.0.13 visitor==0.1.3 Werkzeug==0.11.9 +ConcurrentLogHandler==0.9.1 \ No newline at end of file From 453357b9bcdba435e6da3a5445045d27fc21b436 Mon Sep 17 00:00:00 2001 From: wufeifei Date: Sat, 10 Sep 2016 16:08:33 +0800 Subject: [PATCH 2/3] edit author --- app/controller/backend/RulesController.py | 8 ++------ app/models.py | 4 +++- app/templates/asset/js/admin.js | 6 ++++++ app/templates/backend/rule/edit_rule.html | 10 +++++++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/controller/backend/RulesController.py b/app/controller/backend/RulesController.py index 161cdf6a..4f2de716 100644 --- a/app/controller/backend/RulesController.py +++ b/app/controller/backend/RulesController.py @@ -31,7 +31,6 @@ @web.route(ADMIN_URL + '/rules/', methods=['GET']) @login_required def rules(page): - per_page = 10 cobra_rules = CobraRules.query.order_by(CobraRules.id.desc()).limit(per_page).offset((page - 1) * per_page).all() cobra_vuls = CobraVuls.query.all() @@ -79,7 +78,6 @@ def rules(page): @web.route(ADMIN_URL + '/add_new_rule', methods=['GET', 'POST']) @login_required def add_new_rule(): - if request.method == 'POST': vc = ValidateClass(request, 'vul_type', 'language', 'regex_location', 'regex_repair', 'repair_block', 'description', 'repair', 'level') @@ -121,7 +119,6 @@ def add_new_rule(): @web.route(ADMIN_URL + '/del_rule', methods=['POST']) @login_required def del_rule(): - vc = ValidateClass(request, "rule_id") vc.check_args() vul_id = vc.vars.rule_id @@ -141,11 +138,9 @@ def del_rule(): @web.route(ADMIN_URL + '/edit_rule/', methods=['GET', 'POST']) @login_required def edit_rule(rule_id): - if request.method == 'POST': - vc = ValidateClass(request, "vul_type", "language", "regex_location", "regex_repair", "block_repair", - "description", "rule_id", "repair", "status", "level") + vc = ValidateClass(request, "vul_type", "language", "regex_location", "regex_repair", "block_repair", "description", "rule_id", "repair", "author", "status", "level") ret, msg = vc.check_args() if not ret: @@ -159,6 +154,7 @@ def edit_rule(rule_id): r.regex_repair = vc.vars.regex_repair r.description = vc.vars.description r.repair = vc.vars.repair + r.author = vc.vars.author r.status = vc.vars.status r.level = vc.vars.level r.updated_at = datetime.datetime.now() diff --git a/app/models.py b/app/models.py index a0a31a67..ac0c4c55 100644 --- a/app/models.py +++ b/app/models.py @@ -84,12 +84,13 @@ class CobraRules(db.Model): block_repair = db.Column(TINYINT(2), nullable=False, default=None) description = db.Column(db.String(256), nullable=False, default=None) repair = db.Column(db.String(512), nullable=False, default=None) + author = db.Column(db.String(56), nullable=False, default=None) status = db.Column(TINYINT(2), nullable=False, default=None) level = db.Column(TINYINT(2), nullable=False, default=None) created_at = db.Column(db.DateTime, nullable=False, default=None) updated_at = db.Column(db.DateTime, nullable=False, default=None) - def __init__(self, vul_id, language, regex_location, regex_repair, block_repair, description, repair, status, level, created_at=None, updated_at=None): + def __init__(self, vul_id, language, regex_location, regex_repair, block_repair, description, repair, status, author, level, created_at=None, updated_at=None): self.vul_id = vul_id self.language = language self.regex_location = regex_location @@ -98,6 +99,7 @@ def __init__(self, vul_id, language, regex_location, regex_repair, block_repair, self.description = description self.repair = repair self.status = status + self.author = author self.level = level self.created_at = created_at self.updated_at = updated_at diff --git a/app/templates/asset/js/admin.js b/app/templates/asset/js/admin.js index 7a19ef8a..362c7ccc 100644 --- a/app/templates/asset/js/admin.js +++ b/app/templates/asset/js/admin.js @@ -133,6 +133,7 @@ $("#main-div").delegate("span", "click", function () { var regex_repair = $("#regex-repair").val(); var block_reapir = $("#repair-block:checked").val(); var repair = $("#repair").val(); + var author = $("input[name=author]").val(); var status = $("#status:checked").val(); var level = $("#level:checked").val(); @@ -165,6 +166,10 @@ $("#main-div").delegate("span", "click", function () { showAlert('danger', 'repair can not be blank.', '#edit-rule-result'); return false; } + if (!author || author == "") { + showAlert('danger', 'author can not be blank.', '#edit-rule-result'); + return false; + } if (!status || status == "") { showAlert('danger', 'status error.', '#edit-rule-result'); return false; @@ -184,6 +189,7 @@ $("#main-div").delegate("span", "click", function () { 'description': description, 'rule_id': cid, 'repair': repair, + 'author': author, 'status': status, 'level': level }; diff --git a/app/templates/backend/rule/edit_rule.html b/app/templates/backend/rule/edit_rule.html index eabd2fff..0dc5cabe 100644 --- a/app/templates/backend/rule/edit_rule.html +++ b/app/templates/backend/rule/edit_rule.html @@ -1,5 +1,9 @@
-
+
+ + +
+
+
+
-
+
-
+ +
+ + + +
+
-
+
-