feeder

package
v0.0.0-...-b80f625 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package feeder is responsible for sanitizing and relaying telemetry and alerts data to connected clients

Index

Constants

View Source
const QueueSize = 1000

QueueSize

Variables

View Source
var Running bool

Running flag

Functions

func GetProtocolFromName

func GetProtocolFromName(proto string) string

GetProtocolFromName function gets protocol name from visibility data

Types

type BaseFeeder

type BaseFeeder struct {
	// node
	Node     *tp.Node
	NodeLock **sync.RWMutex

	// wait group
	WgServer sync.WaitGroup

	// output
	Output  string
	LogFile *os.File

	// Activated Enforcer
	Enforcer string

	// Msg, log and alert connection stores
	EventStructs *EventStructs

	// True if feeder and its workers are working
	Running bool

	// port
	Port string

	// gRPC listener
	Listener net.Listener

	// log server
	LogServer *grpc.Server
}

func (*BaseFeeder) DestroyFeeder

func (fd *BaseFeeder) DestroyFeeder() error

DestroyFeeder Function

func (*BaseFeeder) ServeLogFeeds

func (fd *BaseFeeder) ServeLogFeeds()

ServeLogFeeds Function

type EventStruct

type EventStruct[T any] struct {
	Filter    string
	Broadcast chan *T
}

EventStruct Structure

type EventStructs

type EventStructs struct {
	MsgStructs map[string]EventStruct[pb.Message]
	MsgLock    sync.RWMutex

	AlertStructs map[string]EventStruct[pb.Alert]
	AlertLock    sync.RWMutex

	LogStructs map[string]EventStruct[pb.Log]
	LogLock    sync.RWMutex
}

func (*EventStructs) AddAlertStruct

func (es *EventStructs) AddAlertStruct(filter string, queueSize int) (string, chan *pb.Alert)

AddAlertStruct Function

func (*EventStructs) AddLogStruct

func (es *EventStructs) AddLogStruct(filter string, queueSize int) (string, chan *pb.Log)

addLogStruct Function

func (*EventStructs) AddMsgStruct

func (es *EventStructs) AddMsgStruct(filter string, queueSize int) (string, chan *pb.Message)

AddMsgStruct Function

func (*EventStructs) RemoveAlertStruct

func (es *EventStructs) RemoveAlertStruct(uid string)

removeAlertStruct Function

func (*EventStructs) RemoveLogStruct

func (es *EventStructs) RemoveLogStruct(uid string)

removeLogStruct Function

func (*EventStructs) RemoveMsgStruct

func (es *EventStructs) RemoveMsgStruct(uid string)

RemoveMsgStruct Function

type Feeder

type Feeder struct {
	BaseFeeder

	// namespace name + endpoint name / host name -> corresponding security policies
	SecurityPolicies     map[string]tp.MatchPolicies
	SecurityPoliciesLock *sync.RWMutex

	// DefaultPosture (namespace -> postures)
	DefaultPostures     map[string]tp.DefaultPosture
	DefaultPosturesLock *sync.Mutex
}

Feeder Structure

func NewFeeder

func NewFeeder(node *tp.Node, nodeLock **sync.RWMutex) *Feeder

NewFeeder Function

func (*Feeder) Debug

func (fd *Feeder) Debug(message string)

Debug Function

func (*Feeder) Debugf

func (fd *Feeder) Debugf(message string, args ...interface{})

Debugf Function

func (*Feeder) Err

func (fd *Feeder) Err(message string)

Err Function

func (*Feeder) Errf

func (fd *Feeder) Errf(message string, args ...interface{})

Errf Function

func (*Feeder) Print

func (fd *Feeder) Print(message string)

Print Function

func (*Feeder) Printf

func (fd *Feeder) Printf(message string, args ...interface{})

Printf Function

func (*Feeder) PushLog

func (fd *Feeder) PushLog(log tp.Log)

PushLog Function

func (*Feeder) PushMessage

func (fd *Feeder) PushMessage(level, message string)

PushMessage Function

func (*Feeder) StrToFile

func (fd *Feeder) StrToFile(str string)

StrToFile Function

func (*Feeder) UpdateDefaultPosture

func (fd *Feeder) UpdateDefaultPosture(action string, namespace string, defaultPosture tp.DefaultPosture)

UpdateDefaultPosture Function

func (*Feeder) UpdateEnforcer

func (fd *Feeder) UpdateEnforcer(enforcer string)

UpdateEnforcer Function

func (*Feeder) UpdateHostSecurityPolicies

func (fd *Feeder) UpdateHostSecurityPolicies(action string, secPolicies []tp.HostSecurityPolicy)

UpdateHostSecurityPolicies Function

func (*Feeder) UpdateMatchedPolicy

func (fd *Feeder) UpdateMatchedPolicy(log tp.Log) tp.Log

UpdateMatchedPolicy Function

func (*Feeder) UpdateSecurityPolicies

func (fd *Feeder) UpdateSecurityPolicies(action string, endPoint tp.EndPoint)

UpdateSecurityPolicies Function

func (*Feeder) Warn

func (fd *Feeder) Warn(message string)

Warn Function

func (*Feeder) Warnf

func (fd *Feeder) Warnf(message string, args ...interface{})

Warnf Function

type FeederInterface

type FeederInterface interface {

	// How does the feeder pushes logs and messages
	PushLog(tp.Log)
	PushMessage(string, string)

	// How does this feeder match log with policy
	UpdateMatchedPolicy(tp.Log)

	// How this feeder serves log feeds
	ServeLogFeeds()
}

============ // == Feeder == // ============ //

type LogService

type LogService struct {
	QueueSize    int
	EventStructs *EventStructs
	Running      *bool
}

LogService struct holds the state of feeder's log server

func (*LogService) HealthCheck

func (ls *LogService) HealthCheck(ctx context.Context, nonce *pb.NonceMessage) (*pb.ReplyMessage, error)

HealthCheck Function Deprecated: use the server created with google.golang.org/grpc/health/grpc_health_v1

func (*LogService) WatchAlerts

func (ls *LogService) WatchAlerts(req *pb.RequestMessage, svr pb.LogService_WatchAlertsServer) error

WatchAlerts Function

func (*LogService) WatchLogs

WatchLogs Function

func (*LogService) WatchMessages

func (ls *LogService) WatchMessages(req *pb.RequestMessage, svr pb.LogService_WatchMessagesServer) error

WatchMessages Function

Jump to

Keyboard shortcuts

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