Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Harden security status token handling
rcourtman041148f90b97
diff --git a/internal/api/security_status_additional_test.go b/internal/api/security_status_additional_test.gonew file mode 100644index 0000000000..27a3b95cce--- /dev/null+++ b/internal/api/security_status_additional_test.go@@ -0,0 +1,35 @@+package api++import (+ "encoding/json"+ "net/http"+ "net/http/httptest"+ "testing"+)++func TestSecurityStatusIgnoresInvalidTokenHeader(t *testing.T) {+ rawToken := "status-valid-token-123.12345678"+ record := newTokenRecord(t, rawToken, nil, nil)+ cfg := newTestConfigWithTokens(t, record)+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")++ req := httptest.NewRequest(http.MethodGet, "/api/security/status", nil)+ req.Header.Set("X-API-Token", "invalid-token")+ rec := httptest.NewRecorder()+ router.Handler().ServeHTTP(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("expected 200 for security status, got %d", rec.Code)+ }++ var payload map[string]interface{}+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {+ t.Fatalf("decode response: %v", err)+ }+ if hint, ok := payload["apiTokenHint"].(string); ok && hint != "" {+ t.Fatalf("expected apiTokenHint to be empty for invalid token, got %q", hint)+ }+ if _, ok := payload["tokenScopes"]; ok {+ t.Fatalf("expected tokenScopes to be omitted for invalid token")+ }+}