nomadro/apps/miniprogram/scripts/_audit_verify_display.py
eric 4fd2e574c1 Soften audit-sensitive copy for store review and fix weapp real-device nav icons.
Keep original link titles in encoded *Origin fields; soft-sanitize booklet/VIP display for XHS/weapp/tt; export PNG icons for WeChat Image on device.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-30 15:57:10 +08:00

94 lines
2.4 KiB
Python

# -*- coding: utf-8 -*-
"""Verify audit soft-copy cleared sensitive display strings."""
from __future__ import annotations
import json
import re
import sys
import zipfile
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
BADS = [
"科学上网",
"加密货币",
"交易所",
"U卡",
"无人直播",
"云手机",
"地理套利",
"刷量",
"刷粉",
"虚拟货币",
"USDT",
"赚美金",
]
def scrub_links(data: dict) -> str:
def scrub(o):
if isinstance(o, dict):
return {
k: scrub(v)
for k, v in o.items()
if not str(k).endswith("Origin") and k != "_auditNote"
}
if isinstance(o, list):
return [scrub(x) for x in o]
return o
return json.dumps(scrub(data), ensure_ascii=False)
def check_text(label: str, text: str) -> int:
fails = 0
print("==", label)
for b in BADS:
c = text.count(b)
if c:
print(" FAIL", b, c)
fails += 1
if fails == 0:
print(" OK all")
return fails
def main() -> int:
fails = 0
for rel in ("src/data/links.json", "tt/src/data/links.json"):
p = ROOT / rel
fails += check_text(str(p), scrub_links(json.loads(p.read_text(encoding="utf-8"))))
skip_re = re.compile(r"原文|SoT|过审|audit soft")
for rel in (
"src/data/nomadCodeBook.ts",
"src/data/coverBook.ts",
"tt/src/data/nomadCodeBook.ts",
"tt/src/data/coverBook.ts",
"src/pages/vip/index.tsx",
"tt/src/pages/vip/index.tsx",
):
p = ROOT / rel
lines = [ln for ln in p.read_text(encoding="utf-8").splitlines() if not skip_re.search(ln)]
fails += check_text(str(p), "\n".join(lines))
zpath = ROOT / "xhs/dist/nomadro-xhs-portal.zip"
if zpath.exists():
with zipfile.ZipFile(zpath) as z:
blob = b"".join(
z.read(n) for n in z.namelist() if not n.endswith((".webp", ".png", ".jpg", ".gif"))
).decode("utf-8", "ignore")
fails += check_text(str(zpath), blob)
else:
print("MISS", zpath)
fails += 1
cover = (ROOT / "src/data/coverBook.ts").read_text(encoding="utf-8")
m = re.search(r'"title":\s*"([^"]+)"', cover)
print("cover.title =", m.group(1) if m else "?")
return 1 if fails else 0
if __name__ == "__main__":
sys.exit(main())