This commit is contained in:
2026-04-19 20:37:02 +09:00
parent 50e9728202
commit e4812ae79e
@@ -11,7 +11,7 @@ import httpx
CACHE_DIR = Path.cwd() / "databases" / "hsts_preload_cache"
CACHE_TTL = 24 * 60 * 60
CHROME_URL = "https://chromium.googlesource.com/chromium/src/+/refs/heads/main/net/http/transport_security_state_static.json?format=TEXT"
CHROME_URL = "https://raw.githubusercontent.com/chromium/chromium/main/net/http/transport_security_state_static.json"
FIREFOX_URL = "https://hg.mozilla.org/mozilla-central/raw-file/tip/security/manager/ssl/nsSTSPreloadList.inc"
PRELOAD_BROWSERS = ["chrome", "firefox", "edge", "ie"]
@@ -38,11 +38,7 @@ def _cache_fresh(p: Path) -> bool:
async def _fetch_chrome_list(timeout: float = 60.0) -> dict[str, bool] | None:
"""Return mapping: host -> include_subdomains, or None on fetch/parse error.
Chromium's list is served base64-encoded when ?format=TEXT.
Some Gitiles deployments prepend a )]}' XSSI-prevention prefix.
"""
"""Return mapping: host -> include_subdomains, or None on fetch/parse error."""
cache = _cache_path("chrome")
if _cache_fresh(cache):
try:
@@ -57,11 +53,7 @@ async def _fetch_chrome_list(timeout: float = 60.0) -> dict[str, bool] | None:
resp = await client.get(CHROME_URL)
if resp.status_code != 200:
return None
import base64
content = resp.content
if content.startswith(b")]}'\n"):
content = content[5:]
raw = base64.b64decode(content).decode("utf-8", errors="replace")
raw = resp.text
except Exception:
return None
# Strip // comments (json with comments) and parse a loose subset