classifier

package
v2.32.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

Module is a default set of components to enable flow classification

Note: this module provides just a Classifier datastructure, with no API endpoint. Example API endpoint to the classifier is pkg/envoy.

Types

type ActiveRuleset

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

ActiveRuleset represents one of currently active set of rules.

func (ActiveRuleset) Drop

func (rs ActiveRuleset) Drop()

Drop retracts all the rules belonging to a ruleset.

type ClassificationEngine

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

ClassificationEngine receives classification policies and provides Classify method.

func NewClassificationEngine

func NewClassificationEngine(agentInfo *agentinfo.AgentInfo, registry status.Registry) *ClassificationEngine

NewClassificationEngine creates a new Classifier.

func ProvideClassificationEngine

func ProvideClassificationEngine(in ClassificationEngineIn) (iface.ClassificationEngine, *ClassificationEngine)

ProvideClassificationEngine provides a classifier that loads the rules from config file.

func (*ClassificationEngine) ActiveRules

func (c *ClassificationEngine) ActiveRules() []compiler.ReportedRule

ActiveRules returns a slice of uncompiled Rules which are currently active.

func (*ClassificationEngine) AddPreview

func (c *ClassificationEngine) AddPreview(preview iface.HTTPRequestPreview)

AddPreview adds a preview to the active previews.

func (*ClassificationEngine) AddRules

func (c *ClassificationEngine) AddRules(
	ctx context.Context,
	name string,
	classifierWrapper *policysyncv1.ClassifierWrapper,
) (ActiveRuleset, error)

AddRules compiles a ruleset and adds it to the active rules

The name will be used for reporting

To retract the rules, call Classifier.Drop.

func (*ClassificationEngine) Classify

func (c *ClassificationEngine) Classify(
	ctx context.Context,
	svcs []string,
	ctrlPt string,
	labelsForMatching labels.Labels,
	input Input,
) ([]*flowcontrolv1.ClassifierInfo, flowlabel.FlowLabels)

Classify takes rego input, performs classification, and returns a map of flow labels. LabelsForMatching are additional labels to use for selector matching.

func (*ClassificationEngine) DropPreview

func (c *ClassificationEngine) DropPreview(preview iface.HTTPRequestPreview)

DropPreview removes a preview from the active previews.

func (*ClassificationEngine) GetClassifier

func (c *ClassificationEngine) GetClassifier(classifierID iface.ClassifierID) iface.Classifier

GetClassifier Lookup function for getting classifier.

func (*ClassificationEngine) RegisterClassifier

func (c *ClassificationEngine) RegisterClassifier(classifier iface.Classifier) error

RegisterClassifier adds classifier to map.

func (*ClassificationEngine) UnregisterClassifier

func (c *ClassificationEngine) UnregisterClassifier(classifier iface.Classifier) error

UnregisterClassifier removes classifier from map.

type ClassificationEngineIn

type ClassificationEngineIn struct {
	fx.In
	Watcher      notifiers.Watcher `name:"classifier"`
	Lifecycle    fx.Lifecycle
	Registry     status.Registry
	PromRegistry *prometheus.Registry
	AgentInfo    *agentinfo.AgentInfo
}

ClassificationEngineIn holds parameters for ProvideClassificationEngine.

type Classifier

type Classifier struct {
	iface.Classifier
	// contains filtered or unexported fields
}

Classifier implements iface.Classifier interface.

func (*Classifier) GetClassifierID

func (c *Classifier) GetClassifierID() iface.ClassifierID

GetClassifierID returns ClassifierID object that should uniquely identify classifier.

func (*Classifier) GetRequestCounter

func (c *Classifier) GetRequestCounter() prometheus.Counter

GetRequestCounter returns the counter for the classifier.

func (*Classifier) GetSelectors

func (c *Classifier) GetSelectors() []*policylangv1.Selector

GetSelectors returns the selectors.

type Input added in v2.6.0

type Input interface {
	Value() ast.Value
	Interface() interface{}
}

Input is an input to Classify method.

Classifier sometimes needs the input in ast.Value format and sometimes in interface{} format. Using this interface allows to minimize number of conversions. Note that values returned from both methods should be equivalent.

Each method can be called multiple times (including zero).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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