#!/usr/bin/env python3 from pathlib import Path import re import zipfile root = Path(__file__).resolve().parents[1] / "release" text = "\n".join( p.read_text(encoding="utf-8") for p in root.rglob("*") if p.suffix in {".html", ".js", ".css"} ) checks = [ ("inline script", r"]*\bsrc=)[^>]*>"), ("inline handler", r"\son\w+\s*="), ("fetch", r"\bfetch\s*\("), ("XHR", r"\bXMLHttpRequest\b"), ("eval", r"\beval\s*\("), ("new Function", r"\bnew\s+Function\s*\("), ("esm import", r"(^|\n)\s*import\s"), ("esm export", r"(^|\n)\s*export\s"), ("type=module", r"type=['\"]module['\"]"), ("external url attr", r"(?:src|href)\s*=\s*['\"]https?:"), ("aspect-ratio", r"aspect-ratio\s*:"), ("dvh", r"\bdvh\b"), ("color-mix", r"color-mix\s*\("), ] print("--- static scan ---") failed = 0 for name, rx in checks: m = re.search(rx, text, re.I | re.M) print(("FAIL" if m else "OK "), name) if m: failed += 1 zpath = Path(__file__).resolve().parents[1] / "dist" / "yidu-xingqiu-xhs-tool.zip" with zipfile.ZipFile(zpath) as z: names = z.namelist() print("zip entries:", names) print("index at root:", "index.html" in names and not any("/" in n and n.endswith("index.html") for n in names if n != "index.html" or True)) print("zip KB:", round(zpath.stat().st_size / 1024, 1)) raise SystemExit(1 if failed else 0)