Skip to content

Commit 88cbda5

Browse files
f0sselclaude
andcommitted
Restructure audit package and remove Reason field
- Split audit.go into separate files: - request.go: Request struct and HTTPRequestToAuditRequest function - logging_auditor.go: LoggingAuditor implementation and Auditor interface - Move LoggingAuditor tests to logging_auditor_test.go - Keep general audit tests (HTTPRequestToAuditRequest) in request_test.go - Remove Request.Reason field and ReasonNoMatchingRules constant - Update proxy to use concrete LoggingAuditor type instead of interface - Simplify audit logging by removing reason parameter from DENY logs - All tests pass with improved organization and cleaner API 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 9d90af3 commit 88cbda5

File tree

6 files changed

+289
-263
lines changed

6 files changed

+289
-263
lines changed

audit/audit.go

Lines changed: 0 additions & 60 deletions
This file was deleted.

audit/logging_auditor.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package audit
2+
3+
import "log/slog"
4+
5+
// LoggingAuditor implements Auditor by logging to slog
6+
type LoggingAuditor struct {
7+
logger *slog.Logger
8+
}
9+
10+
// NewLoggingAuditor creates a new LoggingAuditor
11+
func NewLoggingAuditor(logger *slog.Logger) *LoggingAuditor {
12+
return &LoggingAuditor{
13+
logger: logger,
14+
}
15+
}
16+
17+
// AuditRequest logs the request using structured logging
18+
func (a *LoggingAuditor) AuditRequest(req *Request) {
19+
if req.Allowed {
20+
a.logger.Info("ALLOW",
21+
"method", req.Method,
22+
"url", req.URL,
23+
"rule", req.Rule)
24+
} else {
25+
a.logger.Warn("DENY",
26+
"method", req.Method,
27+
"url", req.URL)
28+
}
29+
}

0 commit comments

Comments
 (0)