def post(self): """ Add Puts a single or multiple CPE(s) into the whitelist. 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] = insertWhitelist(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 = insertWhitelist(cpe, t_type, comments) return {"message": ret_val}
def api_admin_add_whitelist(self): return wl.insertWhitelist(request.form['cpe'], request.form['type'])
def api_admin_add_whitelist(self): return wl.insertWhitelist(request.form["cpe"], request.form["type"])
def api_admin_add_whitelist(self): return wl.insertWhitelist(request.form['cpe'], request.form['type'])