Documentation
¶
Overview ¶
Package audit provides self-audit logging for the tool's own actions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigChangeDetails ¶
type ConfigChangeDetails struct {
Key string `json:"key"`
OldValue string `json:"old_value,omitempty"`
NewValue string `json:"new_value"`
}
ConfigChangeDetails contains details for config change actions.
type DatabaseInitDetails ¶
type DatabaseInitDetails struct {
Path string `json:"path"`
SchemaVersion string `json:"schema_version"`
}
DatabaseInitDetails contains details for database initialization.
type ExportDetails ¶
type ExportDetails struct {
Format string `json:"format"`
EventCount int `json:"event_count"`
OutputPath string `json:"output_path,omitempty"`
}
ExportDetails contains details for export actions.
type HookErrorDetails ¶ added in v0.5.0
type HookErrorDetails struct {
HookType string `json:"hook_type"`
RawDataSize int `json:"raw_data_size"`
}
HookErrorDetails contains details for hook error actions.
type InstallDetails ¶
type InstallDetails struct {
HooksInstalled []string `json:"hooks_installed"`
BackupPath string `json:"backup_path,omitempty"`
}
InstallDetails contains details for install actions.
type RetentionCleanupDetails ¶
type RetentionCleanupDetails struct {
EventsDeleted int `json:"events_deleted"`
OldestRemaining time.Time `json:"oldest_remaining,omitempty"`
}
RetentionCleanupDetails contains details for retention cleanup actions.
type RetentionPolicy ¶
type RetentionPolicy struct {
// RetentionDays is the number of days to keep events (0 = never delete).
RetentionDays int
// KeepSelfAudit indicates whether to exempt self-audit entries from retention.
KeepSelfAudit bool
}
RetentionPolicy defines the data retention settings.
func DefaultRetentionPolicy ¶
func DefaultRetentionPolicy() *RetentionPolicy
DefaultRetentionPolicy returns the default retention policy (90 days).
func NewRetentionPolicy ¶
func NewRetentionPolicy(days int) *RetentionPolicy
NewRetentionPolicy creates a new RetentionPolicy with the given retention days.
func (*RetentionPolicy) CutoffTime ¶
func (p *RetentionPolicy) CutoffTime() time.Time
CutoffTime returns the time before which events should be deleted. Returns zero time if retention is disabled (RetentionDays == 0).
func (*RetentionPolicy) IsEnabled ¶
func (p *RetentionPolicy) IsEnabled() bool
IsEnabled returns true if retention is enabled.
func (*RetentionPolicy) ShouldDelete ¶
func (p *RetentionPolicy) ShouldDelete(eventTime time.Time) bool
ShouldDelete returns true if an event with the given timestamp should be deleted.
type SelfAudit ¶
type SelfAudit struct {
// ID is the unique identifier for this audit entry.
ID uuid.UUID `json:"id"`
// Timestamp is when the action occurred (UTC).
Timestamp time.Time `json:"timestamp"`
// Action is the type of action performed.
Action SelfAuditAction `json:"action"`
// AgentName is the relevant agent, if applicable.
AgentName string `json:"agent_name,omitempty"`
// Details contains action-specific data.
Details json.RawMessage `json:"details,omitempty"`
// Result is the outcome of the action.
Result SelfAuditResult `json:"result"`
// ErrorMessage contains error details if failed.
ErrorMessage string `json:"error_message,omitempty"`
// ToolVersion is the version of the tool that performed the action.
ToolVersion string `json:"tool_version"`
}
SelfAudit represents a log entry for the tool's own actions.
func NewSelfAudit ¶
func NewSelfAudit(action SelfAuditAction, toolVersion string) *SelfAudit
NewSelfAudit creates a new SelfAudit entry with a generated UUID.
func (*SelfAudit) MarkSkipped ¶
MarkSkipped marks the audit as skipped.
func (*SelfAudit) WithDetails ¶
WithDetails sets the Details from a given struct.
type SelfAuditAction ¶
type SelfAuditAction string
SelfAuditAction represents the type of action the tool performed.
const ( // ActionInstall indicates hooks were installed for an agent. ActionInstall SelfAuditAction = "install" // ActionUninstall indicates hooks were removed from an agent. ActionUninstall SelfAuditAction = "uninstall" // ActionConfigChange indicates configuration was modified. ActionConfigChange SelfAuditAction = "config_change" // ActionExport indicates data was exported. ActionExport SelfAuditAction = "export" // ActionPurge indicates database or config was purged. ActionPurge SelfAuditAction = "purge" // ActionUpgrade indicates the tool was upgraded. ActionUpgrade SelfAuditAction = "upgrade" // ActionDatabaseInit indicates the database was initialized. ActionDatabaseInit SelfAuditAction = "database_init" // ActionRetentionCleanup indicates old events were deleted. ActionRetentionCleanup SelfAuditAction = "retention_cleanup" // ActionHookError indicates a hook invocation failed. ActionHookError SelfAuditAction = "hook_error" )
func (SelfAuditAction) String ¶
func (a SelfAuditAction) String() string
String returns the string representation of a SelfAuditAction.
type SelfAuditResult ¶
type SelfAuditResult string
SelfAuditResult represents the outcome of a self-audit action.
const ( // ResultSuccess indicates the action completed successfully. ResultSuccess SelfAuditResult = "success" // ResultError indicates the action failed with an error. ResultError SelfAuditResult = "error" // ResultSkipped indicates the action was skipped. ResultSkipped SelfAuditResult = "skipped" )
func (SelfAuditResult) String ¶
func (r SelfAuditResult) String() string
String returns the string representation of a SelfAuditResult.
type UninstallDetails ¶
type UninstallDetails struct {
HooksRemoved []string `json:"hooks_removed"`
BackupRestored bool `json:"backup_restored"`
}
UninstallDetails contains details for uninstall actions.