mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 16:59:43 +02:00
fix(csp): drop now-unused gesture CDN connect-src entries (self-hosted MediaPipe)
MediaPipe's wasm runtime + model are served same-origin from /gesture/, so the gesture CSP no longer needs https://cdn.jsdelivr.net / https://storage.googleapis .com in connect-src ('self' covers same-origin). Kept 'wasm-unsafe-eval' (script-src, WASM compile) and worker-src 'self' blob: (MediaPipe blob workers). Codeman's base jsdelivr entries (script/style/font-src) are unchanged — those aren't gesture's. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -155,14 +155,14 @@ export function registerAuthMiddleware(app: FastifyInstance, https: boolean): Au
|
|||||||
*/
|
*/
|
||||||
export function registerSecurityHeaders(app: FastifyInstance, https: boolean): void {
|
export function registerSecurityHeaders(app: FastifyInstance, https: boolean): void {
|
||||||
// Gesture-control overlay (opt-in via CODEMAN_GESTURE=1) runs MediaPipe, which
|
// Gesture-control overlay (opt-in via CODEMAN_GESTURE=1) runs MediaPipe, which
|
||||||
// needs WebAssembly eval and must fetch its wasm/model from the pinned CDNs.
|
// needs WebAssembly eval (script-src) and blob workers (worker-src). Its wasm
|
||||||
// Computed once; OFF by default so the production CSP is byte-for-byte unchanged.
|
// runtime + model are self-hosted under /gesture/ (same-origin, covered by
|
||||||
|
// 'self'), so no CDN connect-src entries are needed. OFF by default so the
|
||||||
|
// production CSP is byte-for-byte unchanged.
|
||||||
const gesture = process.env.CODEMAN_GESTURE === '1';
|
const gesture = process.env.CODEMAN_GESTURE === '1';
|
||||||
const scriptSrc =
|
const scriptSrc =
|
||||||
"script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net" + (gesture ? " 'wasm-unsafe-eval'" : '');
|
"script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net" + (gesture ? " 'wasm-unsafe-eval'" : '');
|
||||||
const connectSrc =
|
const connectSrc = "connect-src 'self' wss://api.deepgram.com";
|
||||||
"connect-src 'self' wss://api.deepgram.com" +
|
|
||||||
(gesture ? ' https://cdn.jsdelivr.net https://storage.googleapis.com' : '');
|
|
||||||
const workerSrc = gesture ? "; worker-src 'self' blob:" : '';
|
const workerSrc = gesture ? "; worker-src 'self' blob:" : '';
|
||||||
const csp =
|
const csp =
|
||||||
`default-src 'self'; ${scriptSrc}; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; ` +
|
`default-src 'self'; ${scriptSrc}; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; ` +
|
||||||
|
|||||||
Reference in New Issue
Block a user