#!/usr/bin/env python3 # -*- coding: utf-8 -*- """观澜云端版 · 方案 A 中文单文件 (用户裁 2026-09-07 "中文版上云走 A: 脱敏面孔"): 部署包页 → 脱敏 → 云端契约段 → 回扫 → 打包目录. 流程 (可复跑, 每步有证据): 1. 挖空 base64 图片块 (`data:…;base64,…` → 占位符; 字节不含可识别文本, 不参与扫描/替换, 完后回填) 2. src/windscada/deid_public.scrub 全局一致替换 (场名/OEM/机型/业主/供应商/文档名/内部系统名) 3. 注入云端契约段 (scripts/guanlan_portal_inject_claims.py, 数据源 = 脱敏面孔 cloud/portal_claims.json, 与内部契约同 sha) 4. 回扫: deid_public.LEAK_RE + guanlan_cloud_face.EXTRA_RE (绝对路径/邮箱/手机/身份证/坐标/密钥) 任一命中 → 不出件 (exit 2); windscada_cloud_pack.GATES 只报 (中文版口径: 机组号/台数/厂商名待裁); 重复 id / 锚点缺目标 任一 → 不出件 5. 打包目录 cloud/_pkg/ (index.html + 五个脱敏面孔 JSON/MD + SHA256SUMS + README) —— 目录 gitignored (20 MB), 只登记 sha 于 cloud/scan_report_page.md 铁律: "替换过了"不算数, 只有回扫零命中算; 上传仍须过 scripts/deploy_gate_check.py --farm rudong (PB-1) 与用户显式批准, 本脚本不上传. 用法: build [--src ] | check """ import argparse, datetime as dt, hashlib, json, re, subprocess, sys, time from collections import Counter from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "src")); sys.path.insert(0, str(ROOT / "scripts")) from windscada import deid_public as DP # noqa: E402 import guanlan_cloud_face as CF # noqa: E402 import windscada_cloud_pack as CP # noqa: E402 import guanlan_portal_inject_claims as INJ # noqa: E402 CLOUD = ROOT / "outputs/rudong/guanlan/cloud"; BUILD = CLOUD / "_build"; PKG = CLOUD / "_pkg"; REPORT = CLOUD / "scan_report_page.md" DEF_SRC = Path.home() / "Desktop/观澜中文系统_详细分析_第一版部署包_20260906 2/观澜中文系统_详细分析.html" FACE_FILES = ("portal_claims.json", "detail_cards.json", "qa_refs.json", "report_summary.md", "claims_public.json", "cloud_manifest.json") _B64 = re.compile(r"data:[a-zA-Z0-9.+/-]+;base64,[A-Za-z0-9+/=]+") sha = lambda b: hashlib.sha256(b).hexdigest() _LOCAL = re.compile(r"https?://(?:127\.0\.0\.1|localhost):(\d+)/([^\"'\s<>]*)") _NOTE = '

本模块 (本机服务) 仅离线版提供, 云端未部署。

' def cloud_links(t: str) -> str: """本机离线地址 → 云端地址 (2026-09-07 用户报 "云上三维拆装打不开": 中文页"三维拆装"按钮把 iframe 指向 127.0.0.1:54292, 云端点了必死). 覆盖 href / iframe src / 内联 JS 单引号 / srcdoc 转义 (") 四种写法: 54292 unit-workbench.html?component=X → /turbine-explorer?component=X (云端三维页, 实测支持 component 参数) 其余本机端口 (8020 CMS / 8791·8792 仿真 / 8033 / 18084 治理清单) 云端未部署 → about:blank; 去 href 变不可点 + 提示;