--
This commit is contained in:
@@ -11,7 +11,7 @@ import httpx
|
|||||||
CACHE_DIR = Path.cwd() / "databases" / "hsts_preload_cache"
|
CACHE_DIR = Path.cwd() / "databases" / "hsts_preload_cache"
|
||||||
CACHE_TTL = 24 * 60 * 60
|
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"
|
FIREFOX_URL = "https://hg.mozilla.org/mozilla-central/raw-file/tip/security/manager/ssl/nsSTSPreloadList.inc"
|
||||||
|
|
||||||
PRELOAD_BROWSERS = ["chrome", "firefox", "edge", "ie"]
|
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:
|
async def _fetch_chrome_list(timeout: float = 60.0) -> dict[str, bool] | None:
|
||||||
"""Return mapping: host -> include_subdomains, or None on fetch/parse error.
|
"""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.
|
|
||||||
"""
|
|
||||||
cache = _cache_path("chrome")
|
cache = _cache_path("chrome")
|
||||||
if _cache_fresh(cache):
|
if _cache_fresh(cache):
|
||||||
try:
|
try:
|
||||||
@@ -57,11 +53,7 @@ async def _fetch_chrome_list(timeout: float = 60.0) -> dict[str, bool] | None:
|
|||||||
resp = await client.get(CHROME_URL)
|
resp = await client.get(CHROME_URL)
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
return None
|
return None
|
||||||
import base64
|
raw = resp.text
|
||||||
content = resp.content
|
|
||||||
if content.startswith(b")]}'\n"):
|
|
||||||
content = content[5:]
|
|
||||||
raw = base64.b64decode(content).decode("utf-8", errors="replace")
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
# Strip // comments (json with comments) and parse a loose subset
|
# Strip // comments (json with comments) and parse a loose subset
|
||||||
|
|||||||
Reference in New Issue
Block a user