nomadro/apps/ebook/redmini/scripts/static_scan.py
eric d93a355fd5 Migrate navmini/ebook/nomadweb into apps/ as same-origin portal subpaths.
Shield external portal jumps (keep EXTERNAL_* for later), serve /nav from static build, and proxy /book + /community to vertical Next apps with Caddy notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 03:30:34 -05:00

42 lines
1.4 KiB
Python

#!/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"<script(?![^>]*\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)