Admin-only: download any user's vault file.
(username: str)
| 16632 | try: |
| 16633 | data = request.get_json(silent=True) or {} |
| 16634 | filename = _safe_face_detector_filename(data.get("filename") or "") |
| 16635 | filedata = (data.get("filedata") or "").strip() |
| 16636 | m = re.match(r"^data:((?:image/(?:png|jpeg|jpg|webp))|(?:video/(?:webm|mp4)));base64,(.+)$", filedata, flags=re.I | re.S) |
| 16637 | if not m: |
| 16638 | return jsonify({"ok": False, "error": "invalid_data"}), 400 |
| 16639 | payload = base64.b64decode(m.group(2), validate=True) |
| 16640 | if not payload or len(payload) > (35 * 1024 * 1024): |
| 16641 | return jsonify({"ok": False, "error": "invalid_size"}), 400 |
| 16642 | out_path = os.path.join(FACE_DETECTOR_DIR, filename) |
| 16643 | with open(out_path, "wb") as f: |
| 16644 | f.write(payload) |
| 16645 | return jsonify({"ok": True, "path": out_path}) |
| 16646 | except Exception as e: |
| 16647 | log.exception("Face detector save failed: %s", e) |
| 16648 | return jsonify({"ok": False, "error": "save_failed"}), 500 |
| 16649 | |
| 16650 | |
| 16651 | @app.route("/bounty") |
| 16652 | |
| 16653 | @login_required |
| 16654 | def bounty(): |
| 16655 | """Admin page for adding/editing/removing profiler bounties.""" |
| 16656 | require_admin() |
| 16657 | q = (request.args.get("q") or "").strip() |
| 16658 | selected_id = request.args.get("eid", type=int) |
| 16659 | |
| 16660 | entries: List[Dict[str, Any]] = [] |
| 16661 | if q: |
| 16662 | entries = profiler_all_entries_for_bounty(q)[:100] |
| 16663 | |
| 16664 | selected = None |
| 16665 | if selected_id is not None: |
| 16666 | # fetch selected entry even when it is not shown because no search results are displayed by default |
| 16667 | for e in (entries + profiler_all_entries_for_bounty("")): |
| 16668 | if int(e["id"]) == int(selected_id): |
| 16669 | selected = e |
| 16670 | break |
| 16671 | |
| 16672 | class Obj: |
| 16673 | def __init__(self, d): |
| 16674 | self.__dict__.update(d) |
| 16675 | |
| 16676 | selected_bounty_value = "" |
| 16677 | selected_reason_value = "" |
| 16678 | selected_has_bounty = False |
nothing calls this directly
no test coverage detected