Documentation
¶
Index ¶
- Variables
- func CleanSQLCommand(cmd string) string
- func WatchConfig(filePath string, reloadCallback func(*PastaayConfig)) error
- func WatchK8sConfigMap(ctx context.Context, cmName, cmKey string, interval time.Duration, ...) error
- func WatchRedisPubSub(ctx context.Context, client *redis.Client, channel string, wg *sync.WaitGroup, ...) error
- func WebhookHandler(expectedToken string, reloadCallback func(*PastaayConfig)) http.HandlerFunc
- type Manager
- func (m *Manager) GetActivePolicies(policyType string) []Policy
- func (m *Manager) GetSensorStatuses() map[string]string
- func (m *Manager) IsCleanCommandIgnored(protocol string, cleanCmd string) bool
- func (m *Manager) IsCommandIgnored(protocol string, cmd string) bool
- func (m *Manager) SetSensorStatus(name, status string)
- func (m *Manager) Update(newCfg *PastaayConfig)
- type PastaayConfig
- type Policy
- type RedisAck
- type WebhookResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultProtectedCommands = map[string][]string{
"sql": {"CREATE", "ALTER", "DROP", "TRUNCATE"},
"mongo": {"create", "createIndexes", "drop", "collMod"},
"redis": {"PING", "INFO", "CONFIG"},
"grpc": {"grpc.health.v1.Health"},
"kafka": {"__consumer_offsets", "_schemas", "__transaction_state"},
"rabbitmq": {"amq.", "reply_"},
}
Functions ¶
func CleanSQLCommand ¶ added in v1.6.0
func WatchConfig ¶
func WatchConfig(filePath string, reloadCallback func(*PastaayConfig)) error
func WatchK8sConfigMap ¶ added in v1.9.0
func WatchK8sConfigMap(ctx context.Context, cmName, cmKey string, interval time.Duration, mgr *Manager) error
WatchK8sConfigMap polls K8s API and reports health status to the Manager.
func WatchRedisPubSub ¶ added in v1.9.0
func WebhookHandler ¶ added in v1.9.0
func WebhookHandler(expectedToken string, reloadCallback func(*PastaayConfig)) http.HandlerFunc
WebhookHandler provides a memory-bounded, constant-time authenticated endpoint.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(initialConfig *PastaayConfig) *Manager
func (*Manager) GetActivePolicies ¶ added in v1.5.0
func (*Manager) GetSensorStatuses ¶ added in v1.9.0
func (*Manager) IsCleanCommandIgnored ¶ added in v1.6.0
func (*Manager) IsCommandIgnored ¶ added in v1.5.0
func (*Manager) SetSensorStatus ¶ added in v1.9.0
func (*Manager) Update ¶
func (m *Manager) Update(newCfg *PastaayConfig)
type PastaayConfig ¶
type PastaayConfig struct {
Version int `yaml:"version"`
WarmupDuration time.Duration `yaml:"warmup_duration"`
EnableDefaultIgnored bool `yaml:"enable_default_ignored"`
IgnoredCommands map[string][]string `yaml:"ignored_commands"`
Policies []Policy `yaml:"policies"`
}
func LoadConfig ¶
func LoadConfig(filePath string) (*PastaayConfig, error)
LoadConfig reads and parses the YAML configuration file from the given path.
func (*PastaayConfig) Validate ¶ added in v1.9.0
func (c *PastaayConfig) Validate() error
Validate performs strict bounds checking and protocol-specific sanity checks.
type Policy ¶
type Policy struct {
Name string `yaml:"name"`
Target string `yaml:"target"`
Type string `yaml:"type"`
LatencyChance float64 `yaml:"latency_chance"`
LatencyDuration time.Duration `yaml:"latency_duration"`
ErrorChance float64 `yaml:"error_chance"`
ErrorCode int `yaml:"error_code,omitempty"`
ErrorBody string `yaml:"error_body,omitempty"`
MatchHeaders map[string]string `yaml:"match_headers,omitempty"`
DropConnection bool `yaml:"drop_connection,omitempty"`
StreamRollMode string `yaml:"stream_roll_mode,omitempty"`
ThrottleThreshold int `yaml:"throttle_threshold,omitempty"`
RAMChunkMB int `yaml:"ram_chunk_mb,omitempty"`
RAMInterval time.Duration `yaml:"ram_interval,omitempty"`
CompiledRegex *regexp.Regexp `yaml:"-"`
PolicyHash uint64 `yaml:"-"`
IsWildcard bool `yaml:"-"`
WildcardPrefix string `yaml:"-"`
}
type WebhookResponse ¶ added in v1.9.0
Click to show internal directories.
Click to hide internal directories.