Example #1
0
    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"})
Example #2
0
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()})
Example #3
0
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()})
Example #4
0
 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()
     })
Example #5
0
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"})
Example #6
0
 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")
Example #7
0
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})
Example #8
0
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()})
Example #9
0
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()})
Example #10
0
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()})
Example #11
0
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})
Example #12
0
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})
Example #13
0
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})
Example #14
0
def blacklistView():
    return render_template('list.html', rules=dbLayer.getBlacklist(), status=["default", "none"], listType="Blacklist")
Example #15
0
 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")
Example #16
0
 def api_admin_blacklist(self):
     return db.getBlacklist()
Example #17
0
def blacklistView():
    return render_template('list.html',
                           rules=db.getBlacklist(),
                           listType="Blacklist")
Example #18
0
def blacklistView():
    return render_template('list.html', rules=db.getBlacklist(), listType="Blacklist")
Example #19
0
def blacklistView():
    return render_template('list.html',
                           rules=db.getBlacklist(),
                           status=["default", "none"],
                           listType="Blacklist")
Example #20
0
 def api_admin_blacklist(self):
   return db.getBlacklist()