events

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package events provides Hockeypuck-compatible event system This bridges between Hockeypuck's KeyChange notifications and our flexible plugin event bus

Index

Constants

View Source
const (
	// Storage events (bridge to Hockeypuck KeyChange)
	EventStorageKeyAdded      = "storage.key.added"
	EventStorageKeyRemoved    = "storage.key.removed"
	EventStorageKeyReplaced   = "storage.key.replaced"
	EventStorageKeyNotChanged = "storage.key.not_changed"

	// Security events (plugin ecosystem)
	EventSecurityThreatDetected     = "security.threat.detected"
	EventSecurityAnomalyDetected    = "security.anomaly.detected"
	EventSecurityRateLimitTriggered = "security.ratelimit.triggered"
	EventSecurityRiskAssessment     = "security.risk.assessment"

	// Zero Trust events
	EventZTNAAuthenticationRequired = "ztna.authentication.required"
	EventZTNAAccessGranted          = "ztna.access.granted"
	EventZTNAAccessDenied           = "ztna.access.denied"
	EventZTNARiskScoreUpdated       = "ztna.risk.score.updated"
	EventZTNASessionCreated         = "ztna.session.created"
	EventZTNASessionTerminated      = "ztna.session.terminated"

	// Rate limiting events
	EventRateLimitViolation    = "ratelimit.violation"
	EventRateLimitThresholdHit = "ratelimit.threshold.hit"
	EventRateLimitGeoAnomaly   = "ratelimit.geo.anomaly"
	EventRateLimitMLAnomaly    = "ratelimit.ml.anomaly"

	// Endpoint protection events
	EventEndpointProtectionRequest = "endpoint.protection.request"
	EventEndpointProtectionUpdate  = "endpoint.protection.update"
	EventEndpointAccessDenied      = "endpoint.access.denied"
	EventEndpointAccessGranted     = "endpoint.access.granted"

	// Plugin coordination events
	EventPluginLoaded        = "plugin.loaded"
	EventPluginUnloaded      = "plugin.unloaded"
	EventPluginError         = "plugin.error"
	EventPluginConfigUpdated = "plugin.config.updated"
)

Event type constants aligned with Hockeypuck patterns

Variables

This section is empty.

Functions

This section is empty.

Types

type EndpointProtectionRequest

type EndpointProtectionRequest struct {
	Action      string   `json:"action"`       // "protect" or "whitelist"
	Paths       []string `json:"paths"`        // Endpoint paths
	Reason      string   `json:"reason"`       // Reason for request
	RequesterID string   `json:"requester_id"` // Plugin requesting
	Temporary   bool     `json:"temporary"`    // Whether temporary
	Duration    string   `json:"duration"`     // Duration for temporary
	Priority    int      `json:"priority"`     // Priority level
}

EndpointProtectionRequest represents endpoint protection requests

type EventBus

type EventBus struct {
	// contains filtered or unexported fields
}

EventBus provides a unified event system compatible with Hockeypuck patterns

func NewEventBus

func NewEventBus(logger *log.Logger) *EventBus

NewEventBus creates a new event bus

func (*EventBus) NotifyKeyChange

func (eb *EventBus) NotifyKeyChange(change hkpstorage.KeyChange) error

NotifyKeyChange notifies all key change handlers (Hockeypuck compatibility)

func (*EventBus) PublishEvent

func (eb *EventBus) PublishEvent(event PluginEvent) error

PublishEvent publishes a generic plugin event

func (*EventBus) PublishRateLimitViolation

func (eb *EventBus) PublishRateLimitViolation(violation RateLimitViolation) error

PublishRateLimitViolation publishes a rate limit violation event

func (*EventBus) PublishThreatDetected

func (eb *EventBus) PublishThreatDetected(threatInfo ThreatInfo) error

PublishThreatDetected publishes a threat detection event

func (*EventBus) PublishZTNAEvent

func (eb *EventBus) PublishZTNAEvent(eventType string, ztnaEvent ZTNAEvent) error

PublishZTNAEvent publishes a Zero Trust event

func (*EventBus) SubscribeEvent

func (eb *EventBus) SubscribeEvent(eventType string, handler PluginEventHandler) error

SubscribeEvent subscribes to generic plugin events

func (*EventBus) SubscribeKeyChanges

func (eb *EventBus) SubscribeKeyChanges(handler func(hkpstorage.KeyChange) error) error

SubscribeKeyChanges subscribes to Hockeypuck-style key change notifications

type PluginEvent

type PluginEvent struct {
	Type      string                 `json:"type"`
	Source    string                 `json:"source"`
	Timestamp time.Time              `json:"timestamp"`
	Data      map[string]interface{} `json:"data"`
}

PluginEvent represents a generic plugin event

type PluginEventHandler

type PluginEventHandler func(event PluginEvent) error

PluginEventHandler handles plugin events

type RateLimitViolation

type RateLimitViolation struct {
	ClientIP     string `json:"client_ip"`
	Endpoint     string `json:"endpoint"`
	LimitType    string `json:"limit_type"`
	CurrentCount int    `json:"current_count"`
	Limit        int    `json:"limit"`
	Window       string `json:"window"`
	Action       string `json:"action"`
	Source       string `json:"source"`
}

RateLimitViolation represents a rate limiting violation

type ThreatInfo

type ThreatInfo struct {
	ThreatType        string  `json:"threat_type"`
	Severity          string  `json:"severity"`
	ClientIP          string  `json:"client_ip"`
	Endpoint          string  `json:"endpoint"`
	Description       string  `json:"description"`
	Confidence        float64 `json:"confidence"`
	RecommendedAction string  `json:"recommended_action"`
	Source            string  `json:"source"`
}

ThreatInfo represents security threat information

type ZTNAEvent

type ZTNAEvent struct {
	SessionID  string  `json:"session_id"`
	UserID     string  `json:"user_id"`
	ClientIP   string  `json:"client_ip"`
	TrustLevel string  `json:"trust_level"`
	RiskScore  float64 `json:"risk_score"`
	Endpoint   string  `json:"endpoint"`
	Decision   string  `json:"decision"`
	Reason     string  `json:"reason"`
}

ZTNAEvent represents Zero Trust events

Jump to

Keyboard shortcuts

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