fix(network): 禁止公网查询持久化缓存及会话数据
This commit is contained in:
+19
-2
@@ -5,6 +5,7 @@ import os
|
||||
import signal
|
||||
from pathlib import Path
|
||||
import plistlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -55,7 +56,7 @@ CHECKS.update({
|
||||
"SettingsWindowChecks": ["kymo/Core/Services/SettingsPresentation.swift", "kymo/Features/Settings/SettingsWindowLifecycle.swift"],
|
||||
"PanelWindowChecks": ["kymo/Features/MenuBar/MenuPanelController.swift", "kymo/Features/MenuBar/PanelLayout.swift",
|
||||
"kymo/UI/Components/IntervalControl.swift"],
|
||||
"SandboxNetworkChecks": [],
|
||||
"SandboxNetworkChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
|
||||
})
|
||||
GUI = {"NativeMetricDrawingChecks", "NativeProcessTableChecks", "LanguageScopeChecks", "SettingsWindowChecks", "PanelWindowChecks"}
|
||||
NETWORK = {"SandboxNetworkChecks"}
|
||||
@@ -103,6 +104,19 @@ def test_bundle(work, name, executable, host_entitlements=None, resources=None):
|
||||
return app
|
||||
|
||||
|
||||
|
||||
def clean_test_container(bundle):
|
||||
# Only the random bundle ID generated by this runner; never the real app's data.
|
||||
identifier = plistlib.loads((bundle / "Contents/Info.plist").read_bytes())["CFBundleIdentifier"]
|
||||
if not re.fullmatch(r"cn\.airnan\.kymo\.checks\.[a-f0-9]{32}", identifier):
|
||||
raise RuntimeError("Refusing to clean an unrecognized test container")
|
||||
container = Path.home() / "Library/Containers" / identifier
|
||||
if container.is_symlink():
|
||||
raise RuntimeError("Refusing to follow a test-container symlink")
|
||||
if container.exists():
|
||||
shutil.rmtree(container)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--app", type=Path, help="Use an already built app instead of building")
|
||||
@@ -176,7 +190,10 @@ def main():
|
||||
raise RuntimeError(f"{name} did not report success\n" + (error.read_text() if error.exists() else ""))
|
||||
elif name in NETWORK or name == "NetworkAddressChecks":
|
||||
bundle = test_bundle(work, name, executable, host_entitlements)
|
||||
run([bundle / "Contents/MacOS" / name], timeout=15)
|
||||
try:
|
||||
run([bundle / "Contents/MacOS" / name], timeout=15)
|
||||
finally:
|
||||
clean_test_container(bundle)
|
||||
else:
|
||||
extra = [app] if name in {"LocalizationChecks", "PanelAssetChecks"} else []
|
||||
if name == "CodeIdentityChecks":
|
||||
|
||||
Reference in New Issue
Block a user