enhancement: audit-channel hook on every secret.Get (ai) #5
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
heiko/secret#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
enhancement: audit-channel hook on every
secret.Get(ai)Summary
secret.Get(spec)resolves credentials silently. There is nohook for emitting an audit-channel record naming the
resolution: which scheme was used, which fallback candidate
won, success or failure, the OS-level reason on failure
(file-not-found, env-unset, mode-too-permissive). Consumers
that need security-event review for credential access have to
wrap every call site themselves.
Proposed addition
A package-level audit-logger hook, similar to the standard-
library
slog.Default()pattern:Or, if a global is too implicit for the project's taste, a
context-carried logger:
I lean global.
secret.Getis intentionally a low-ceremony API;threading a context through every call site for an
observability concern adds a lot of boilerplate.
Why this belongs upstream
Security-conscious deployments typically have a security-review
step that asks "what credentials were resolved when this process
started, and which scheme did each come from?" Today every
consumer either:
Getcall (boilerplateUpstream emission means consumers get the audit trail "for
free" by installing a logger once at startup.
The dmarc project requires this in spec 1.2 §"Audit channel"
(every credential resolution emits a record on the
unfilterable audit channel). dmarc wrapped
secret.Getininternal/secret/resolver.goto add this; ~160 LOC of which~40 LOC is the audit emission.
Compatibility
Purely additive. Default behavior (nil logger / no
WithAuditLogger) is the current silent behavior. Existingcallers see no change.
What dmarc does today
internal/secret/resolver.gowrapssecret.Getwith:slog-based audit emission (level=audit component=secret phase=runtime msg=resolved scheme=... status=...),spec emit one record per unique resolution, not one per
goroutine.
(2) is dmarc-specific and not part of this request — keeping
the audit hook minimal so consumers who don't want
deduplication aren't forced into it.
References
https://git.schlittermann.de/heiko/dmarc/src/branch/dev/docs/specs/1.2-config-and-logging.md
https://git.schlittermann.de/heiko/dmarc/src/branch/dev/internal/secret/resolver.go