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 action audit verification redaction
rcourtmanadc46e2d0a96
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 5e89bd2339..75cbbf4efc 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -48,6 +48,7 @@ cross-source deduplication.24. `internal/unifiedresources/relationships.go`25. `internal/unifiedresources/privacy.go`26. `internal/unifiedresources/actions.go`+27. `internal/unifiedresources/audit_redaction.go`27. `frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx`28. `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx`29. `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx`@@ -517,6 +518,12 @@ AI-only summary payloads, or page-local heuristics.intentionally narrower than the patrol-failure redactor: arbitraryURLs are preserved so operators can reference runbooks, ticketlinks, and GitHub issues in audit reasons.+ Verification command output is part of the same persistence+ boundary: `ActionVerificationResult.Command`, `Output`, and `Note`+ must be redacted both on top-level `ActionAuditRecord.Verification`+ and nested `ExecutionResult.Verification`, while `Ran=false`+ normalization remains responsible for clearing verification details+ rather than persisting redaction markers for unrun checks.21. Keep post-execution verification outcome on the canonical executionresult. `ExecutionResult.Verification` carries`ActionVerificationResult` with `Ran`, `Command`, `Output`,diff --git a/internal/unifiedresources/audit_redaction.go b/internal/unifiedresources/audit_redaction.goindex ebca1b5ec2..f8d2eb12da 100644--- a/internal/unifiedresources/audit_redaction.go+++ b/internal/unifiedresources/audit_redaction.go@@ -65,11 +65,23 @@ func RedactAuditText(s string) string {return s}+func redactActionVerificationResult(result *ActionVerificationResult) *ActionVerificationResult {+ redacted := NormalizeActionVerificationResult(result)+ if redacted == nil {+ return nil+ }+ redacted.Command = RedactAuditText(redacted.Command)+ redacted.Output = RedactAuditText(redacted.Output)+ redacted.Note = RedactAuditText(redacted.Note)+ return redacted+}+// RedactAuditRecord returns a copy of the input ActionAuditRecord with// known secret shapes scrubbed from the operator-authored reason, the-// params map's string values, and the execution result's output. The-// canonical Plan, Approvals, and identity fields are left alone — they-// are produced by Pulse, not by operators or external command output.+// params map's string values, execution output, and verification command+// fields. The canonical Plan, Approvals, and identity fields are left+// alone — they are produced by Pulse, not by operators or external+// command output.func RedactAuditRecord(record ActionAuditRecord) ActionAuditRecord {record.Request.Reason = RedactAuditText(record.Request.Reason)if len(record.Request.Params) > 0 {@@ -87,8 +99,10 @@ func RedactAuditRecord(record ActionAuditRecord) ActionAuditRecord {redacted := *record.Resultredacted.Output = RedactAuditText(redacted.Output)redacted.ErrorMessage = RedactAuditText(redacted.ErrorMessage)+ redacted.Verification = redactActionVerificationResult(redacted.Verification)record.Result = &redacted}+ record.Verification = redactActionVerificationResult(record.Verification)record.VerificationOutcome.EvidenceSummary = RedactAuditText(record.VerificationOutcome.EvidenceSummary)return record}diff --git a/internal/unifiedresources/audit_redaction_test.go b/internal/unifiedresources/audit_redaction_test.goindex 64175c00f8..105a147b95 100644--- a/internal/unifiedresources/audit_redaction_test.go+++ b/internal/unifiedresources/audit_redaction_test.go@@ -113,6 +113,18 @@ func TestRedactAuditRecord_ScrubsRequestAndResultStringFields(t *testing.T) {RequestID: "req-1",PlanHash: "deadbeef",},+ Verification: &ActionVerificationResult{+ Ran: true,+ Command: "systemctl status nginx token=top-command-secret",+ Output: "ActiveState=active token=top-output-secret",+ Success: true,+ RanAt: now.Add(time.Minute),+ Note: "verified active with password=top-note-secret",+ },+ VerificationOutcome: VerificationOutcome{+ Status: VerificationVerified,+ EvidenceSummary: "observed active after api_key=evidence-secret",+ },Result: actionResultStub(),}redacted := RedactAuditRecord(record)@@ -138,14 +150,96 @@ func TestRedactAuditRecord_ScrubsRequestAndResultStringFields(t *testing.T) {if strings.Contains(redacted.Result.Output, "hunter2") {t.Fatalf("Result.Output still contains password: %s", redacted.Result.Output)}+ if strings.Contains(redacted.Result.ErrorMessage, "leakedkey") {+ t.Fatalf("Result.ErrorMessage still contains API key: %s", redacted.Result.ErrorMessage)+ }+ if redacted.Verification == nil {+ t.Fatal("expected top-level verification to remain present")+ }+ if strings.Contains(redacted.Verification.Command, "top-command-secret") || !strings.Contains(redacted.Verification.Command, "systemctl status nginx") {+ t.Fatalf("top-level verification command redaction failed: %s", redacted.Verification.Command)+ }+ if strings.Contains(redacted.Verification.Output, "top-output-secret") || !strings.Contains(redacted.Verification.Output, "ActiveState=active") {+ t.Fatalf("top-level verification output redaction failed: %s", redacted.Verification.Output)+ }+ if strings.Contains(redacted.Verification.Note, "top-note-secret") || !strings.Contains(redacted.Verification.Note, "verified active") {+ t.Fatalf("top-level verification note redaction failed: %s", redacted.Verification.Note)+ }+ if redacted.Result.Verification == nil {+ t.Fatal("expected result verification to remain present")+ }+ if strings.Contains(redacted.Result.Verification.Command, "nested-command-secret") || !strings.Contains(redacted.Result.Verification.Command, "curl -H") {+ t.Fatalf("nested verification command redaction failed: %s", redacted.Result.Verification.Command)+ }+ if strings.Contains(redacted.Result.Verification.Output, "nested-output-secret") || !strings.Contains(redacted.Result.Verification.Output, "state") {+ t.Fatalf("nested verification output redaction failed: %s", redacted.Result.Verification.Output)+ }+ if strings.Contains(redacted.Result.Verification.Note, "nested-note-secret") || !strings.Contains(redacted.Result.Verification.Note, "nested check") {+ t.Fatalf("nested verification note redaction failed: %s", redacted.Result.Verification.Note)+ }+ if strings.Contains(redacted.VerificationOutcome.EvidenceSummary, "evidence-secret") {+ t.Fatalf("verification evidence summary still contains API key: %s", redacted.VerificationOutcome.EvidenceSummary)+ }+}++func TestRedactAuditRecord_PreservesUnrunVerificationNormalization(t *testing.T) {+ now := time.Now().UTC()+ record := ActionAuditRecord{+ ID: "act-unrun",+ CreatedAt: now,+ UpdatedAt: now,+ State: ActionStateFailed,+ Verification: &ActionVerificationResult{+ Ran: false,+ Command: "should not persist token=top-command-secret",+ Output: "should not persist token=top-output-secret",+ Success: true,+ RanAt: now,+ Note: "should not persist password=top-note-secret",+ },+ Result: &ExecutionResult{+ Success: false,+ Verification: &ActionVerificationResult{+ Ran: false,+ Command: "should not persist token=nested-command-secret",+ Output: "should not persist token=nested-output-secret",+ Success: true,+ RanAt: now,+ Note: "should not persist password=nested-note-secret",+ },+ },+ }++ redacted := RedactAuditRecord(record)+ if redacted.Verification == nil || redacted.Verification.Ran {+ t.Fatalf("expected normalized top-level ran=false verification, got %#v", redacted.Verification)+ }+ if redacted.Verification.Command != "" || redacted.Verification.Output != "" || redacted.Verification.Note != "" || redacted.Verification.Success || !redacted.Verification.RanAt.IsZero() {+ t.Fatalf("top-level ran=false verification retained details: %#v", redacted.Verification)+ }+ if redacted.Result == nil || redacted.Result.Verification == nil || redacted.Result.Verification.Ran {+ t.Fatalf("expected normalized nested ran=false verification, got %#v", redacted.Result)+ }+ if redacted.Result.Verification.Command != "" || redacted.Result.Verification.Output != "" || redacted.Result.Verification.Note != "" || redacted.Result.Verification.Success || !redacted.Result.Verification.RanAt.IsZero() {+ t.Fatalf("nested ran=false verification retained details: %#v", redacted.Result.Verification)+ }}// actionResultStub builds a result fixture with secret-shaped output and-// error message for the audit-record redaction test.+// verification details for the audit-record redaction test.func actionResultStub() *ExecutionResult {+ now := time.Now().UTC()return &ExecutionResult{Success: false,Output: "ran: PASSWORD=hunter2 service start && exit 1",ErrorMessage: "auth failed: api_key=leakedkey not accepted",+ Verification: &ActionVerificationResult{+ Ran: true,+ Command: "curl -H 'Authorization: Bearer nested-command-secret' https://api.example.com/status",+ Output: `payload {"token":"nested-output-secret","state":"active"}`,+ Success: true,+ RanAt: now,+ Note: "nested check completed with api_key=nested-note-secret",+ },}}diff --git a/internal/unifiedresources/store_test.go b/internal/unifiedresources/store_test.goindex c80632bddb..316870c7fc 100644--- a/internal/unifiedresources/store_test.go+++ b/internal/unifiedresources/store_test.go@@ -1236,13 +1236,14 @@ func TestActionAuditRecord_RoundTrip(t *testing.T) {approvedAt := now.Add(2 * time.Minute)result := &ExecutionResult{Success: true,- Output: "completed",+ Output: "completed token=result-output-secret",Verification: &ActionVerificationResult{Ran: true,- Command: "systemctl is-active 'nginx'",- Output: "active",+ Command: "systemctl is-active 'nginx' token=verify-command-secret",+ Output: "active token=verify-output-secret",Success: true,RanAt: now.Add(4 * time.Minute),+ Note: "verified via password=verify-note-secret",},}@@ -1313,19 +1314,34 @@ func TestActionAuditRecord_RoundTrip(t *testing.T) {if len(got.Approvals) != 1 || got.Approvals[0].Actor != record.Approvals[0].Actor || got.Approvals[0].Outcome != record.Approvals[0].Outcome {t.Fatalf("approvals round-trip failed: %+v", got.Approvals)}- if got.Result == nil || !got.Result.Success || got.Result.Output != result.Output {+ if got.Result == nil || !got.Result.Success {t.Fatalf("result round-trip failed: %+v", got.Result)}+ if strings.Contains(got.Result.Output, "result-output-secret") || !strings.Contains(got.Result.Output, "completed") {+ t.Fatalf("result output redaction failed: %+v", got.Result)+ }verification := CanonicalActionVerification(got)- if verification == nil || !verification.Ran || verification.Command != result.Verification.Command {+ if verification == nil || !verification.Ran {t.Fatalf("canonical verification round-trip failed: %+v", verification)}+ if strings.Contains(verification.Command, "verify-command-secret") || !strings.Contains(verification.Command, "systemctl is-active 'nginx'") {+ t.Fatalf("canonical verification command redaction failed: %+v", verification)+ }+ if strings.Contains(verification.Output, "verify-output-secret") || !strings.Contains(verification.Output, "active") {+ t.Fatalf("canonical verification output redaction failed: %+v", verification)+ }+ if strings.Contains(verification.Note, "verify-note-secret") || !strings.Contains(verification.Note, "verified via") {+ t.Fatalf("canonical verification note redaction failed: %+v", verification)+ }if got.Verification == nil || got.Verification.Command != verification.Command {t.Fatalf("top-level verification was not restored from sqlite row: top-level=%+v canonical=%+v", got.Verification, verification)}if got.Result.Verification == nil || got.Result.Verification.Command != verification.Command {t.Fatalf("result verification did not stay aligned with canonical verification: result=%+v canonical=%+v", got.Result.Verification, verification)}+ if got.Result.Verification.Note != verification.Note {+ t.Fatalf("result verification note did not stay aligned with canonical verification: result=%+v canonical=%+v", got.Result.Verification, verification)+ }}func TestActionAuditRecord_RoundTripLegacyResultVerificationCanonicalizesSQLiteRead(t *testing.T) {