classifier

package
v0.1.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BadExtractor = extractors.BadExtractor

BadExtractor is an error occurring when extractor is invalid.

View Source
var BadLabelName = badLabelName{}

BadLabelName is an error occurring when label name is invalid.

View Source
var BadRego = badRego{}

BadRego is an error occurring when rego compilation fails.

View Source
var BadSelector = badSelector{}

BadSelector is an error occurring when selector is invalid.

View Source
var Module fx.Option = fx.Options(
	fx.Provide(
		fx.Annotated{
			Target: setupEtcdClassifierWatcher,
			Name:   "classifier",
		},
		fx.Annotated{
			Target: ProvideEmptyClassifier,
			Name:   "empty",
		},
		ProvideClassifier,
	),
)

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.

Functions

This section is empty.

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 Classifier

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

Classifier receives classification policies and provides Classify method.

func New

func New() *Classifier

New creates a new Flow Classifier.

func ProvideClassifier

func ProvideClassifier(in ProvideClassifierIn) *Classifier

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

func ProvideEmptyClassifier

func ProvideEmptyClassifier() *Classifier

ProvideEmptyClassifier provides a classifier that is empty

The classifier could be populated by calling UpdateRules.

func (*Classifier) ActiveRules

func (c *Classifier) ActiveRules() []ReportedRule

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

func (*Classifier) AddRules

func (c *Classifier) AddRules(
	ctx context.Context,
	name string,
	classifier *classificationv1.Classifier,
) (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 (*Classifier) Classify

func (c *Classifier) Classify(
	ctx context.Context,
	svcs []services.ServiceID,
	labelsForMatching selectors.Labels,
	direction selectors.TrafficDirection,
	input ast.Value,
) (FlowLabels, error)

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

type CompiledRuleset

type CompiledRuleset struct {
	ControlPointID selectors.ControlPointID
	Labelers       []labelerWithSelector
	ReportedRules  []ReportedRule
}

CompiledRuleset is compiled form of Classifier proto.

func CompileRuleset

func CompileRuleset(ctx context.Context, name string, classifier *classificationv1.Classifier) (CompiledRuleset, error)

CompileRuleset parses ruleset's selector and compiles its rules.

type FlowLabelValue

type FlowLabelValue struct {
	Value string
	Flags LabelFlags
}

FlowLabelValue is a value of a flow label with additional metadata.

type FlowLabels

type FlowLabels map[string]FlowLabelValue

FlowLabels is a map from flow labels to their values.

func (FlowLabels) ToPlainMap

func (fl FlowLabels) ToPlainMap() map[string]string

ToPlainMap returns flow labels as normal map[string]string.

type LabelFlags

type LabelFlags struct {
	// Should the created label be applied to the whole flow (propagated in baggage)
	Propagate bool
	// Should the created flow label be hidden from telemetry
	Hidden bool
}

LabelFlags are flags for a flow label.

type ProvideClassifierIn

type ProvideClassifierIn struct {
	fx.In
	Classifier *Classifier       `name:"empty"`
	Watcher    notifiers.Watcher `name:"classifier"`
	Lifecycle  fx.Lifecycle
	Registry   status.Registry
}

ProvideClassifierIn holds parameters for ProvideClassifier.

type ReportedRule

type ReportedRule struct {
	Selector    *selectorv1.Selector
	Rule        *classificationv1.Rule
	RulesetName string
	LabelName   string
}

ReportedRule is a rule along with its selector and label name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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