执行 Ruff 安全自动修复
This commit is contained in:
@@ -32,7 +32,7 @@ WORKER_KEY = os.environ.get("YYB_WORKER_KEY", "")
|
||||
_jobs: dict[str, dict] = {}
|
||||
_lock = threading.Lock()
|
||||
|
||||
from pyvm.payment_errors import describe_payment_failure # noqa: E402
|
||||
from pyvm.payment_errors import describe_payment_failure
|
||||
|
||||
|
||||
def _payment_failure_message(job: dict, phase: str, fallback: str) -> str:
|
||||
@@ -81,13 +81,13 @@ def _safe_log(job: dict, line: str) -> None:
|
||||
clean = re.sub(r"HOLD_[A-Za-z0-9_-]+", "[订单已隐藏]", clean)
|
||||
clean = re.sub(r"(订单\s*[::]\s*)\S+", r"\1[订单已隐藏]", clean)
|
||||
clean = re.sub(
|
||||
r"(?:token|openid|openkey|cookie)=\S+", "[敏感字段已隐藏]", clean, flags=re.I
|
||||
r"(?:token|openid|openkey|cookie)=\S+", "[敏感字段已隐藏]", clean, flags=re.IGNORECASE
|
||||
)
|
||||
clean = re.sub(
|
||||
r"(?:pay_token|web_token|anti_token|session_id|sessionid)\s*[:= ]\s*\S+",
|
||||
"[敏感字段已隐藏]",
|
||||
clean,
|
||||
flags=re.I,
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
timestamp = time.strftime("%H:%M:%S")
|
||||
with _lock:
|
||||
@@ -523,7 +523,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
value = self.headers.get("Authorization", "")
|
||||
return value == f"Bearer {WORKER_KEY}"
|
||||
|
||||
def do_POST(self) -> None: # noqa: N802
|
||||
def do_POST(self) -> None:
|
||||
if not self._authorized():
|
||||
return self._json(401, {"detail": "未授权"})
|
||||
path = urlparse(self.path).path.strip("/").split("/")
|
||||
@@ -687,7 +687,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
except Exception as exc: # noqa: BLE001
|
||||
return self._json(500, {"detail": str(exc)})
|
||||
|
||||
def do_GET(self) -> None: # noqa: N802
|
||||
def do_GET(self) -> None:
|
||||
if urlparse(self.path).path == "/health":
|
||||
return self._json(200, {"status": "ok"})
|
||||
if not self._authorized():
|
||||
|
||||
Reference in New Issue
Block a user