Преглед изворни кода

fix(app): close remaining UI audit findings (#1632)

Neutralise spreadsheet formulas in the CSV export without touching negative numbers, check the logout response before redirecting, unsubscribe this device from push before revoking the session and keep local device overrides only in demo mode.

Self-host the three font families, drop the Google domains from the CSP, pin the landing scripts with SRI and copy the install commands from bundle constants.

Closes #1631
Nacho пре 1 месец
родитељ
комит
af594ad266

+ 1 - 6
app/index.html

@@ -11,12 +11,7 @@
     <meta name="apple-mobile-web-app-title" content="NetPulse" />
     <meta name="apple-mobile-web-app-title" content="NetPulse" />
     <link rel="icon" type="image/svg+xml" href="/logo.svg" />
     <link rel="icon" type="image/svg+xml" href="/logo.svg" />
     <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
     <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
-    <link rel="preconnect" href="https://fonts.googleapis.com" />
-    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
-    <link
-      href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap"
-      rel="stylesheet"
-    />
+    <link rel="stylesheet" href="/fonts/fonts.css" />
     <title>NetPulse</title>
     <title>NetPulse</title>
     <link rel="stylesheet" href="/src/splash.css" />
     <link rel="stylesheet" href="/src/splash.css" />
     <script src="/boot.js"></script>
     <script src="/boot.js"></script>

+ 82 - 0
app/public/fonts/fonts.css

@@ -0,0 +1,82 @@
+/* Self-hosted fonts (#1631 F-31). Latin subset, generated from the Google Fonts CSS. */
+
+@font-face {
+  font-family: 'Inter';
+  font-style: normal;
+  font-weight: 400;
+  font-display: swap;
+  src: url('/fonts/inter-3100e775.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Inter';
+  font-style: normal;
+  font-weight: 500;
+  font-display: swap;
+  src: url('/fonts/inter-3100e775.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Inter';
+  font-style: normal;
+  font-weight: 600;
+  font-display: swap;
+  src: url('/fonts/inter-3100e775.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'JetBrains Mono';
+  font-style: normal;
+  font-weight: 400;
+  font-display: swap;
+  src: url('/fonts/jetbrains-mono-83c005d4.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'JetBrains Mono';
+  font-style: normal;
+  font-weight: 500;
+  font-display: swap;
+  src: url('/fonts/jetbrains-mono-83c005d4.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'JetBrains Mono';
+  font-style: normal;
+  font-weight: 600;
+  font-display: swap;
+  src: url('/fonts/jetbrains-mono-83c005d4.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Space Grotesk';
+  font-style: normal;
+  font-weight: 500;
+  font-display: swap;
+  src: url('/fonts/space-grotesk-06408904.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Space Grotesk';
+  font-style: normal;
+  font-weight: 600;
+  font-display: swap;
+  src: url('/fonts/space-grotesk-06408904.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Space Grotesk';
+  font-style: normal;
+  font-weight: 700;
+  font-display: swap;
+  src: url('/fonts/space-grotesk-06408904.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}

BIN
app/public/fonts/inter-3100e775.woff2


BIN
app/public/fonts/jetbrains-mono-83c005d4.woff2


BIN
app/public/fonts/space-grotesk-06408904.woff2


+ 1 - 0
app/public/locales/en/translation.json

@@ -1735,6 +1735,7 @@
       "active": "Active session on this device",
       "active": "Active session on this device",
       "activeCaption": "You will have to enter the password again to sign in.",
       "activeCaption": "You will have to enter the password again to sign in.",
       "logout": "Sign out",
       "logout": "Sign out",
+      "logoutError": "Could not sign out. Your session is still active.",
       "title": "My profile",
       "title": "My profile",
       "demoActive": "Demo mode active",
       "demoActive": "Demo mode active",
       "demoCaption": "Local simulated data, no connection to your network.",
       "demoCaption": "Local simulated data, no connection to your network.",

+ 1 - 0
app/public/locales/es/translation.json

@@ -1735,6 +1735,7 @@
       "active": "Sesión activa en este dispositivo",
       "active": "Sesión activa en este dispositivo",
       "activeCaption": "Tendrás que volver a introducir la contraseña para entrar.",
       "activeCaption": "Tendrás que volver a introducir la contraseña para entrar.",
       "logout": "Cerrar sesión",
       "logout": "Cerrar sesión",
+      "logoutError": "No se pudo cerrar la sesión. Sigue activa.",
       "title": "Mi perfil",
       "title": "Mi perfil",
       "demoActive": "Modo demo activo",
       "demoActive": "Modo demo activo",
       "demoCaption": "Datos simulados locales, sin conexión a tu red.",
       "demoCaption": "Datos simulados locales, sin conexión a tu red.",

+ 23 - 2
app/src/data/push.ts

@@ -55,20 +55,41 @@ export async function postPushSubscribe(sub: PushSubscriptionPayload): Promise<b
 }
 }
 
 
 /** POST /api/push/unsubscribe. El resultado no bloquea la baja local. */
 /** POST /api/push/unsubscribe. El resultado no bloquea la baja local. */
-export async function postPushUnsubscribe(endpoint: string): Promise<boolean> {
+export async function postPushUnsubscribe(endpoint: string, redirectOn401 = true): Promise<boolean> {
   try {
   try {
     const res = await fetch('/api/push/unsubscribe', {
     const res = await fetch('/api/push/unsubscribe', {
       method: 'POST',
       method: 'POST',
       headers: { 'Content-Type': 'application/json' },
       headers: { 'Content-Type': 'application/json' },
       body: JSON.stringify({ endpoint }),
       body: JSON.stringify({ endpoint }),
     })
     })
-    if (res.status === 401) redirectLogin()
+    if (res.status === 401 && redirectOn401) redirectLogin()
     return res.ok // 204
     return res.ok // 204
   } catch {
   } catch {
     return false
     return false
   }
   }
 }
 }
 
 
+/**
+ * #1631 F-20: da de baja este navegador antes de revocar la sesión.
+ *
+ * Se llama desde el logout, con la cookie todavía válida, para que el servidor
+ * pueda borrar la fila. Si la llamada falla se elimina igualmente la
+ * suscripción local, y el servidor la purgará en el siguiente 404/410.
+ */
+export async function unsubscribeCurrentDevice(): Promise<void> {
+  if (pushContext() !== 'ok') return
+  try {
+    const reg = await navigator.serviceWorker.getRegistration()
+    const sub = reg ? await reg.pushManager.getSubscription() : null
+    if (!sub) return
+    const endpoint = sub.endpoint
+    await postPushUnsubscribe(endpoint, false)
+    await sub.unsubscribe().catch(() => false)
+  } catch {
+    /* best effort */
+  }
+}
+
 /** Clave VAPID pública (base64url) → applicationServerKey para pushManager.subscribe(). */
 /** Clave VAPID pública (base64url) → applicationServerKey para pushManager.subscribe(). */
 export function urlBase64ToUint8Array(base64url: string): Uint8Array {
 export function urlBase64ToUint8Array(base64url: string): Uint8Array {
   const base64 = base64url.replace(/-/g, '+').replace(/_/g, '/')
   const base64 = base64url.replace(/-/g, '+').replace(/_/g, '/')

+ 22 - 3
app/src/pages/Devices.tsx

@@ -1428,6 +1428,7 @@ export default function Devices() {
     }
     }
   }
   }
   const [deviceOverrides, setDeviceOverrides] = useState<Record<string, { iconOverride?: string; nameOverride?: string; typeOverride?: string; notifyOffline?: boolean }>>(() => {
   const [deviceOverrides, setDeviceOverrides] = useState<Record<string, { iconOverride?: string; nameOverride?: string; typeOverride?: string; notifyOffline?: boolean }>>(() => {
+    if (!isDemo) return {}
     try {
     try {
       const raw = localStorage.getItem('netpulse-device-overrides')
       const raw = localStorage.getItem('netpulse-device-overrides')
       return raw ? (JSON.parse(raw) as Record<string, { iconOverride?: string; nameOverride?: string; typeOverride?: string; notifyOffline?: boolean }>) : {}
       return raw ? (JSON.parse(raw) as Record<string, { iconOverride?: string; nameOverride?: string; typeOverride?: string; notifyOffline?: boolean }>) : {}
@@ -1436,13 +1437,24 @@ export default function Devices() {
     }
     }
   })
   })
 
 
+  // #1631 F-29: los overrides locales solo tienen sentido en la demo. En live
+  // el servidor es la fuente de verdad y una entrada vieja no debe ganarle.
+  useEffect(() => {
+    if (isDemo) return
+    try {
+      localStorage.removeItem('netpulse-device-overrides')
+    } catch {
+      /* ignore */
+    }
+  }, [isDemo])
+
   // Lista enriquecida de clientes: en demo local expande el canon a los 65
   // Lista enriquecida de clientes: en demo local expande el canon a los 65
   // del dataset reconciliado; en live solo fusiona metadatos conocidos sobre
   // del dataset reconciliado; en live solo fusiona metadatos conocidos sobre
   // la API. D6: los equipos de infraestructura (host hipervisor, sus CTs y
   // la API. D6: los equipos de infraestructura (host hipervisor, sus CTs y
   // switches gestionados con LLDP) se reclasifican al grupo de filtro 'infra'.
   // switches gestionados con LLDP) se reclasifican al grupo de filtro 'infra'.
   const { allDevices, infraById } = useMemo(() => {
   const { allDevices, infraById } = useMemo(() => {
     const list = buildClientDevices(devices, isDemo).map((d) => {
     const list = buildClientDevices(devices, isDemo).map((d) => {
-      const ov = deviceOverrides[d.id]
+      const ov = isDemo ? deviceOverrides[d.id] : undefined
       // '' o ausente = automático: en ese caso manda el valor del server
       // '' o ausente = automático: en ese caso manda el valor del server
       // (que en live ya trae los overrides aplicados, #797).
       // (que en live ya trae los overrides aplicados, #797).
       return {
       return {
@@ -1698,7 +1710,11 @@ export default function Devices() {
   const exportCsv = useCallback(() => {
   const exportCsv = useCallback(() => {
     const routerName = new Map((routers ?? []).map((r) => [r.id, r.name]))
     const routerName = new Map((routers ?? []).map((r) => [r.id, r.name]))
     const esc = (v: unknown): string => {
     const esc = (v: unknown): string => {
-      const s = v === null || v === undefined ? '' : String(v)
+      let s = v === null || v === undefined ? '' : String(v)
+      // #1631 F-18: neutraliza prefijos que Excel y LibreOffice interpretan
+      // como formula, sin tocar numeros negativos legitimos (signalDbm, etc.).
+      const numeric = /^-?\d+(?:[.,]\d+)?$/.test(s)
+      if (!numeric && /^[=+\-@\t\r]/.test(s)) s = "'" + s
       return /[",\n;]/.test(s) ? '"' + s.replaceAll('"', '""') + '"' : s
       return /[",\n;]/.test(s) ? '"' + s.replaceAll('"', '""') + '"' : s
     }
     }
     const head = ['name', 'hostname', 'mac', 'ip', 'type', 'group', 'manufacturer', 'router', 'band', 'online', 'signalDbm', 'port', 'portLabel', 'firstSeenMs', 'lastSeenMs', 'dhcpLease', 'adguard', 'traffic24hRx', 'traffic24hTx']
     const head = ['name', 'hostname', 'mac', 'ip', 'type', 'group', 'manufacturer', 'router', 'band', 'online', 'signalDbm', 'port', 'portLabel', 'firstSeenMs', 'lastSeenMs', 'dhcpLease', 'adguard', 'traffic24hRx', 'traffic24hTx']
@@ -1760,6 +1776,9 @@ export default function Devices() {
 
 
   const persistOverride = useCallback(
   const persistOverride = useCallback(
     (id: string, patch: { iconOverride: string; nameOverride: string; typeOverride: string; notifyOffline: boolean } | null) => {
     (id: string, patch: { iconOverride: string; nameOverride: string; typeOverride: string; notifyOffline: boolean } | null) => {
+      // #1631 F-29: en live el override lo persiste el servidor y no se toca
+      // localStorage.
+      if (!isDemo) return
       setDeviceOverrides((prev) => {
       setDeviceOverrides((prev) => {
         const next = { ...prev }
         const next = { ...prev }
         if (patch && (patch.iconOverride || patch.nameOverride || patch.typeOverride || patch.notifyOffline)) {
         if (patch && (patch.iconOverride || patch.nameOverride || patch.typeOverride || patch.notifyOffline)) {
@@ -1780,7 +1799,7 @@ export default function Devices() {
         return next
         return next
       })
       })
     },
     },
-    []
+    [isDemo]
   )
   )
 
 
   // #797: el patch es absoluto ('' = volver al automático); antes el early
   // #797: el patch es absoluto ('' = volver al automático); antes el early

+ 25 - 5
app/src/pages/Settings.tsx

@@ -66,7 +66,7 @@ import { InfoTip } from '@/components/InfoTip'
 import { useNetPulse } from '@/data/DataProvider'
 import { useNetPulse } from '@/data/DataProvider'
 import { fmtEs } from '@/data/mock'
 import { fmtEs } from '@/data/mock'
 import { useAuth } from '@/data/AuthContext'
 import { useAuth } from '@/data/AuthContext'
-import { getVapidKey, postPushSubscribe, postPushUnsubscribe, pushContext, urlBase64ToUint8Array } from '@/data/push'
+import { getVapidKey, postPushSubscribe, postPushUnsubscribe, pushContext, unsubscribeCurrentDevice, urlBase64ToUint8Array } from '@/data/push'
 import { useServicesVisibility } from '@/hooks/useServicesVisibility'
 import { useServicesVisibility } from '@/hooks/useServicesVisibility'
 import type { ServicesVisibility } from '@/hooks/useServicesVisibility'
 import type { ServicesVisibility } from '@/hooks/useServicesVisibility'
 import { useIntegrations } from '@/hooks/useIntegrations'
 import { useIntegrations } from '@/hooks/useIntegrations'
@@ -5145,6 +5145,7 @@ export default function Settings() {
   const { devices, wan, isDemo, refresh: refreshOverview } = useNetPulse()
   const { devices, wan, isDemo, refresh: refreshOverview } = useNetPulse()
   const auth = useAuth()
   const auth = useAuth()
   const [adminPanel, setAdminPanel] = useState<'users' | 'backups' | 'autoupdate' | null>(null)
   const [adminPanel, setAdminPanel] = useState<'users' | 'backups' | 'autoupdate' | null>(null)
+  const [logoutError, setLogoutError] = useState<string | null>(null)
 
 
   // ——— Orquestación (issue #121): toggle opt-in en la AdminBar ———
   // ——— Orquestación (issue #121): toggle opt-in en la AdminBar ———
   const [orchOn, setOrchOn] = useState(false)
   const [orchOn, setOrchOn] = useState(false)
@@ -6408,12 +6409,25 @@ export default function Settings() {
                     exitDemo()
                     exitDemo()
                     return
                     return
                   }
                   }
-                  void fetch('/api/auth/logout', { method: 'POST' })
-                    .catch(() => undefined)
-                    .finally(() => {
+                  setLogoutError(null)
+                  void (async () => {
+                    // #1631 F-20: la suscripción push se retira antes de
+                    // revocar la cookie, porque la baja exige sesión válida.
+                    await unsubscribeCurrentDevice()
+                    try {
+                      const res = await fetch('/api/auth/logout', { method: 'POST' })
+                      if (!res.ok) {
+                        // #1631 F-19: no afirmar que la sesión terminó si el
+                        // servidor no revocó la cookie.
+                        setLogoutError(t('settings.session.logoutError'))
+                        return
+                      }
                       window.dispatchEvent(new Event('netpulse-unauthorized'))
                       window.dispatchEvent(new Event('netpulse-unauthorized'))
                       window.location.assign('/login')
                       window.location.assign('/login')
-                    })
+                    } catch {
+                      setLogoutError(t('settings.session.logoutError'))
+                    }
+                  })()
                 }}
                 }}
                 className="ml-auto flex h-9 shrink-0 items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 text-sm font-medium text-danger transition-colors duration-150 hover:bg-danger/15"
                 className="ml-auto flex h-9 shrink-0 items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 text-sm font-medium text-danger transition-colors duration-150 hover:bg-danger/15"
               >
               >
@@ -6422,6 +6436,12 @@ export default function Settings() {
               </button>
               </button>
             </div>
             </div>
 
 
+            {logoutError && (
+              <p role="alert" className="mt-2 text-caption text-danger">
+                {logoutError}
+              </p>
+            )}
+
             {showPwdForm && !isDemo && (
             {showPwdForm && !isDemo && (
               <form
               <form
                 className="mt-4 flex max-w-md flex-col gap-3 border-t border-border pt-4"
                 className="mt-4 flex max-w-md flex-col gap-3 border-t border-border pt-4"

+ 1 - 1
server-go/internal/httpapi/httpapi_test.go

@@ -888,7 +888,7 @@ func TestSecurityHeaders(t *testing.T) {
 		"X-Frame-Options":           "DENY",
 		"X-Frame-Options":           "DENY",
 		"Referrer-Policy":           "strict-origin-when-cross-origin",
 		"Referrer-Policy":           "strict-origin-when-cross-origin",
 		"Permissions-Policy":        "geolocation=(), microphone=(), camera=()",
 		"Permissions-Policy":        "geolocation=(), microphone=(), camera=()",
-		"Content-Security-Policy":   "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data:; connect-src 'self'",
+		"Content-Security-Policy":   "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src 'self'",
 	}
 	}
 	for k, v := range want {
 	for k, v := range want {
 		if got := res.Header.Get(k); got != v {
 		if got := res.Header.Get(k); got != v {

+ 43 - 0
server-go/internal/httpapi/landing_integrity_test.go

@@ -0,0 +1,43 @@
+package httpapi_test
+
+import (
+	"os"
+	"regexp"
+	"strings"
+	"testing"
+)
+
+var scriptSrcRe = regexp.MustCompile(`<script[^>]*src="([^"]+)"[^>]*>`)
+
+func TestLandingScriptsArePinned(t *testing.T) {
+	for _, name := range []string{"index.html", "features.html", "home-assistant.html"} {
+		path := "../../../web/" + name
+		b, err := os.ReadFile(path)
+		if err != nil {
+			t.Fatalf("read %s: %v", path, err)
+		}
+		for _, m := range scriptSrcRe.FindAllStringSubmatch(string(b), -1) {
+			src, tag := m[1], m[0]
+			if strings.HasPrefix(src, "//") {
+				t.Errorf("%s: protocol-relative script %s", name, src)
+			}
+			if strings.HasPrefix(src, "http") && !strings.Contains(tag, "integrity=") {
+				t.Errorf("%s: external script without integrity: %s", name, src)
+			}
+		}
+	}
+}
+
+func TestAppIndexUsesFirstPartyFonts(t *testing.T) {
+	b, err := os.ReadFile("../../../app/index.html")
+	if err != nil {
+		t.Fatalf("read app/index.html: %v", err)
+	}
+	html := string(b)
+	if strings.Contains(html, "fonts.googleapis.com") || strings.Contains(html, "fonts.gstatic.com") {
+		t.Fatal("app/index.html still loads Google Fonts")
+	}
+	if !strings.Contains(html, `href="/fonts/fonts.css"`) {
+		t.Fatal("app/index.html does not load the self-hosted fonts")
+	}
+}

+ 1 - 1
server-go/internal/security/security.go

@@ -17,7 +17,7 @@ var Headers = []struct{ K, V string }{
 	// una violación CSP y las transiciones no corren. El riesgo de CSS
 	// una violación CSP y las transiciones no corren. El riesgo de CSS
 	// inline es muy inferior al de script inline (la app no renderiza HTML
 	// inline es muy inferior al de script inline (la app no renderiza HTML
 	// controlado por el usuario), y script-src sigue sin 'unsafe-inline'.
 	// controlado por el usuario), y script-src sigue sin 'unsafe-inline'.
-	{"Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data:; connect-src 'self'"},
+	{"Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src 'self'"},
 }
 }
 
 
 // HSTS is the Strict-Transport-Security value for a server whose every
 // HSTS is the Strict-Transport-Security value for a server whose every

+ 22 - 0
server-go/internal/security/security_test.go

@@ -0,0 +1,22 @@
+package security
+
+import (
+	"strings"
+	"testing"
+)
+
+func TestCSPKeepsFontsFirstParty(t *testing.T) {
+	for _, h := range Headers {
+		if h.K != "Content-Security-Policy" {
+			continue
+		}
+		if strings.Contains(h.V, "fonts.googleapis.com") || strings.Contains(h.V, "fonts.gstatic.com") {
+			t.Fatalf("CSP still allows third-party fonts: %s", h.V)
+		}
+		if !strings.Contains(h.V, "font-src 'self'") {
+			t.Fatalf("CSP must allow first-party fonts: %s", h.V)
+		}
+		return
+	}
+	t.Fatal("Content-Security-Policy header missing")
+}

+ 3 - 5
web/features.html

@@ -33,9 +33,7 @@
   <meta name="twitter:description" content="Listado completo de funciones de NetPulse y las decisiones técnicas detrás del proyecto." data-i18n-attr="content" data-i18n="featuresPage.metaDescription" />
   <meta name="twitter:description" content="Listado completo de funciones de NetPulse y las decisiones técnicas detrás del proyecto." data-i18n-attr="content" data-i18n="featuresPage.metaDescription" />
   <meta name="twitter:image" content="https://netpulse.cloudless.club/og.png" />
   <meta name="twitter:image" content="https://netpulse.cloudless.club/og.png" />
   <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96' fill='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='10' y1='78' x2='90' y2='20' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%2322D3EE'/%3E%3Cstop offset='1' stop-color='%23A78BFA'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M10 60 H27 L33 60 L40 38 L48 78 L54 48 L58 60 H64' stroke='url(%23g)' stroke-width='5.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='73' cy='60' r='6' fill='url(%23g)'/%3E%3Cpath d='M62.4 49.4 A15 15 0 0 1 83.6 49.4' stroke='url(%23g)' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M55.3 39.7 A25 25 0 0 1 90.7 39.7' stroke='url(%23g)' stroke-width='5' stroke-linecap='round' opacity='0.6'/%3E%3C/svg%3E" />
   <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96' fill='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='10' y1='78' x2='90' y2='20' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%2322D3EE'/%3E%3Cstop offset='1' stop-color='%23A78BFA'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M10 60 H27 L33 60 L40 38 L48 78 L54 48 L58 60 H64' stroke='url(%23g)' stroke-width='5.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='73' cy='60' r='6' fill='url(%23g)'/%3E%3Cpath d='M62.4 49.4 A15 15 0 0 1 83.6 49.4' stroke='url(%23g)' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M55.3 39.7 A25 25 0 0 1 90.7 39.7' stroke='url(%23g)' stroke-width='5' stroke-linecap='round' opacity='0.6'/%3E%3C/svg%3E" />
-  <link rel="preconnect" href="https://fonts.googleapis.com" />
-  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
-  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
+  <link rel="stylesheet" href="fonts/fonts.css" />
   <link rel="stylesheet" href="styles.css?v=20261018b" />
   <link rel="stylesheet" href="styles.css?v=20261018b" />
   <script type="application/ld+json">
   <script type="application/ld+json">
   {
   {
@@ -65,7 +63,7 @@
     ]
     ]
   }
   }
   </script>
   </script>
-<script data-goatcounter="https://stats.netpulse.cloudless.club/count" async src="//stats.netpulse.cloudless.club/count.js"></script>
+<script data-goatcounter="https://stats.netpulse.cloudless.club/count" async src="https://stats.netpulse.cloudless.club/count.js" integrity="sha384-2UjvVpptg4JlEVgJI2PdscrjOjPcil/4F1ZvIMJ81CShQnEDSlPI+l4PfogvTLYi" crossorigin="anonymous"></script>
 </head>
 </head>
 <body>
 <body>
   <canvas id="bgCanvas" aria-hidden="true"></canvas>
   <canvas id="bgCanvas" aria-hidden="true"></canvas>
@@ -681,6 +679,6 @@
 
 
   <script src="i18n.js?v=20261019a"></script>
   <script src="i18n.js?v=20261019a"></script>
   <script src="app.js?v=20261019a"></script>
   <script src="app.js?v=20261019a"></script>
-<script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9"></script>
+<script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9" integrity="sha384-FeSgFWhRpNmUWqmtRLZpDSRTuxgovbVqlyM0OaJpq2IanhF2u3xjYziXsyXR9Kg/" crossorigin="anonymous"></script>
 </body>
 </body>
 </html>
 </html>

+ 82 - 0
web/fonts/fonts.css

@@ -0,0 +1,82 @@
+/* Self-hosted fonts (#1631 F-31). Latin subset, generated from the Google Fonts CSS. */
+
+@font-face {
+  font-family: 'Inter';
+  font-style: normal;
+  font-weight: 400;
+  font-display: swap;
+  src: url('inter-3100e775.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Inter';
+  font-style: normal;
+  font-weight: 500;
+  font-display: swap;
+  src: url('inter-3100e775.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Inter';
+  font-style: normal;
+  font-weight: 600;
+  font-display: swap;
+  src: url('inter-3100e775.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'JetBrains Mono';
+  font-style: normal;
+  font-weight: 400;
+  font-display: swap;
+  src: url('jetbrains-mono-83c005d4.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'JetBrains Mono';
+  font-style: normal;
+  font-weight: 500;
+  font-display: swap;
+  src: url('jetbrains-mono-83c005d4.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'JetBrains Mono';
+  font-style: normal;
+  font-weight: 600;
+  font-display: swap;
+  src: url('jetbrains-mono-83c005d4.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Space Grotesk';
+  font-style: normal;
+  font-weight: 500;
+  font-display: swap;
+  src: url('space-grotesk-06408904.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Space Grotesk';
+  font-style: normal;
+  font-weight: 600;
+  font-display: swap;
+  src: url('space-grotesk-06408904.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+@font-face {
+  font-family: 'Space Grotesk';
+  font-style: normal;
+  font-weight: 700;
+  font-display: swap;
+  src: url('space-grotesk-06408904.woff2') format('woff2');
+  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}

BIN
web/fonts/inter-3100e775.woff2


BIN
web/fonts/jetbrains-mono-83c005d4.woff2


BIN
web/fonts/space-grotesk-06408904.woff2


+ 3 - 5
web/home-assistant.html

@@ -33,11 +33,9 @@
   <meta name="twitter:description" content="El estado de tu red en Home Assistant: descubrimiento automático por MQTT, sin nube." data-i18n-attr="content" data-i18n="haPage.metaDescription" />
   <meta name="twitter:description" content="El estado de tu red en Home Assistant: descubrimiento automático por MQTT, sin nube." data-i18n-attr="content" data-i18n="haPage.metaDescription" />
   <meta name="twitter:image" content="https://netpulse.cloudless.club/og.png" />
   <meta name="twitter:image" content="https://netpulse.cloudless.club/og.png" />
   <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96' fill='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='10' y1='78' x2='90' y2='20' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%2322D3EE'/%3E%3Cstop offset='1' stop-color='%23A78BFA'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M10 60 H27 L33 60 L40 38 L48 78 L54 48 L58 60 H64' stroke='url(%23g)' stroke-width='5.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='73' cy='60' r='6' fill='url(%23g)'/%3E%3Cpath d='M62.4 49.4 A15 15 0 0 1 83.6 49.4' stroke='url(%23g)' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M55.3 39.7 A25 25 0 0 1 90.7 39.7' stroke='url(%23g)' stroke-width='5' stroke-linecap='round' opacity='0.6'/%3E%3C/svg%3E" />
   <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96' fill='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='10' y1='78' x2='90' y2='20' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%2322D3EE'/%3E%3Cstop offset='1' stop-color='%23A78BFA'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M10 60 H27 L33 60 L40 38 L48 78 L54 48 L58 60 H64' stroke='url(%23g)' stroke-width='5.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='73' cy='60' r='6' fill='url(%23g)'/%3E%3Cpath d='M62.4 49.4 A15 15 0 0 1 83.6 49.4' stroke='url(%23g)' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M55.3 39.7 A25 25 0 0 1 90.7 39.7' stroke='url(%23g)' stroke-width='5' stroke-linecap='round' opacity='0.6'/%3E%3C/svg%3E" />
-  <link rel="preconnect" href="https://fonts.googleapis.com" />
-  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
-  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
+  <link rel="stylesheet" href="fonts/fonts.css" />
   <link rel="stylesheet" href="styles.css?v=20261018b" />
   <link rel="stylesheet" href="styles.css?v=20261018b" />
-<script data-goatcounter="https://stats.netpulse.cloudless.club/count" async src="//stats.netpulse.cloudless.club/count.js"></script>
+<script data-goatcounter="https://stats.netpulse.cloudless.club/count" async src="https://stats.netpulse.cloudless.club/count.js" integrity="sha384-2UjvVpptg4JlEVgJI2PdscrjOjPcil/4F1ZvIMJ81CShQnEDSlPI+l4PfogvTLYi" crossorigin="anonymous"></script>
 </head>
 </head>
 <body>
 <body>
   <canvas id="bgCanvas" aria-hidden="true"></canvas>
   <canvas id="bgCanvas" aria-hidden="true"></canvas>
@@ -324,6 +322,6 @@ NETPULSE_MQTT_INSTANCE=casa</code>
 
 
   <script src="i18n.js?v=20261019a"></script>
   <script src="i18n.js?v=20261019a"></script>
   <script src="app.js?v=20261019a"></script>
   <script src="app.js?v=20261019a"></script>
-<script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9"></script>
+<script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9" integrity="sha384-FeSgFWhRpNmUWqmtRLZpDSRTuxgovbVqlyM0OaJpq2IanhF2u3xjYziXsyXR9Kg/" crossorigin="anonymous"></script>
 </body>
 </body>
 </html>
 </html>

+ 3 - 5
web/index.html

@@ -33,9 +33,7 @@
   <meta name="twitter:description" content="Monitorización en vivo para redes domésticas OpenWrt: topología en vivo, salud, WireGuard, AdGuard Home y alertas. Autoalojado, 100% libre (AGPL-3.0), sin nube." />
   <meta name="twitter:description" content="Monitorización en vivo para redes domésticas OpenWrt: topología en vivo, salud, WireGuard, AdGuard Home y alertas. Autoalojado, 100% libre (AGPL-3.0), sin nube." />
   <meta name="twitter:image" content="https://netpulse.cloudless.club/og.png" />
   <meta name="twitter:image" content="https://netpulse.cloudless.club/og.png" />
   <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96' fill='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='10' y1='78' x2='90' y2='20' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%2322D3EE'/%3E%3Cstop offset='1' stop-color='%23A78BFA'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M10 60 H27 L33 60 L40 38 L48 78 L54 48 L58 60 H64' stroke='url(%23g)' stroke-width='5.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='73' cy='60' r='6' fill='url(%23g)'/%3E%3Cpath d='M62.4 49.4 A15 15 0 0 1 83.6 49.4' stroke='url(%23g)' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M55.3 39.7 A25 25 0 0 1 90.7 39.7' stroke='url(%23g)' stroke-width='5' stroke-linecap='round' opacity='0.6'/%3E%3C/svg%3E" />
   <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96' fill='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='10' y1='78' x2='90' y2='20' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%2322D3EE'/%3E%3Cstop offset='1' stop-color='%23A78BFA'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M10 60 H27 L33 60 L40 38 L48 78 L54 48 L58 60 H64' stroke='url(%23g)' stroke-width='5.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='73' cy='60' r='6' fill='url(%23g)'/%3E%3Cpath d='M62.4 49.4 A15 15 0 0 1 83.6 49.4' stroke='url(%23g)' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M55.3 39.7 A25 25 0 0 1 90.7 39.7' stroke='url(%23g)' stroke-width='5' stroke-linecap='round' opacity='0.6'/%3E%3C/svg%3E" />
-  <link rel="preconnect" href="https://fonts.googleapis.com" />
-  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
-  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
+  <link rel="stylesheet" href="fonts/fonts.css" />
   <link rel="stylesheet" href="styles.css?v=20261018b" />
   <link rel="stylesheet" href="styles.css?v=20261018b" />
   <script type="application/ld+json">
   <script type="application/ld+json">
   {
   {
@@ -92,7 +90,7 @@
     ]
     ]
   }
   }
   </script>
   </script>
-<script data-goatcounter="https://stats.netpulse.cloudless.club/count" async src="//stats.netpulse.cloudless.club/count.js"></script>
+<script data-goatcounter="https://stats.netpulse.cloudless.club/count" async src="https://stats.netpulse.cloudless.club/count.js" integrity="sha384-2UjvVpptg4JlEVgJI2PdscrjOjPcil/4F1ZvIMJ81CShQnEDSlPI+l4PfogvTLYi" crossorigin="anonymous"></script>
 </head>
 </head>
 <body>
 <body>
   <canvas id="bgCanvas" aria-hidden="true"></canvas>
   <canvas id="bgCanvas" aria-hidden="true"></canvas>
@@ -885,6 +883,6 @@
 
 
   <script src="i18n.js?v=20261019a"></script>
   <script src="i18n.js?v=20261019a"></script>
   <script src="app.js?v=20261019a"></script>
   <script src="app.js?v=20261019a"></script>
-<script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9"></script>
+<script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9" integrity="sha384-FeSgFWhRpNmUWqmtRLZpDSRTuxgovbVqlyM0OaJpq2IanhF2u3xjYziXsyXR9Kg/" crossorigin="anonymous"></script>
 </body>
 </body>
 </html>
 </html>

+ 6 - 4
web/src/app.ts

@@ -1299,18 +1299,20 @@ function initAppearance() {
 }
 }
 
 
 /* ---------- copiar comando ---------- */
 /* ---------- copiar comando ---------- */
+// #1631 F-30: el comando es una constante del bundle, no texto leído del DOM.
+const INSTALL_CMD = 'curl -fsSL https://raw.githubusercontent.com/gnacho/netpulse/main/install.sh | sh'
+const AGENT_CMD = 'opkg install netpulse-agent'
+
 function initCopy() {
 function initCopy() {
   const btn = document.getElementById('copyBtn')
   const btn = document.getElementById('copyBtn')
   if (!btn) return
   if (!btn) return
   btn.addEventListener('click', async () => {
   btn.addEventListener('click', async () => {
-    const cmd = document.getElementById('installCmd').textContent
-    copyText(cmd, btn)
+    copyText(INSTALL_CMD, btn)
   })
   })
   const agentBtn = document.getElementById('agentCopyBtn')
   const agentBtn = document.getElementById('agentCopyBtn')
   if (agentBtn) {
   if (agentBtn) {
     agentBtn.addEventListener('click', async () => {
     agentBtn.addEventListener('click', async () => {
-      const cmd = document.getElementById('agentCmd').textContent
-      copyText(cmd, agentBtn)
+      copyText(AGENT_CMD, agentBtn)
     })
     })
   }
   }
 }
 }