Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Validate setup script input sanitization

rcourtman77f23b35f7eb
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index 29c6dc3418..37323738db 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -2820,6 +2820,36 @@ func TestSSHKeyGenerationBlockedInContainer(t *testing.T) {
}
}
+func TestSetupScriptRejectsInvalidAuthToken(t *testing.T) {
+ cfg := newTestConfigWithTokens(t)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodGet, "/api/setup-script?type=pve&host=https://example.com&pulse_url=https://pulse.example.com&auth_token=not-hex", nil)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusBadRequest {
+ t.Fatalf("expected 400 for invalid auth_token, got %d", rec.Code)
+ }
+ if !strings.Contains(rec.Body.String(), "Invalid auth_token parameter") {
+ t.Fatalf("expected invalid auth_token error, got %q", rec.Body.String())
+ }
+}
+
+func TestSetupScriptRejectsInvalidHostURL(t *testing.T) {
+ cfg := newTestConfigWithTokens(t)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodGet, "/api/setup-script?type=pve&host=ftp://example.com&pulse_url=https://pulse.example.com", nil)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusBadRequest {
+ t.Fatalf("expected 400 for invalid host, got %d", rec.Code)
+ }
+ if !strings.Contains(rec.Body.String(), "Invalid host parameter") {
+ t.Fatalf("expected invalid host error, got %q", rec.Body.String())
+ }
+}
+
func TestOIDCLoginBypassesAuth(t *testing.T) {
cfg := newTestConfigWithTokens(t)
cfg.AuthUser = "admin"