def report(request: Request, name: str): def load_value_of(key) -> str: may_val = load(key) or {} return may_val if "report_format_editor" in request.accepted_media_type: images = load_value_of("{}images".format(name)) return Response({ "template": load_value_of("{}html_template".format(name)), "vulnerability_report": load(name), "pdf_css": load_value_of("{}pdf_css".format(name)), "html_css": load_value_of("{}html_css".format(name)), "images": images, }) data = load(name) if request.GET.get('without_overview'): # remove charts data.pop('overview', None) if request.META.get('HTTP_ACCEPT') == "application/xml": # XML needs exactly one root data = {'report': data} return Response(data)
def report(request: Request, name: str): def load_value_of(key) -> str: may_val = load(key) or {} return may_val if "report_format_editor" in request.accepted_media_type: images = load_value_of("{}images".format(name)) return Response( { "template": load_value_of("{}html_template".format(name)), "vulnerability_report": load(name), "pdf_css": load_value_of("{}pdf_css".format(name)), "html_css": load_value_of("{}html_css".format(name)), "images": images, } ) data = load(name) data["pheme_version"] = int("".join(filter(str.isdigit, __version__))) if request.GET.get("without_overview"): # remove charts data.pop("overview", None) if request.META.get("HTTP_ACCEPT") == "application/xml": # XML needs exactly one root data = {"report": data} return Response(data)
def store_cache(request): key = request.data.get("key", "unknown") data = request.data.get("value") if request.data.get("append"): if isinstance(data, dict): cached = load(key) or {} cached[data.get("name", "unknown")] = data.get("content") data = cached name = store(key, data, id_generator=str) return Response(name)
def store_cache(request): key = request.data.get("key", "unknown") data = request.data.get('value') if request.data.get('append'): if isinstance(data, dict): cached = load(key) or {} cached[data.get('name', 'unknown')] = data.get('content') data = cached name = store(key, data, id_generator=str) return Response(name)
def load_value_of(key) -> str: may_val = load(key) or {} return may_val
def load_cache(request, key): return Response(load(key))