Strips sensitive tokens, secrets, and credentials from logs and strings.
# Source: https://github.com/Diabloluo/hermes-hud | License: MIT | Copyright 2026 Hermes HUD contributors
# Provided via justclaw.it.com; keep this notice with the code.
"""Hermes HUD — 脱敏工具。
日志、错误摘要、投递目标在进入 telemetry.db / WebSocket / API 之前必须经过这里。
规则设计(顺序即安全):
1. 模式规则先行:Bearer/JWT/sk-*/Telegram bot token/长 hex/base64 —— 整体替换,
确保"先匹配掉 Bearer 字样却把真正 token 留在后面"这类截断泄漏不会发生。
2. 键值规则:
a. 引号值(JSON quoted keys):"token":"xxxx" / 'client_secret': 'xxxx' / key="xxx"
b. 无引号值:token=xxx / authorization: xxx(值到空白/分隔符为止)
3. URL query 中的 token/key/secret/password/auth/ticket 参数。
4. Authorization/Cookie 整行兜底。
不读取 .env / auth.json,只对已经拿到的字符串做替换。
"""
from __future__ import annotations
import re
from pathlib import Path
REDACTED = "[REDACTED]"
# ----------------------------------
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key