def listAdd(self): cpe = request.args.get('cpe') cpeType = request.args.get('type') lst = request.args.get('list') isglobal = False if db.isMasterAccount(current_user.get_id()): isglobal = True logging.info( "CPE:{0} cpeType:{1} lst:{2} isglobal:{3} user:{4}".format( cpe, cpeType, lst, isglobal, current_user.get_id())) if cpe and cpeType and lst: status = "added_to_list" if self.addCPEToList( cpe, lst, cpeType, isglobal, current_user.get_id()) else "already_exists_in_list" print(status) returnList = db.getWhitelist(user=current_user.get_id( )) if lst == "Whitelist" else db.getBlacklist( user=current_user.get_id()) pprint(returnList) return jsonify({ "status": status, "rules": returnList, "listType": lst.title() }) else: return jsonify({"status": "could_not_add_to_list"})
def listAdd(): cpe = request.args.get('cpe') cpeType = request.args.get('type') lst = request.args.get('list') status = ["added", "success"] if addCPEToList(cpe, lst, cpeType) else ["already_exists", "info"] returnList = dbLayer.getWhitelist() if lst=="whitelist" else dbLayer.getBlacklist() return jsonify({"status":status, "rules":returnList, "listType":lst.title()})
def listAdd(): cpe = request.args.get('cpe') cpeType = request.args.get('type') lst = request.args.get('list') status = ["added", "success"] if addCPEToList(cpe, lst, cpeType) else ["already_exists", "info"] returnList = db.getWhitelist() if lst=="whitelist" else db.getBlacklist() return jsonify({"status":status, "rules":returnList, "listType":lst.title()})
def listRemove(self): cpe = request.args.get('cpe', type=str) cpe = urllib.parse.quote_plus(cpe).lower() user = current_user.get_id() cpe = cpe.replace("%3a", ":") cpe = cpe.replace("%2f", "/") lst = request.args.get('list', type=str) if cpe and lst: result = wl.removeWhitelist( cpe, user) if lst.lower() == "whitelist" else bl.removeBlacklist( cpe, user) status = "removed_from_list" if ( result > 0) else "already_removed_from_list" else: status = "invalid_cpe" returnList = db.getWhitelist(user=current_user.get_id( )) if lst == "Whitelist" else db.getBlacklist( user=current_user.get_id()) pprint("Returned list {0}".format(returnList)) return jsonify({ "status": status, "rules": returnList, "listType": lst.title() })
def listAdd(): cpe = request.args.get('cpe') cpeType = request.args.get('type') lst = request.args.get('list') if cpe and cpeType and lst: status = "added_to_list" if addCPEToList(cpe, lst, cpeType) else "already_exists_in_list" returnList = db.getWhitelist() if lst=="whitelist" else db.getBlacklist() return jsonify({"status":status, "rules":returnList, "listType":lst.title()}) else: return jsonify({"status": "could_not_add_to_list"})
def listView(self): if request.url_rule.rule.split('/')[2].lower() == 'whitelist': return render_template('list.html', rules=db.getWhitelist(), listType="Whitelist") else: return render_template('list.html', rules=db.getBlacklist(), listType="Blacklist")
def listEdit(): oldCPE = request.args.get('oldCPE') newCPE = request.args.get('cpe') lst = request.args.get('list') CPEType = request.args.get('type') if oldCPE and newCPE: result = updateWhitelist(oldCPE, newCPE, CPEType) if lst=="whitelist" else updateBlacklist(oldCPE, newCPE, CPEType) status = "cpelist_updated" if (result) else "cpelist_update_failed" else: status = "invalid_cpe" returnList = list(db.getWhitelist()) if lst=="whitelist" else list(db.getBlacklist()) return jsonify({"rules":returnList, "status":status, "listType":lst})
def listRemove(): cpe = request.args.get('cpe', type=str) cpe = urllib.parse.quote_plus(cpe).lower() cpe = cpe.replace("%3a", ":") cpe = cpe.replace("%2f", "/") lst = request.args.get('list', type=str) if cpe and lst: result=removeWhitelist(cpe) if lst.lower()=="whitelist" else removeBlacklist(cpe) status = "removed_from_list" if (result > 0) else "already_removed_from_list" else: status = "invalid_cpe" returnList = db.getWhitelist() if lst=="whitelist" else db.getBlacklist() return jsonify({"status":status, "rules":returnList, "listType":lst.title()})
def listRemove(): cpe = request.args.get('cpe', type=str) cpe = urllib.parse.quote_plus(cpe).lower() cpe = cpe.replace("%3a", ":") cpe = cpe.replace("%2f", "/") lst = request.args.get('list', type=str) if cpe: result=removeWhitelist(cpe) if lst=="whitelist" else removeBlacklist(cpe) status = ["removed", "success"] if (result > 0) else ["already_removed", "info"] else: status = ["invalid_url", "error"] returnList = db.getWhitelist() if lst=="whitelist" else db.getBlacklist() return jsonify({"status":status, "rules":returnList, "listType":lst.title()})
def listRemove(): cpe = request.args.get('cpe', type=str) cpe = urllib.parse.quote_plus(cpe).lower() cpe = cpe.replace("%3a", ":") cpe = cpe.replace("%2f", "/") lst = request.args.get('list', type=str) if cpe: result=removeWhitelist(cpe) if lst=="whitelist" else removeBlacklist(cpe) status = ["removed", "success"] if (result > 0) else ["already_removed", "info"] else: status = ["invalid_url", "error"] returnList = dbLayer.getWhitelist() if lst=="whitelist" else dbLayer.getBlacklist() return jsonify({"status":status, "rules":returnList, "listType":lst.title()})
def listEdit(): oldCPE = request.args.get('oldCPE') newCPE = request.args.get('cpe') lst = request.args.get('list') CPEType = request.args.get('type') if oldCPE and newCPE: result = updateWhitelist(oldCPE, newCPE, CPEType) if lst=="whitelist" else updateBlacklist(oldCPE, newCPE, CPEType) if (result): status = ["updated", "success"] else: status = ["update_failed", "error"] else: status = ["invalid_url", "error"] returnList = list(dbLayer.getWhitelist()) if lst=="whitelist" else list(dbLayer.getBlacklist()) return jsonify({"rules":returnList, "status":status, "listType":lst})
def listEdit(): oldCPE = request.args.get("oldCPE") newCPE = request.args.get("cpe") lst = request.args.get("list") CPEType = request.args.get("type") if oldCPE and newCPE: result = ( updateWhitelist(oldCPE, newCPE, CPEType) if lst == "whitelist" else updateBlacklist(oldCPE, newCPE, CPEType) ) if result: status = ["updated", "success"] else: status = ["update_failed", "error"] else: status = ["invalid_url", "error"] returnList = list(db.getWhitelist()) if lst == "whitelist" else list(db.getBlacklist()) return jsonify({"rules": returnList, "status": status, "listType": lst})
def listEdit(): oldCPE = request.args.get('oldCPE') newCPE = request.args.get('cpe') lst = request.args.get('list') CPEType = request.args.get('type') if oldCPE and newCPE: result = updateWhitelist( oldCPE, newCPE, CPEType) if lst == "whitelist" else updateBlacklist( oldCPE, newCPE, CPEType) if (result): status = ["updated", "success"] else: status = ["update_failed", "error"] else: status = ["invalid_url", "error"] returnList = list(dbLayer.getWhitelist()) if lst == "whitelist" else list( dbLayer.getBlacklist()) return jsonify({"rules": returnList, "status": status, "listType": lst})
def blacklistView(): return render_template('list.html', rules=dbLayer.getBlacklist(), status=["default", "none"], listType="Blacklist")
def api_admin_blacklist(self): return db.getBlacklist()
def blacklistView(): return render_template('list.html', rules=db.getBlacklist(), listType="Blacklist")
def blacklistView(): return render_template('list.html', rules=db.getBlacklist(), status=["default", "none"], listType="Blacklist")