From ff17b4ca407e18663badd048afb5df4e00855384 Mon Sep 17 00:00:00 2001 From: therealsama <263038098+therealsama@users.noreply.github.com> Date: Thu, 11 Jun 2026 16:36:02 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20harden=20security=20=E2=80=94=20meta=20C?= =?UTF-8?q?SP,=20security.txt,=20Firebase=20WS=20transport?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub Pages can't set response headers, so this is done at the static layer: - vite.config.js: build-time Content-Security-Policy. script-src avoids 'unsafe-inline' by hashing every executable inline script post-transform (inert application/ld+json blocks are skipped — script-src doesn't govern them); connect-src allows Algolia + Firebase (incl. wss://, via the *.firebaseio.com wildcard required by RTDB's dynamic shard hosts). Throws if the anchor is missing. Intentionally no upgrade-insecure-requests (it breaks the WebKit preview e2e and buys nothing on HTTPS-only Pages). - vite.config.js: after injecting the CSP, re-parse the final HTML with jsdom (an independent parser, not the extraction regex) and fail the build if any executable inline script lacks a matching hash — closes the regex's " src=" blind spot and guards against future plugins injecting unhashed scripts. - vite.config.js: emit /.well-known/security.txt (RFC 9116) with a build-time Expires (+6 months) so it can't silently go stale. - src/api/hnSdk.ts: pin Firebase RTDB to WebSockets. Its long-poll fallback is JSONP