config

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

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 CleanSQLCommand(cmd string) string

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 WatchRedisPubSub(ctx context.Context, client *redis.Client, channel string, wg *sync.WaitGroup, mgr *Manager) error

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 (m *Manager) GetActivePolicies(policyType string) []Policy

func (*Manager) GetSensorStatuses added in v1.9.0

func (m *Manager) GetSensorStatuses() map[string]string

func (*Manager) IsCleanCommandIgnored added in v1.6.0

func (m *Manager) IsCleanCommandIgnored(protocol string, cleanCmd string) bool

func (*Manager) IsCommandIgnored added in v1.5.0

func (m *Manager) IsCommandIgnored(protocol string, cmd string) bool

func (*Manager) SetSensorStatus added in v1.9.0

func (m *Manager) SetSensorStatus(name, status string)

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 RedisAck added in v1.9.0

type RedisAck struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

type WebhookResponse added in v1.9.0

type WebhookResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Details string `json:"details,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL