[117] CSP: strikte Content-Security-Policy für Tauri, Electron und Web-Build; Rich-Text-Stilwerte bereinigt

Eine Quelle scripts/csp.cjs; tauri.conf.json (devCsp null), Electron-Header (nur gepackt),
Meta-Tag im Vite-Build. Farbe/Schriftname/Ausrichtung/Zeilenhöhe aus Dateien per Positivliste.
Tests: csp.test.ts, renderHtml.test.ts, e2e/csp.spec.ts.
This commit is contained in:
Claude committed 2026-11-03 17:37:56 +00:00
1 parent bb3d9ede38
commit 61446b3edb
9 files changed
+215 -9

No files matched your search

+11 -1
View File
@@ -6,6 +6,7 @@
const { app, BrowserWindow, Menu, ipcMain } = require("electron");
const path = require("node:path");
const { buildCsp } = require("./csp.cjs");
// Randloses App-Fenster wie chromium-shell.sh (--app=…): keine native
// Menüleiste (File/Edit/View/Window), kein Fensterrahmen. Minimieren/
@@ -66,7 +67,16 @@ ipcMain.handle("window:is-maximized", (event) => {
return BrowserWindow.fromWebContents(event.sender)?.isMaximized() ?? false;
});
app.whenReady().then(createWindow);
app.whenReady().then(() => {
// [117] CSP als Antwort-Header — nur gepackt: der Dev-Server (Vite HMR) braucht Inline-Skripte.
if (!isDev) {
const { session } = require("electron");
session.defaultSession.webRequest.onHeadersReceived((details, cb) => {
cb({ responseHeaders: { ...details.responseHeaders, "Content-Security-Policy": [buildCsp()] } });
});
}
createWindow();
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();