- Replace Go interface{} with any (Go 1.18+ standard)
- Add database indexes to frequently queried model fields
- Add JSDoc documentation to frontend API client methods
- Remove deprecated docker-compose version keys
- Add concurrency groups to all 25 GitHub Actions workflows
- Add YAML front matter and fix H1→H2 headings in docs
Coverage: Backend 85.5%, Frontend 87.73%
Security: No vulnerabilities detected
Refs: docs/plans/instruction_compliance_spec.md
40 lines
1.2 KiB
Go
40 lines
1.2 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"`
|
|
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"`
|
|
}
|