执行 Ruff 安全自动修复
This commit is contained in:
@@ -31,10 +31,10 @@ from pyvm.algorithm import (
|
||||
build_plaintext,
|
||||
derive_key1_from_key16,
|
||||
generate_encrypt_msg_offline,
|
||||
) # noqa: E402
|
||||
from pyvm.login_profile import midas_login_params # noqa: E402
|
||||
from pyvm.payment_errors import describe_payment_failure # noqa: E402
|
||||
from pyvm.protocol import ( # noqa: E402
|
||||
)
|
||||
from pyvm.login_profile import midas_login_params
|
||||
from pyvm.payment_errors import describe_payment_failure
|
||||
from pyvm.protocol import (
|
||||
DEFAULT_ORDER_PF,
|
||||
GOODS_USER_AGENT,
|
||||
PAY_APPID,
|
||||
@@ -450,7 +450,6 @@ def cmd_check_only(session_path: Path, out_dir: Path) -> int:
|
||||
from pyvm.order_status import (
|
||||
completion_summary,
|
||||
get_official_orders,
|
||||
is_finished,
|
||||
)
|
||||
|
||||
session = load_json(session_path)
|
||||
@@ -697,7 +696,7 @@ def main() -> int:
|
||||
out_dir, fields, int(fp.get("device_fp_length", 0)), plaintext_length
|
||||
)
|
||||
body = urllib.parse.urlencode(fields)
|
||||
from pyvm.order_status import order_completion_states, get_official_orders
|
||||
from pyvm.order_status import get_official_orders, order_completion_states
|
||||
|
||||
# 尽量在发起支付前建立基线,缩小极快支付造成的检测窗口;失败不阻塞支付,付款码生成后重试。
|
||||
baseline_document = None
|
||||
|
||||
@@ -17,8 +17,8 @@ from pathlib import Path
|
||||
from urllib.error import HTTPError
|
||||
from urllib.parse import urlencode
|
||||
from urllib.request import (
|
||||
HTTPRedirectHandler,
|
||||
HTTPCookieProcessor,
|
||||
HTTPRedirectHandler,
|
||||
Request,
|
||||
build_opener,
|
||||
)
|
||||
@@ -43,7 +43,7 @@ USER_AGENT = (
|
||||
class NoRedirect(HTTPRedirectHandler):
|
||||
"""Keep OAuth redirects visible while CookieJar receives Set-Cookie headers."""
|
||||
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl): # noqa: D401
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||
return None
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ def g_tk(p_skey: str) -> int:
|
||||
|
||||
|
||||
def parse_poll(body: str) -> tuple[int, str]:
|
||||
match = re.search(r"ptuiCB\((.*)\)", body, re.S)
|
||||
match = re.search(r"ptuiCB\((.*)\)", body, re.DOTALL)
|
||||
if not match:
|
||||
raise ValueError("QQ 二维码轮询响应缺少 ptuiCB")
|
||||
values = re.findall(r"'([^']*)'", match.group(1))
|
||||
|
||||
@@ -20,8 +20,8 @@ from pathlib import Path
|
||||
from urllib.error import HTTPError
|
||||
from urllib.parse import urlencode
|
||||
from urllib.request import (
|
||||
HTTPRedirectHandler,
|
||||
HTTPCookieProcessor,
|
||||
HTTPRedirectHandler,
|
||||
Request,
|
||||
build_opener,
|
||||
)
|
||||
@@ -42,7 +42,7 @@ USER_AGENT = (
|
||||
class NoRedirect(HTTPRedirectHandler):
|
||||
"""保留 OAuth 回调的 302 和 Set-Cookie。"""
|
||||
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl): # noqa: D401
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||
return None
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ def extract_uuid(page: str) -> str:
|
||||
r"connect/qrcode/([A-Za-z0-9_-]{8,64})",
|
||||
r"uuid=([A-Za-z0-9_-]{8,64})",
|
||||
):
|
||||
match = re.search(pattern, page, re.I)
|
||||
match = re.search(pattern, page, re.IGNORECASE)
|
||||
if match:
|
||||
return match.group(1)
|
||||
raise ValueError("微信授权页未找到二维码 UUID")
|
||||
|
||||
@@ -18,7 +18,7 @@ from curl_cffi import requests
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from pyvm.login_profile import midas_login_params # noqa: E402
|
||||
from pyvm.login_profile import midas_login_params
|
||||
|
||||
YYB_APP_ID = 52575843
|
||||
SOURCE_ID = "24292013"
|
||||
|
||||
@@ -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