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.

Complete strict webhook merge helper separation

pulse-triage[bot]4a764d738005
diff --git a/internal/api/alerting/notifications.go b/internal/api/alerting/notifications.go
index d2d960dcc6..9d49f24fb1 100644
--- a/internal/api/alerting/notifications.go
+++ b/internal/api/alerting/notifications.go
@@ -514,7 +514,7 @@ func (h *NotificationHandlers) CreateWebhook(w http.ResponseWriter, r *http.Requ
// sends a replacement map: explicit edits and omitted keys must not be undone
// just because another value is still masked. Header names are case-insensitive;
// custom-field names are not. Never store a placeholder without a saved value.
-func restoreMaskedWebhookValues(incoming, existing map[string]string, headers bool) (map[string]string, error) {
+func restoreStrictMaskedWebhookValues(incoming, existing map[string]string, headers bool) (map[string]string, error) {
if incoming == nil {
return nil, nil
}
diff --git a/internal/api/alerting/notifications_test.go b/internal/api/alerting/notifications_test.go
index b225b6ecf1..8ab7555035 100644
--- a/internal/api/alerting/notifications_test.go
+++ b/internal/api/alerting/notifications_test.go
@@ -1474,7 +1474,14 @@ func TestWebhookEditPreservesOnlyMaskedValues(t *testing.T) {
if !tc.invalid {
var response notifications.WebhookConfig
assert.NoError(t, json.Unmarshal(rec.Body.Bytes(), &response))
- assert.Equal(t, maskedWebhookResponse(notifications.NormalizeWebhookConfig(incoming)).CustomFields, response.CustomFields)
+ var expectedFields map[string]string
+ if len(incoming.CustomFields) > 0 {
+ expectedFields = make(map[string]string, len(incoming.CustomFields))
+ for key := range incoming.CustomFields {
+ expectedFields[key] = maskedWebhookSecret
+ }
+ }
+ assert.Equal(t, expectedFields, response.CustomFields)
}
assert.Equal(t, "old", stored.CustomFields["channel"], "edit mutated the previous map")
assert.Equal(t, "text/plain", stored.Headers["Content-Type"], "edit mutated the previous map")