Documentation
¶
Overview ¶
Package audit provides shared audit logging functionality
Index ¶
- type AuditEvent
- type AuditFormat
- type AuditLogger
- func (l *AuditLogger) FilterEvents(options FilterOptions) []AuditEvent
- func (l *AuditLogger) GenerateComplianceReport(writer io.Writer, options ComplianceReportOptions) error
- func (l *AuditLogger) LogBackupCreated(bundleID, targetDir, backupPath string)
- func (l *AuditLogger) LogEvent(event, component, id string, details map[string]interface{})
- func (l *AuditLogger) LogEventWithStatus(event, component, id, status string, details map[string]interface{})
- func (l *AuditLogger) LogFileInstallation(bundleID, filePath string, success bool, details map[string]interface{})
- func (l *AuditLogger) LogImportComplete(bundleID string, success bool, details map[string]interface{})
- func (l *AuditLogger) LogImportStart(bundleID, bundlePath string, options map[string]interface{})
- func (l *AuditLogger) LogImportSummary(bundleID string, stats map[string]interface{})
- func (l *AuditLogger) LogValidation(bundleID, bundlePath string, level string, success bool, ...)
- type AuditLoggerOptions
- type ComplianceReportOptions
- type ComplianceReportSummary
- type ComplianceReportType
- type FilterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEvent ¶
type AuditEvent struct {
// Timestamp is the time the event occurred
Timestamp time.Time `json:"timestamp"`
// EventType is the type of event
EventType string `json:"event_type"`
// Component is the component associated with the event
Component string `json:"component"`
// User is the user who triggered the event
User string `json:"user,omitempty"`
// ID is the ID associated with the event
ID string `json:"id,omitempty"`
// Operation is the specific operation being performed
Operation string `json:"operation,omitempty"`
// Status is the status of the operation (success, failure, in-progress)
Status string `json:"status,omitempty"`
// Details contains additional details about the event
Details map[string]interface{} `json:"details,omitempty"`
}
AuditEvent represents an audit event
type AuditFormat ¶
type AuditFormat string
AuditFormat represents the format for exporting audit logs
const ( // JSONAuditFormat represents JSON format for audit logs JSONAuditFormat AuditFormat = "json" // CSVAuditFormat represents CSV format for audit logs CSVAuditFormat AuditFormat = "csv" )
type AuditLogger ¶
type AuditLogger struct {
// Writer is the writer for audit logs
Writer io.Writer
// User is the user performing the operation
User string
// Events stores audit events if enabled
Events []AuditEvent
// StoreEvents indicates whether to store events in memory
StoreEvents bool
}
AuditLogger implements audit logging functionality
func NewAuditLogger ¶
func NewAuditLogger(writer io.Writer, user string) *AuditLogger
NewAuditLogger creates a new audit logger
func NewFileAuditLogger ¶
func NewFileAuditLogger(filePath string) (*AuditLogger, error)
NewFileAuditLogger creates a new audit logger that writes to a file
func (*AuditLogger) FilterEvents ¶
func (l *AuditLogger) FilterEvents(options FilterOptions) []AuditEvent
FilterEvents filters audit events based on the provided options
func (*AuditLogger) GenerateComplianceReport ¶
func (l *AuditLogger) GenerateComplianceReport(writer io.Writer, options ComplianceReportOptions) error
GenerateComplianceReport generates a compliance report based on audit logs
func (*AuditLogger) LogBackupCreated ¶
func (l *AuditLogger) LogBackupCreated(bundleID, targetDir, backupPath string)
LogBackupCreated logs a backup creation event
func (*AuditLogger) LogEvent ¶
func (l *AuditLogger) LogEvent(event, component, id string, details map[string]interface{})
LogEvent logs an event
func (*AuditLogger) LogEventWithStatus ¶
func (l *AuditLogger) LogEventWithStatus(event, component, id, status string, details map[string]interface{})
LogEventWithStatus logs an event with a status
func (*AuditLogger) LogFileInstallation ¶
func (l *AuditLogger) LogFileInstallation(bundleID, filePath string, success bool, details map[string]interface{})
LogFileInstallation logs a file installation event
func (*AuditLogger) LogImportComplete ¶
func (l *AuditLogger) LogImportComplete(bundleID string, success bool, details map[string]interface{})
LogImportComplete logs the completion of an import operation
func (*AuditLogger) LogImportStart ¶
func (l *AuditLogger) LogImportStart(bundleID, bundlePath string, options map[string]interface{})
LogImportStart logs the start of an import operation
func (*AuditLogger) LogImportSummary ¶
func (l *AuditLogger) LogImportSummary(bundleID string, stats map[string]interface{})
LogImportSummary logs a summary of the import operation
func (*AuditLogger) LogValidation ¶
func (l *AuditLogger) LogValidation(bundleID, bundlePath string, level string, success bool, details map[string]interface{})
LogValidation logs a validation event
type AuditLoggerOptions ¶
type AuditLoggerOptions struct {
// Writer is the writer for audit logs
Writer io.Writer
// User is the user performing the operation
User string
// EnableConsoleOutput indicates whether to output to console
EnableConsoleOutput bool
// StoreEvents indicates whether to store events in memory
StoreEvents bool
// LogFilePath is the path to the log file
LogFilePath string
}
AuditLoggerOptions contains options for creating a new audit logger
type ComplianceReportOptions ¶
type ComplianceReportOptions struct {
// ReportType is the type of report to generate
ReportType ComplianceReportType
// Filter contains filtering options for the report
Filter FilterOptions
// Format is the format of the report
Format AuditFormat
// IncludeSystemEvents indicates whether to include system events
IncludeSystemEvents bool
}
ComplianceReportOptions defines options for generating compliance reports
type ComplianceReportSummary ¶
type ComplianceReportSummary struct {
// ReportType is the type of report
ReportType ComplianceReportType `json:"report_type"`
// GeneratedAt is the time the report was generated
GeneratedAt time.Time `json:"generated_at"`
// TimeRange contains the time range for the report
TimeRange struct {
Start time.Time `json:"start,omitempty"`
End time.Time `json:"end,omitempty"`
} `json:"time_range,omitempty"`
// EventCounts contains counts of events by type
EventCounts map[string]int `json:"event_counts,omitempty"`
// BundleCounts contains counts of events by bundle ID
BundleCounts map[string]int `json:"bundle_counts,omitempty"`
// StatusCounts contains counts of events by status
StatusCounts map[string]int `json:"status_counts,omitempty"`
// UserCounts contains counts of events by user
UserCounts map[string]int `json:"user_counts,omitempty"`
// TotalEvents is the total number of events
TotalEvents int `json:"total_events"`
}
ComplianceReportSummary contains summary information for a compliance report
type ComplianceReportType ¶
type ComplianceReportType string
ComplianceReportType defines the type of compliance report to generate
const ( // DetailedReport includes all audit events with full details DetailedReport ComplianceReportType = "detailed" // SummaryReport includes summarized information about audit events SummaryReport ComplianceReportType = "summary" // ActivityReport includes activity-based information ActivityReport ComplianceReportType = "activity" )
type FilterOptions ¶
type FilterOptions struct {
// StartTime is the start time for filtering events
StartTime *time.Time
// EndTime is the end time for filtering events
EndTime *time.Time
// EventTypes is a list of event types to include
EventTypes []string
// IDs is a list of IDs to include
IDs []string
// BundleIDs is a list of bundle IDs to include
BundleIDs []string
// Statuses is a list of statuses to include
Statuses []string
// Users is a list of users to include
Users []string
}
FilterOptions defines options for filtering audit events