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.

Bind audit help checks to the bounded selection decoder

pulse-triage[bot]58e46e21d7c9
diff --git a/scripts/tests/test_audit_recovery_docs.py b/scripts/tests/test_audit_recovery_docs.py
index d78798b598..d7f704ae9b 100644
--- a/scripts/tests/test_audit_recovery_docs.py
+++ b/scripts/tests/test_audit_recovery_docs.py
@@ -111,12 +111,25 @@ class AuditWebhookDocsTest(unittest.TestCase):
for boundary in ("ensureAdminSession", "featureAuditLoggingValue", "ScopeSettingsRead",
"ScopeSettingsWrite", "auth.ResourceAuditLogs"):
self.assertIn(boundary, route)
- handler = (ROOT / "internal/api/activity_audit_handlers.go").read_text().split(
- "func (h *AuditHandlers) HandleUpdateWebhooks", 1)[1].split(
- "// validateWebhookURL", 1)[0]
- self.assertIn('URLs []string `json:"urls"`', handler)
- self.assertIn("getLoggerForOrg(orgID)", handler)
- self.assertIn("logger.UpdateWebhookURLs(validatedURLs)", handler)
+ source = (ROOT / "internal/api/activity_audit_handlers.go").read_text()
+ handler = source.split("func (h *AuditHandlers) HandleUpdateWebhooks", 1)[1].split(
+ "\n}\n", 1)[0]
+ # The bounded decoder now owns the wire shape; requiring an inline
+ # struct would reject the repair that prevents last-member-wins clears.
+ selection = source.split("func decodeAuditWebhookSelection(", 1)[1].split(
+ "\n}\n", 1)[0]
+ self.assertIn("var urls []string", selection)
+ self.assertIn("decoder.Decode(&urls)", selection)
+ self.assertIn("if urls == nil", selection)
+ for boundary in ("http.MaxBytesReader(w, r.Body, 64*1024)",
+ "urls, err := decodeAuditWebhookSelection(r.Body)",
+ "for _, rawURL := range urls", "validateWebhookURL(rawURL)",
+ "getLoggerForOrg(orgID)", "logger.UpdateWebhookURLs(validatedURLs)"):
+ self.assertIn(boundary, handler)
+ self.assertLess(handler.index("decodeAuditWebhookSelection(r.Body)"),
+ handler.index("validateWebhookURL(rawURL)"))
+ self.assertLess(handler.index("validateWebhookURL(rawURL)"),
+ handler.index("logger.UpdateWebhookURLs(validatedURLs)"))
def test_audit_endpoint_restrictions_are_not_an_alert_setting(self):
for phrase in ("using HTTPS with valid certificate trust", "placeholder",