Documentation
¶
Overview ¶
Package audit provides audit logging for MCP tool calls.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReloadConfig ¶ added in v1.1.1
func ReloadConfig()
ReloadConfig re-parses configuration from environment variables. Exported for testing purposes.
Types ¶
type AuditConfig ¶ added in v1.1.1
type AuditConfig struct {
// MaxFileSize is the maximum size of a single audit log file before rotation.
MaxFileSize int64
// MaxBackups is the maximum number of rotated backup files to retain.
MaxBackups int
// MaxAgeDays is the maximum age of a rotated backup file in days before deletion.
MaxAgeDays int
}
AuditConfig holds the configuration for audit log rotation. These values are set at package initialization from environment variables.
func GetConfig ¶ added in v1.1.1
func GetConfig() AuditConfig
GetConfig returns the current audit configuration.
type ErrorInfo ¶ added in v1.1.0
type ErrorInfo struct {
Timestamp string `json:"ts"`
Action string `json:"action"`
Reason string `json:"reason,omitempty"`
OK bool `json:"ok"`
}
ErrorInfo represents a redacted error from audit logs.
type HealthStatus ¶ added in v1.1.0
type HealthStatus struct {
LogFilePath string `json:"log_file_path"`
LogFileAge string `json:"log_file_age"`
LastEntryTime string `json:"last_entry_time,omitempty"`
Agent string `json:"agent"`
TotalAuditSize int64 `json:"total_audit_size_bytes"`
LogFileSize int64 `json:"log_file_size_bytes"`
ErrorCount int `json:"error_count_last_100"`
LastEntryOK *bool `json:"last_entry_ok,omitempty"`
OK bool `json:"ok"`
WriteAccessible bool `json:"write_accessible"`
NeedsRotation bool `json:"needs_rotation"`
NeedsRetention bool `json:"needs_retention"`
}
HealthStatus represents the health status of audit logging.
type LogEntry ¶
type LogEntry struct {
Timestamp string `json:"ts"`
Agent string `json:"agent"`
Action string `json:"action"`
Path string `json:"path,omitempty"`
Field string `json:"field,omitempty"`
Transport string `json:"transport,omitempty"`
Reason string `json:"reason,omitempty"`
DurMs int64 `json:"dur_ms,omitempty"`
OK bool `json:"ok"`
}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) EnforceRetention ¶ added in v1.1.0
EnforceRetention removes old rotated files based on retention policy: - Removes oldest files if count exceeds MaxBackups - Removes files older than MaxAgeDays
func (*Logger) GetErrors ¶ added in v1.1.0
GetErrors returns redacted error entries from the audit log.
func (*Logger) HealthCheck ¶ added in v1.1.0
func (l *Logger) HealthCheck() (*HealthStatus, error)
HealthCheck returns the health status of the audit logger.