fix(audit): recursive redaction for nested maps and inlined secrets (PILOT-304)#27
fix(audit): recursive redaction for nested maps and inlined secrets (PILOT-304)#27matthew-pilot wants to merge 1 commit into
Conversation
…PILOT-304)
BuildEntry previously only redacted top-level attribute keys. Nested
maps (e.g. config={token=sk-abc}) and string values containing
embedded secrets (e.g. stringified JSON, key=value pairs) bypassed
redaction entirely.
Adds formatVal/formatMap to recursively walk map values, plus
scanSecrets to scan string values for known secret patterns
(token=, "token":") and replace them with <redacted>.
Scope: audit/audit.go (+113/-8), audit/zz_redaction_test.go (+53)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📊 PR Status — #27 PILOT-304
CI Checks (2/2 passing)
Canary🧪 Running — dispatched run JiraPILOT-304 — QA/IN-REVIEW (unassigned). Updated: 2026-05-30T22:11 EEST. Last operator activityPR created by matthew-pilot at 19:11 UTC. No operator activity yet. |
🔍 PR Explanation — #27 PILOT-304What this doesExtends audit entry redaction from top-level keys only to recursive deep inspection: nested maps, deeply-nested maps, and inline secrets embedded in string values (e.g. JSON blobs or The problemThe existing Walkthrough: 2 files (+158/−8)
Why this approach
|
What
BuildEntrypreviously only redacted top-level attribute keys viaredactKey(). If an attribute value was:map[string]interface{}with nested secret keys (e.g.config={token=sk-abc})key=valuepairs)…the secrets landed verbatim in the audit log.
Fix
formatVal— dispatches to recursive map-walker or string-scanner based on value typeformatMap— recursively walks maps, redacting secret keys at any depthscanSecrets— scans string values for known secret patterns (token=,"token":") and replaces values with<redacted>Scope
Verification
go build ./...✓go vet ./...✓Ticket
Closes PILOT-304: audit redaction — only top-level keys checked, nested values bypass