Files
Charon/backend/internal/models/notification_config.go
GitHub Actions 9ef8a1ce21 fix: add system permissions handler for diagnostics and repair
- Implemented SystemPermissionsHandler to check and repair file permissions.
- Added endpoints for retrieving and repairing permissions.
- Introduced utility functions for permission checks and error mapping.
- Created tests for the new handler and utility functions.
- Updated routes to include the new permissions endpoints.
- Enhanced configuration to support new logging and plugin directories.
2026-02-11 05:33:19 +00:00

42 lines
1.4 KiB
Go

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// NotificationConfig stores configuration for security notifications.
type NotificationConfig struct {
ID string `gorm:"primaryKey" json:"id"`
Enabled bool `json:"enabled"`
MinLogLevel string `json:"min_log_level"` // error, warn, info, debug
WebhookURL string `json:"webhook_url"`
NotifyWAFBlocks bool `json:"notify_waf_blocks"`
NotifyACLDenies bool `json:"notify_acl_denies"`
NotifyRateLimitHits bool `json:"notify_rate_limit_hits"`
EmailRecipients string `json:"email_recipients"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// BeforeCreate sets the ID if not already set.
func (nc *NotificationConfig) BeforeCreate(tx *gorm.DB) error {
if nc.ID == "" {
nc.ID = uuid.New().String()
}
return nil
}
// SecurityEvent represents a security event for notification dispatch.
type SecurityEvent struct {
EventType string `json:"event_type"` // waf_block, acl_deny, etc.
Severity string `json:"severity"` // error, warn, info
Message string `json:"message"`
ClientIP string `json:"client_ip"`
Path string `json:"path"`
Timestamp time.Time `json:"timestamp"`
Metadata map[string]any `json:"metadata"`
}