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.

Exercise webhook mask failures through the API boundary

pulse-triage[bot]b10112cc774d
diff --git a/internal/api/alerting/notifications_test.go b/internal/api/alerting/notifications_test.go
index 33809b54ae..a8430daa61 100644
--- a/internal/api/alerting/notifications_test.go
+++ b/internal/api/alerting/notifications_test.go
@@ -1474,9 +1474,21 @@ func TestWebhookEditRejectsUnrecoverableMasks(t *testing.T) {
{"Authorization": "***REDACTED***"},
{"AUTHORIZATION": "synthetic-first", "authorization": "synthetic-second"},
} {
- if _, err := restoreMaskedWebhookValues(map[string]string{"Authorization": "***REDACTED***"}, stored, true); err == nil {
- t.Fatal("unrecoverable or ambiguous saved mask must not become a credential")
- }
+ manager := new(MockNotificationManager)
+ persistence := new(MockNotificationConfigPersistence)
+ monitor := new(MockNotificationMonitor)
+ monitor.On("GetNotificationManager").Return(manager)
+ monitor.On("GetConfigPersistence").Return(persistence)
+ manager.On("GetWebhooks").Return([]notifications.WebhookConfig{{ID: "edit", Headers: stored}}).Once()
+ rec := httptest.NewRecorder()
+ NewNotificationHandlers(nil, monitor).UpdateWebhook(rec, httptest.NewRequest(http.MethodPut,
+ "/api/notifications/webhooks/edit", strings.NewReader(`{"headers":{"Authorization":"***REDACTED***"}}`)))
+ assert.Equal(t, http.StatusBadRequest, rec.Code)
+ assert.NotContains(t, rec.Body.String(), "synthetic-first")
+ assert.NotContains(t, rec.Body.String(), "synthetic-second")
+ manager.AssertNotCalled(t, "UpdateWebhook", mock.Anything, mock.Anything)
+ persistence.AssertNotCalled(t, "SaveWebhooks", mock.Anything)
+ manager.AssertExpectations(t)
}
}
@@ -1579,8 +1591,11 @@ func TestWebhookMaskedEditPersistsAndDelivers(t *testing.T) {
}
updated := httptest.NewRecorder()
handler.UpdateWebhook(updated, httptest.NewRequest(http.MethodPut, "/api/notifications/webhooks/edit", bytes.NewReader(body)))
- if updated.Code != http.StatusOK || strings.Contains(updated.Body.String(), "synthetic-token") {
- t.Fatal("masked update failed or exposed a credential")
+ if updated.Code != http.StatusOK {
+ t.Fatal("masked update failed")
+ }
+ if strings.Contains(updated.Body.String(), "synthetic-token") {
+ t.Error("masked update exposed a stored credential")
}
m.Stop()
m = open()