feat: structured audit logging with agent and secret attribution#149
Open
johnthompson-ybor wants to merge 1 commit into
Open
feat: structured audit logging with agent and secret attribution#149johnthompson-ybor wants to merge 1 commit into
johnthompson-ybor wants to merge 1 commit into
Conversation
Adds per-request audit logging to the gateway with three levels controlled by AUDIT_LOG env var: - (unset): minimal logging, same as before - "basic": agent name, hostname, method, status, secrets used - "full": adds request path (may contain sensitive data / PHI) Blocked and rate-limited requests always log agent + path regardless of level. Changes: - db.rs: add name to AgentRow and SecretRow, update SQL queries - inject.rs: add source_name to InjectionRule for credential attribution - connect.rs: pass secret names and agent name through ConnectResponse - gateway.rs: structured AUDIT log in forward_request with level check Closes onecli#54 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61f3271 to
e63c019
Compare
Author
|
This is a Claude-written PR, but we did this for our own use and I thought it would be useful for upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-request audit logging to the gateway. Every proxied request can be traced to which agent made it and which credential was injected.
Closes #54
Audit levels (
AUDIT_LOGenv var)basicfullBlocked (403) and rate-limited (429) requests always include path and status for security investigation.
Example output
AUDIT_LOG=basic:AUDIT_LOG=full:Changes
db.rsnametoAgentRowandSecretRow, update SQL queriesinject.rssource_nametoInjectionRulefor credential attributionconnect.rsConnectResponsegateway.rsforward_request()with level-based detailHIPAA / compliance notes
basicmode never logs request paths (which could contain PHI like patient IDs or PII)fullmode includes paths — intended for debugging onlywarnlevel for security investigationTesting
All 131 tests pass (126 unit + 5 integration). No existing behavior changes when
AUDIT_LOGis unset.