Skip to content

feat(api): optional stdout audit sink + surface dropped audit writes - #16

Merged
ValgulNecron merged 1 commit into
mainfrom
feat/api-audit-stdout-sink
Jun 30, 2026
Merged

ValgulNecron merged 1 commit into
mainfrom
feat/api-audit-stdout-sink

Conversation

@ValgulNecron

Copy link
Copy Markdown
Collaborator

What

Closes the remaining half of the README's audit limitation — "there is no external sink (S3/syslog)." Instead of a bespoke S3/syslog pusher, the API can mirror each audit event to stdout as a structured JSON line, so the cluster's existing log aggregator (Loki / ELK / CloudWatch — all scrape pod stdout) captures the audit trail. That's the Kubernetes-native external sink (rule 9: compose stock primitives — the pod's stdout is the log pipeline).

How

  • audit.New now takes functional options; WithStdoutSink(logger) enables the mirror. Off by default; events always still land in the database (the sink mirrors, never replaces).
  • Opt in via --audit-stdout / GAMEPLANE_AUDIT_STDOUT, surfaced through the Helm chart as api.audit.stdout.
  • Also stop silently discarding the audit INSERT error (_, _ = ExecContext → captured): a dropped security-audit write now logs a warning, so a hole in the trail is visible rather than invisible.
  • README known-limitations updated.

Tests

TestMiddleware_StdoutSink asserts the sink line carries the audited fields (actor/method/path/target/status) and the event still lands in the DB; TestMiddleware_NoSinkByDefault covers the default (no sink → no panic, still recorded). Verified helm template renders --audit-stdout only when api.audit.stdout=true.

Notes

No schema change (no migration). No Pencil pass (no dashboard surface). Builds on the merged #14 audit retention work.

🤖 Generated with Claude Code

Closes the remaining half of the documented audit limitation ("no
external sink"). Rather than build a bespoke S3/syslog pusher, mirror
each audit event to stdout as a structured JSON line so the cluster's
existing log aggregator (Loki/ELK/CloudWatch, all of which scrape pod
stdout) captures the audit trail — the Kubernetes-native external sink.

- audit.New takes functional options; WithStdoutSink(logger) enables the
  mirror. Off by default; events always still land in the database.
- Opt in via --audit-stdout / GAMEPLANE_AUDIT_STDOUT, surfaced through
  the Helm chart as api.audit.stdout.
- Also stop silently discarding the audit INSERT error: a dropped
  security-audit write now logs a warning so a hole in the trail is
  visible instead of invisible.
- README known-limitations updated.

Tests: the sink emits the audited fields and still records to the DB;
the default (no sink) path doesn't panic and still records.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: valgulnecron <39313199+ValgulNecron@users.noreply.github.com>
@ValgulNecron
ValgulNecron merged commit bfb3253 into main Jun 30, 2026
11 checks passed
@ValgulNecron
ValgulNecron deleted the feat/api-audit-stdout-sink branch June 30, 2026 11:10
@ValgulNecron
ValgulNecron restored the feat/api-audit-stdout-sink branch June 30, 2026 11:15
@ValgulNecron
ValgulNecron deleted the feat/api-audit-stdout-sink branch June 30, 2026 14:26
ValgulNecron pushed a commit that referenced this pull request Oct 11, 2026
modules: GameplanePanel/module#49 (hell-let-loose removed).
website: GameplanePanel/website#15 and #16 (module count text).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant