Publish reviewed history-free open-source snapshot (2026-10-12)
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import plistlib
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
EXPECTED = [
|
||||
"project.yml",
|
||||
"App/AppState.swift",
|
||||
"App/ContentView.swift",
|
||||
"App/PlatformAPI.swift",
|
||||
"App/VPNController.swift",
|
||||
"PacketTunnel/PacketTunnelProvider.swift",
|
||||
"PacketTunnel/XrayBridge.swift",
|
||||
"Shared/Models.swift",
|
||||
"Shared/TunnelConfigurationBuilder.swift",
|
||||
"Shared/NetworkAddress.swift",
|
||||
"Tests/TunnelConfigurationBuilderTests.swift",
|
||||
"Tests/ClientConfigResponseTests.swift",
|
||||
"Shared/ConnectionAttemptPolicy.swift",
|
||||
"Tests/ConnectionAttemptPolicyTests.swift",
|
||||
]
|
||||
|
||||
|
||||
def require(condition: bool, message: str) -> None:
|
||||
if not condition:
|
||||
raise RuntimeError(message)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for relative in EXPECTED:
|
||||
require((ROOT / relative).is_file(), f"缺少文件:{relative}")
|
||||
|
||||
for relative in ("App/Info.plist", "PacketTunnel/Info.plist", "App/UCVLZonghengjia.entitlements", "PacketTunnel/PacketTunnel.entitlements"):
|
||||
with (ROOT / relative).open("rb") as stream:
|
||||
value = plistlib.load(stream)
|
||||
if relative.endswith("entitlements"):
|
||||
require(
|
||||
"packet-tunnel-provider" in value.get("com.apple.developer.networking.networkextension", []),
|
||||
f"Network Extension 权限缺失:{relative}",
|
||||
)
|
||||
|
||||
project = (ROOT / "project.yml").read_text(encoding="utf-8")
|
||||
version_match = re.search(r'MARKETING_VERSION:\s*"(\d+\.\d+\.\d+)"', project)
|
||||
require(version_match is not None, "缺少规范的源码版本号")
|
||||
source_version = version_match.group(1)
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
require(f"{source_version} 源码候选版" in readme.splitlines()[0]
|
||||
and f"版本 `{source_version}`" in readme, "README 与工程版本不一致")
|
||||
require("cn.toplc.zonghengjia.PacketTunnel" in project, "Packet Tunnel Bundle ID 缺失")
|
||||
require('iOS: "15.0"' in project, "iOS 最低版本与验收基线不一致")
|
||||
|
||||
app_state = (ROOT / "App/AppState.swift").read_text(encoding="utf-8")
|
||||
api = (ROOT / "App/PlatformAPI.swift").read_text(encoding="utf-8")
|
||||
tunnel = (ROOT / "PacketTunnel/PacketTunnelProvider.swift").read_text(encoding="utf-8")
|
||||
require("selectedNodeID" not in app_state, "客户端仍暴露节点选择")
|
||||
require('URLQueryItem(name: "node", value: "auto")' in api, "未启用后台自动选节点")
|
||||
require("verifyProxyEgress" in api and "verifyProxyEgress" in app_state, "缺少出口验证")
|
||||
require("resolveIPv4Address" in tunnel and "excludedRoutes" in tunnel, "缺少节点域名防回环处理")
|
||||
require("dns.alidns.com/resolve" in api and "doh.pub/resolve" in api, "缺少国内 DoH 真实地址解析")
|
||||
require("NetworkAddress.isPublicIPv4" in api and "NetworkAddress.isPublicIPv4" in tunnel, "未拒绝 Fake-IP/内网地址")
|
||||
require("response.gateway" in app_state and "configContract" in (ROOT / "Shared/Models.swift").read_text(encoding="utf-8"), "未兼容后台网关契约")
|
||||
require("vpn.status == .connected" in app_state, "出口验证后未复核系统 VPN 状态")
|
||||
require("ConnectionAttemptPolicy.decide" in app_state and "attemptedNode" in app_state,
|
||||
"未区分控制面、本地授权与节点出口故障")
|
||||
|
||||
secret_pattern = re.compile(
|
||||
r"(?i)(password|passwd|private[_-]?key)['\"]?\s*[:=]\s*['\"][^'\"]{4,}['\"]"
|
||||
)
|
||||
findings: list[str] = []
|
||||
for path in ROOT.rglob("*"):
|
||||
if not path.is_file() or any(part in {".git", "Vendor", "BuildArtifacts"} for part in path.parts):
|
||||
continue
|
||||
if path.suffix.lower() not in {".swift", ".yml", ".yaml", ".json", ".md", ".sh", ".py", ".plist"}:
|
||||
continue
|
||||
text = path.read_text(encoding="utf-8", errors="ignore")
|
||||
if secret_pattern.search(text):
|
||||
findings.append(str(path.relative_to(ROOT)))
|
||||
require(not findings, "疑似明文凭据:" + ", ".join(findings))
|
||||
|
||||
vendor_archive = ROOT / "Vendor/libxray-apple-cgo-v26.7.28.zip"
|
||||
vendor_result = "not-present"
|
||||
if vendor_archive.is_file():
|
||||
digest = hashlib.sha256(vendor_archive.read_bytes()).hexdigest()
|
||||
require(digest == "07f7ed7697277930e1c517755855950f594f41435b0dfc5917a66eea6278aeb9", "libXray 本地归档 SHA256 不匹配")
|
||||
vendor_result = digest
|
||||
|
||||
geo_files = [ROOT / "Resources/Geo/geoip.dat", ROOT / "Resources/Geo/geosite.dat"]
|
||||
geo_present = [path.is_file() for path in geo_files]
|
||||
require(all(geo_present) or not any(geo_present), "Geo data must be supplied as a complete pair")
|
||||
geo_status = "present-not-verified-by-source-audit" if all(geo_present) else "not-packaged"
|
||||
|
||||
report = {
|
||||
"result": "PASS",
|
||||
"source_version": source_version,
|
||||
"geo_data_status": geo_status,
|
||||
"geo_data_required_before_build_and_tunnel": True,
|
||||
"documentation_version_matches": True,
|
||||
"scope": "Source audit only; no Xcode compile, signing, IPA export, or iPhone tunnel acceptance",
|
||||
"automatic_node_selection": True,
|
||||
"egress_verification": ["api.openai.com", "chatgpt.com"],
|
||||
"domain_loop_prevention": True,
|
||||
"gateway_contract": 2,
|
||||
"legacy_backend_compatible": True,
|
||||
"network_extension_entitlement": True,
|
||||
"libxray_archive_sha256": vendor_result,
|
||||
}
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
raise SystemExit(main())
|
||||
except Exception as exc:
|
||||
print(json.dumps({"result": "FAIL", "error": str(exc)}, ensure_ascii=False, indent=2), file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
Reference in New Issue
Block a user