Exemplo n.º 1
0
    def post(self):
        """
        Add

        Puts a single or multiple CPE(s) into the blacklist.
        Passing a single request body schema adds a single entry into the whitelist. Combining multiple request body
        schemas into a list adds multiple entries into the whitelist
        """
        if not request.is_json:
            wl.abort(400, "Missing JSON in request")

        if isinstance(request.json, list):
            ret_val = defaultdict(str)
            for each in request.json:
                cpe = each.get("cpe", None)
                t_type = each.get("type", None)
                comments = each.get("comments", None)
                if not cpe:
                    wl.abort(400, "Missing cpe parameter in request body")
                if not t_type:
                    wl.abort(400, "Missing type parameter in request body")

                ret_val[cpe] = insertBlacklist(cpe, t_type, comments)

            ret_val = json.dumps(dict(ret_val))

        else:
            cpe = request.json.get("cpe", None)
            t_type = request.json.get("type", None)
            comments = request.json.get("comments", None)
            if not cpe:
                wl.abort(400, "Missing cpe parameter in request body")
            if not t_type:
                wl.abort(400, "Missing type parameter in request body")

            ret_val = insertBlacklist(cpe, t_type, comments)

        return {"message": ret_val}
Exemplo n.º 2
0
 def api_admin_add_blacklist(self):
     return bl.insertBlacklist(request.form['cpe'], request.form['type'])
Exemplo n.º 3
0
 def api_admin_add_blacklist(self):
     return bl.insertBlacklist(request.form["cpe"], request.form["type"])
Exemplo n.º 4
0
 def api_admin_add_blacklist(self):
   return bl.insertBlacklist(request.form['cpe'], request.form['type'])