Documentation ¶
Index ¶
- Constants
- Variables
- func IPToInt(ip net.IP) (*big.Int, int, error)
- func IntToIP(ipInt *big.Int, bits int) net.IP
- func NewCookie() uint32
- func NotOfValue(value interface{}) (interface{}, error)
- func PatternMatches(pattern string, str string, caseInsensitive bool) bool
- func RandString(n int) string
- type BoolArrayEvaluator
- type BoolEvalFnc
- type BoolEvaluator
- func AllCIDRValuesContains(a *CIDREvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func AllCIDRValuesMatches(a *CIDRValuesEvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func And(a *BoolEvaluator, b *BoolEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func ArrayBoolContains(a *BoolEvaluator, b *BoolArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func BoolArrayEquals(a *BoolEvaluator, b *BoolArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func BoolEquals(a *BoolEvaluator, b *BoolEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func CIDREquals(a *CIDREvaluator, b *CIDREvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func CIDRValuesContains(a *CIDREvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func CIDRValuesContainsWithOpFunction(a *CIDREvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State, ...) (*BoolEvaluator, error)
- func CIDRValuesMatches(a *CIDRValuesEvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func CIDRValuesMatchesWithOpFunction(a *CIDRValuesEvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State, ...) (*BoolEvaluator, error)
- func DurationGreaterOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func DurationGreaterThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func DurationLesserOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func DurationLesserThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func GreaterOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func GreaterThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func IntArrayEquals(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func IntArrayGreaterOrEqualThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func IntArrayGreaterThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func IntArrayLesserOrEqualThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func IntArrayLesserThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func IntArrayMatches(a *IntArrayEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func IntEquals(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func LesserOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func LesserThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func Not(a *BoolEvaluator, opts *Opts, state *State) *BoolEvaluator
- func Or(a *BoolEvaluator, b *BoolEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringArrayContains(a *StringEvaluator, b *StringArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringArrayContainsWrapper(a *StringEvaluator, b *StringArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringArrayMatches(a *StringArrayEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringArrayMatchesWrapper(a *StringArrayEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringEquals(a *StringEvaluator, b *StringEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringEqualsWrapper(a *StringEvaluator, b *StringEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringValuesContains(a *StringEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- func StringValuesContainsWrapper(a *StringEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
- type BoolVariable
- type CIDREvaluator
- type CIDRMatcher
- type CIDRValues
- func (s *CIDRValues) AppendCIDR(cidr *net.IPNet)
- func (s *CIDRValues) AppendFieldValue(value FieldValue) error
- func (s *CIDRValues) AppendIP(ip net.IP)
- func (s *CIDRValues) GetFieldValues() []FieldValue
- func (s *CIDRValues) GetMatchers() []IPMatcher
- func (s *CIDRValues) Matches(value IPMatcher) bool
- func (s *CIDRValues) MatchesAll(value IPMatcher) bool
- func (s *CIDRValues) SetFieldValues(values ...FieldValue) error
- type CIDRValuesEvaluator
- func (cve *CIDRValuesEvaluator) AppendFieldValues(values ...FieldValue) error
- func (cve *CIDRValuesEvaluator) AppendMembers(members ...ast.CIDRMember) error
- func (cve *CIDRValuesEvaluator) Eval(ctx *Context) interface{}
- func (cve *CIDRValuesEvaluator) GetField() string
- func (cve *CIDRValuesEvaluator) IsDeterministicFor(field Field) bool
- func (cve *CIDRValuesEvaluator) IsStatic() bool
- func (cve *CIDRValuesEvaluator) SetFieldValues(values ...FieldValue) error
- type Context
- type ContextPool
- type ErrAstToEval
- func NewArrayTypeError(pos lexer.Position, arrayKind reflect.Kind, kind reflect.Kind) *ErrAstToEval
- func NewCIDRTypeError(pos lexer.Position, arrayKind reflect.Kind, kind interface{}) *ErrAstToEval
- func NewError(pos lexer.Position, text string) *ErrAstToEval
- func NewOpError(pos lexer.Position, op string, err error) *ErrAstToEval
- func NewOpUnknownError(pos lexer.Position, op string) *ErrAstToEval
- func NewRegisterMultipleFields(pos lexer.Position, regID RegisterID, err error) *ErrAstToEval
- func NewRegisterNameNotAllowed(pos lexer.Position, regID RegisterID, err error) *ErrAstToEval
- func NewTypeError(pos lexer.Position, kind reflect.Kind) *ErrAstToEval
- type ErrFieldNotFound
- type ErrInvalidPattern
- type ErrInvalidRegexp
- type ErrIteratorNotSupported
- type ErrNonStaticPattern
- type ErrNotSupported
- type ErrRuleNotCompiled
- type ErrRuleParse
- type ErrValueTypeMismatch
- type Evaluator
- type Event
- type EventType
- type Field
- type FieldValue
- type FieldValueType
- type Glob
- type GlobStringMatcher
- type GlobalVariables
- type IPMatcher
- type IntArrayEvaluator
- type IntArrayVariable
- type IntEvaluator
- func IntAnd(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*IntEvaluator, error)
- func IntNot(a *IntEvaluator, opts *Opts, state *State) *IntEvaluator
- func IntOr(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*IntEvaluator, error)
- func IntXor(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*IntEvaluator, error)
- func Minus(a *IntEvaluator, opts *Opts, state *State) *IntEvaluator
- type IntVariable
- type Iterator
- type Macro
- type MacroEvaluator
- type MacroID
- type Model
- type MutableBoolVariable
- type MutableIntArrayVariable
- type MutableIntVariable
- type MutableStringArrayVariable
- type MutableStringVariable
- type MutableVariable
- type OpOverrides
- type Opts
- func (o *Opts) AddMacro(macro *Macro) *Opts
- func (o *Opts) WithConstants(constants map[string]interface{}) *Opts
- func (o *Opts) WithLegacyFields(fields map[Field]Field) *Opts
- func (o *Opts) WithMacros(macros map[MacroID]*Macro) *Opts
- func (o *Opts) WithUserContext(ctx interface{}) *Opts
- func (o *Opts) WithVariables(variables map[string]VariableValue) *Opts
- type RegexpStringMatcher
- type Register
- type RegisterID
- type Registers
- type Rule
- func (r *Rule) Eval(ctx *Context) bool
- func (r *Rule) GenEvaluator(model Model, opts *Opts) error
- func (r *Rule) GenPartials() error
- func (r *Rule) GetAst() *ast.Rule
- func (r *Rule) GetEvaluator() *RuleEvaluator
- func (r *Rule) GetEventTypes() ([]EventType, error)
- func (r *Rule) GetFieldValues(field Field) []FieldValue
- func (r *Rule) GetFields() []Field
- func (r *Rule) GetPartialEval(field Field) BoolEvalFnc
- func (r *Rule) Parse() error
- func (r *Rule) PartialEval(ctx *Context, field Field) (bool, error)
- type RuleEvaluator
- type RuleID
- type ScalarStringMatcher
- type ScopedVariables
- type Scoper
- type SingleIPMatcher
- type State
- type StringArrayEvaluator
- type StringArrayVariable
- type StringCmpOpts
- type StringEvaluator
- func (s *StringEvaluator) Eval(ctx *Context) interface{}
- func (s *StringEvaluator) GetField() string
- func (s *StringEvaluator) GetValue(ctx *Context) string
- func (s *StringEvaluator) IsDeterministicFor(field Field) bool
- func (s *StringEvaluator) IsStatic() bool
- func (s *StringEvaluator) ToStringMatcher(opts StringCmpOpts) (StringMatcher, error)
- type StringMatcher
- type StringValues
- func (s *StringValues) AppendFieldValue(value FieldValue)
- func (s *StringValues) AppendScalarValue(value string)
- func (s *StringValues) Compile(opts StringCmpOpts) error
- func (s *StringValues) GetScalarValues() []string
- func (s *StringValues) GetStringMatchers() []StringMatcher
- func (s *StringValues) Matches(value string) bool
- func (s *StringValues) SetFieldValues(values ...FieldValue) error
- type StringValuesEvaluator
- func (s *StringValuesEvaluator) AppendFieldValues(values ...FieldValue)
- func (s *StringValuesEvaluator) AppendMembers(members ...ast.StringMember)
- func (s *StringValuesEvaluator) Compile(opts StringCmpOpts) error
- func (s *StringValuesEvaluator) Eval(ctx *Context) interface{}
- func (s *StringValuesEvaluator) GetField() string
- func (s *StringValuesEvaluator) IsDeterministicFor(field Field) bool
- func (s *StringValuesEvaluator) IsStatic() bool
- func (s *StringValuesEvaluator) SetFieldValues(values ...FieldValue) error
- type StringVariable
- type Variable
- type VariableValue
- type Variables
- func (v *Variables) GetBool(name string) bool
- func (v *Variables) GetInt(name string) int
- func (v *Variables) GetIntArray(name string) []int
- func (v *Variables) GetString(name string) string
- func (v *Variables) GetStringArray(name string) []string
- func (v *Variables) Set(name string, value interface{}) bool
Constants ¶
const ( FunctionWeight = 5 InArrayWeight = 10 HandlerWeight = 50 RegexpWeight = 100 InPatternArrayWeight = 1000 IteratorWeight = 2000 )
defines factor applied by specific operator
Variables ¶
var DefaultStringCmpOpts = StringCmpOpts{}
DefaultStringCmpOpts defines the default comparison options
Functions ¶
func NotOfValue ¶
func NotOfValue(value interface{}) (interface{}, error)
NotOfValue returns the NOT of a value
func PatternMatches ¶ added in v0.34.0
PatternMatches matches a pattern against a string
func RandString ¶
RandString returns a random string of the given length size
Types ¶
type BoolArrayEvaluator ¶
type BoolArrayEvaluator struct { EvalFnc func(ctx *Context) []bool Field Field Values []bool Weight int OpOverrides *OpOverrides // contains filtered or unexported fields }
BoolArrayEvaluator returns an array of bool
func (*BoolArrayEvaluator) Eval ¶
func (b *BoolArrayEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*BoolArrayEvaluator) GetField ¶
func (b *BoolArrayEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*BoolArrayEvaluator) IsDeterministicFor ¶ added in v0.35.0
func (b *BoolArrayEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*BoolArrayEvaluator) IsStatic ¶ added in v0.36.0
func (b *BoolArrayEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
type BoolEvalFnc ¶
BoolEvalFnc describe a eval function return a boolean
type BoolEvaluator ¶
type BoolEvaluator struct { EvalFnc BoolEvalFnc Field Field Value bool Weight int OpOverrides *OpOverrides // contains filtered or unexported fields }
BoolEvaluator returns a bool as result of the evaluation
func AllCIDRValuesContains ¶ added in v0.36.0
func AllCIDRValuesContains(a *CIDREvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
AllCIDRValuesContains evaluates a CIDR against a list of CIDRs
func AllCIDRValuesMatches ¶ added in v0.36.0
func AllCIDRValuesMatches(a *CIDRValuesEvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
AllCIDRValuesMatches ensures that all values from a and b match.
func And ¶
func And(a *BoolEvaluator, b *BoolEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func ArrayBoolContains ¶
func ArrayBoolContains(a *BoolEvaluator, b *BoolArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
ArrayBoolContains evaluates array of bool against a value
func BoolArrayEquals ¶ added in v0.34.0
func BoolArrayEquals(a *BoolEvaluator, b *BoolArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func BoolEquals ¶
func BoolEquals(a *BoolEvaluator, b *BoolEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func CIDREquals ¶ added in v0.36.0
func CIDREquals(a *CIDREvaluator, b *CIDREvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
CIDREquals evaluates CIDR ranges
func CIDRValuesContains ¶ added in v0.36.0
func CIDRValuesContains(a *CIDREvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
CIDRValuesContains evaluates a CIDR against a list of CIDRs
func CIDRValuesContainsWithOpFunction ¶ added in v0.36.0
func CIDRValuesContainsWithOpFunction(a *CIDREvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State, arrayOp func(a IPMatcher, b *CIDRValues) bool) (*BoolEvaluator, error)
CIDRValuesContainsWithOpFunction evaluates a CIDR against a list of CIDRs
func CIDRValuesMatches ¶ added in v0.36.0
func CIDRValuesMatches(a *CIDRValuesEvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
CIDRValuesMatches weak comparison, at least one element of a should be in b.
func CIDRValuesMatchesWithOpFunction ¶ added in v0.36.0
func CIDRValuesMatchesWithOpFunction(a *CIDRValuesEvaluator, b *CIDRValuesEvaluator, opts *Opts, state *State, arrayOp func(a *CIDRValues, b *CIDRValues) bool) (*BoolEvaluator, error)
CIDRValuesMatchesWithOpFunction compares a and b following the provided arrayOp
func DurationGreaterOrEqualThan ¶
func DurationGreaterOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func DurationGreaterThan ¶
func DurationGreaterThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func DurationLesserOrEqualThan ¶
func DurationLesserOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func DurationLesserThan ¶
func DurationLesserThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func GreaterOrEqualThan ¶
func GreaterOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func GreaterThan ¶
func GreaterThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func IntArrayEquals ¶ added in v0.34.0
func IntArrayEquals(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func IntArrayGreaterOrEqualThan ¶ added in v0.34.0
func IntArrayGreaterOrEqualThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func IntArrayGreaterThan ¶ added in v0.34.0
func IntArrayGreaterThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func IntArrayLesserOrEqualThan ¶ added in v0.34.0
func IntArrayLesserOrEqualThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func IntArrayLesserThan ¶ added in v0.34.0
func IntArrayLesserThan(a *IntEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func IntArrayMatches ¶ added in v0.34.0
func IntArrayMatches(a *IntArrayEvaluator, b *IntArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
IntArrayMatches weak comparison, a least one element of a should be in b
func IntEquals ¶
func IntEquals(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func LesserOrEqualThan ¶
func LesserOrEqualThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func LesserThan ¶
func LesserThan(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func Or ¶
func Or(a *BoolEvaluator, b *BoolEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
func StringArrayContains ¶ added in v0.34.0
func StringArrayContains(a *StringEvaluator, b *StringArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringArrayContains evaluates array of strings against a value
func StringArrayContainsWrapper ¶ added in v0.34.0
func StringArrayContainsWrapper(a *StringEvaluator, b *StringArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringArrayContainsWrapper makes use of operator overrides
func StringArrayMatches ¶ added in v0.34.0
func StringArrayMatches(a *StringArrayEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringArrayMatches weak comparison, a least one element of a should be in b. a can't contain regexp
func StringArrayMatchesWrapper ¶ added in v0.34.0
func StringArrayMatchesWrapper(a *StringArrayEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringArrayMatchesWrapper makes use of operator overrides
func StringEquals ¶
func StringEquals(a *StringEvaluator, b *StringEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringEquals evaluates string
func StringEqualsWrapper ¶ added in v0.34.0
func StringEqualsWrapper(a *StringEvaluator, b *StringEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringEqualsWrapper makes use of operator overrides
func StringValuesContains ¶ added in v0.34.0
func StringValuesContains(a *StringEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringValuesContains evaluates a string against values
func StringValuesContainsWrapper ¶ added in v0.34.0
func StringValuesContainsWrapper(a *StringEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error)
StringValuesContainsWrapper makes use of operator overrides
func (*BoolEvaluator) Eval ¶
func (b *BoolEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*BoolEvaluator) GetField ¶
func (b *BoolEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*BoolEvaluator) IsDeterministicFor ¶ added in v0.35.0
func (b *BoolEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*BoolEvaluator) IsStatic ¶ added in v0.36.0
func (b *BoolEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
type BoolVariable ¶ added in v0.35.0
type BoolVariable struct { Variable // contains filtered or unexported fields }
BoolVariable describes a boolean variable
func NewBoolVariable ¶ added in v0.35.0
func NewBoolVariable(boolFnc func(ctx *Context) bool, setFnc func(ctx *Context, value interface{}) error) *BoolVariable
NewBoolVariable returns a new boolean variable
func (*BoolVariable) GetEvaluator ¶ added in v0.35.0
func (b *BoolVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
type CIDREvaluator ¶ added in v0.36.0
type CIDREvaluator struct { EvalFnc func(ctx *Context) *FieldValue Field Field Value string Weight int OpOverrides *OpOverrides ValueType FieldValueType // contains filtered or unexported fields }
CIDREvaluator returns a net.IP
func (*CIDREvaluator) Compile ¶ added in v0.36.0
func (s *CIDREvaluator) Compile() error
Compile compile internal object
func (*CIDREvaluator) Eval ¶ added in v0.36.0
func (s *CIDREvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*CIDREvaluator) GetField ¶ added in v0.36.0
func (s *CIDREvaluator) GetField() string
GetField returns field name used by this evaluator
func (*CIDREvaluator) IsDeterministicFor ¶ added in v0.36.0
func (s *CIDREvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*CIDREvaluator) IsStatic ¶ added in v0.36.0
func (s *CIDREvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
type CIDRMatcher ¶ added in v0.36.0
type CIDRMatcher struct {
// contains filtered or unexported fields
}
CIDRMatcher defines an IPv4/IPv6 CIDR
func (*CIDRMatcher) Compile ¶ added in v0.36.0
func (cm *CIDRMatcher) Compile(pattern string) error
Compile the string representation of a CIDR to a net.IPNet
func (*CIDRMatcher) GetType ¶ added in v0.36.0
func (cm *CIDRMatcher) GetType() FieldValueType
GetType returns the FieldValueType of the IPMatcher
func (*CIDRMatcher) IPMatches ¶ added in v0.36.0
func (cm *CIDRMatcher) IPMatches(value net.IP) bool
IPMatches returns wether the value matches
func (*CIDRMatcher) Matches ¶ added in v0.36.0
func (cm *CIDRMatcher) Matches(value IPMatcher) bool
Matches matches with an IPMatcher
func (*CIDRMatcher) String ¶ added in v0.36.0
func (cm *CIDRMatcher) String() string
type CIDRValues ¶ added in v0.36.0
type CIDRValues struct {
// contains filtered or unexported fields
}
CIDRValues describes a set of CIDRs, either simple IPs or CIDR
func NewCIDRValues ¶ added in v0.36.0
func NewCIDRValues(ips []net.IP, cidrs []*net.IPNet) *CIDRValues
NewCIDRValues returns a new CIDRValues
func (*CIDRValues) AppendCIDR ¶ added in v0.36.0
func (s *CIDRValues) AppendCIDR(cidr *net.IPNet)
AppendCIDR appends a CIDR
func (*CIDRValues) AppendFieldValue ¶ added in v0.36.0
func (s *CIDRValues) AppendFieldValue(value FieldValue) error
AppendFieldValue append a FieldValue
func (*CIDRValues) AppendIP ¶ added in v0.36.0
func (s *CIDRValues) AppendIP(ip net.IP)
AppendIP appends an IP
func (*CIDRValues) GetFieldValues ¶ added in v0.36.0
func (s *CIDRValues) GetFieldValues() []FieldValue
GetFieldValues returns the list of FieldValues stored in the current CIDRValues
func (*CIDRValues) GetMatchers ¶ added in v0.36.0
func (s *CIDRValues) GetMatchers() []IPMatcher
GetMatchers return the matchers
func (*CIDRValues) Matches ¶ added in v0.36.0
func (s *CIDRValues) Matches(value IPMatcher) bool
Matches returns whether the value matches the provided IPMatcher
func (*CIDRValues) MatchesAll ¶ added in v0.36.0
func (s *CIDRValues) MatchesAll(value IPMatcher) bool
MatchesAll returns true if value matches all CIDRValues entries
func (*CIDRValues) SetFieldValues ¶ added in v0.36.0
func (s *CIDRValues) SetFieldValues(values ...FieldValue) error
SetFieldValues apply field values
type CIDRValuesEvaluator ¶ added in v0.36.0
type CIDRValuesEvaluator struct { EvalFnc func(ctx *Context) *CIDRValues Values CIDRValues Field Field Weight int OpOverrides *OpOverrides // contains filtered or unexported fields }
CIDRValuesEvaluator returns IPValues
func (*CIDRValuesEvaluator) AppendFieldValues ¶ added in v0.36.0
func (cve *CIDRValuesEvaluator) AppendFieldValues(values ...FieldValue) error
AppendFieldValues append field values
func (*CIDRValuesEvaluator) AppendMembers ¶ added in v0.36.0
func (cve *CIDRValuesEvaluator) AppendMembers(members ...ast.CIDRMember) error
AppendMembers add CIDR values to the evaluator
func (*CIDRValuesEvaluator) Eval ¶ added in v0.36.0
func (cve *CIDRValuesEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*CIDRValuesEvaluator) GetField ¶ added in v0.36.0
func (cve *CIDRValuesEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*CIDRValuesEvaluator) IsDeterministicFor ¶ added in v0.36.0
func (cve *CIDRValuesEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*CIDRValuesEvaluator) IsStatic ¶ added in v0.36.0
func (cve *CIDRValuesEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
func (*CIDRValuesEvaluator) SetFieldValues ¶ added in v0.36.0
func (cve *CIDRValuesEvaluator) SetFieldValues(values ...FieldValue) error
SetFieldValues apply field values
type Context ¶
type Context struct { Object unsafe.Pointer Registers Registers // cache available across all the evaluations Cache map[string]unsafe.Pointer // contains filtered or unexported fields }
Context describes the context used during a rule evaluation
type ContextPool ¶
type ContextPool struct {
// contains filtered or unexported fields
}
ContextPool defines a pool of context
func (*ContextPool) Get ¶
func (c *ContextPool) Get(obj unsafe.Pointer) *Context
Get returns a context with the given object
func (*ContextPool) Put ¶
func (c *ContextPool) Put(ctx *Context)
Put returns the context to the pool
type ErrAstToEval ¶
ErrAstToEval describes an error that occurred during the conversion from the AST to an evaluator
func NewArrayTypeError ¶ added in v0.34.0
NewArrayTypeError returns a new ErrAstToEval error when an invalid type was used
func NewCIDRTypeError ¶ added in v0.36.0
func NewCIDRTypeError(pos lexer.Position, arrayKind reflect.Kind, kind interface{}) *ErrAstToEval
NewCIDRTypeError returns a new ErrAstToEval error when an invalid type was used
func NewError ¶
func NewError(pos lexer.Position, text string) *ErrAstToEval
NewError returns a new ErrAstToEval error
func NewOpError ¶
func NewOpError(pos lexer.Position, op string, err error) *ErrAstToEval
NewOpError returns a new ErrAstToEval error when an operator was used in an invalid manner
func NewOpUnknownError ¶
func NewOpUnknownError(pos lexer.Position, op string) *ErrAstToEval
NewOpUnknownError returns a new ErrAstToEval error when an unknown operator was used
func NewRegisterMultipleFields ¶
func NewRegisterMultipleFields(pos lexer.Position, regID RegisterID, err error) *ErrAstToEval
NewRegisterMultipleFields returns a new ErrAstToEval error when a register is used across multiple fields
func NewRegisterNameNotAllowed ¶
func NewRegisterNameNotAllowed(pos lexer.Position, regID RegisterID, err error) *ErrAstToEval
NewRegisterNameNotAllowed returns a new ErrAstToEval error when a register name is not allowed
func NewTypeError ¶
func NewTypeError(pos lexer.Position, kind reflect.Kind) *ErrAstToEval
NewTypeError returns a new ErrAstToEval error when an invalid type was used
func (*ErrAstToEval) Error ¶
func (r *ErrAstToEval) Error() string
type ErrFieldNotFound ¶
type ErrFieldNotFound struct {
Field string
}
ErrFieldNotFound error when a field is not present in the model
func (ErrFieldNotFound) Error ¶
func (e ErrFieldNotFound) Error() string
type ErrInvalidPattern ¶
type ErrInvalidPattern struct {
Pattern string
}
ErrInvalidPattern is returned for an invalid regular expression
func (ErrInvalidPattern) Error ¶
func (e ErrInvalidPattern) Error() string
type ErrInvalidRegexp ¶
type ErrInvalidRegexp struct {
Regexp string
}
ErrInvalidRegexp is returned for an invalid regular expression
func (ErrInvalidRegexp) Error ¶
func (e ErrInvalidRegexp) Error() string
type ErrIteratorNotSupported ¶
type ErrIteratorNotSupported struct {
Field string
}
ErrIteratorNotSupported error when a field doesn't support iteration
func (ErrIteratorNotSupported) Error ¶
func (e ErrIteratorNotSupported) Error() string
type ErrNonStaticPattern ¶
type ErrNonStaticPattern struct {
Field Field
}
ErrNonStaticPattern when pattern operator is used on a non static value
func (ErrNonStaticPattern) Error ¶
func (e ErrNonStaticPattern) Error() string
type ErrNotSupported ¶
type ErrNotSupported struct {
Field string
}
ErrNotSupported returned when something is not supported on a field
func (ErrNotSupported) Error ¶
func (e ErrNotSupported) Error() string
type ErrRuleNotCompiled ¶ added in v0.34.0
type ErrRuleNotCompiled struct {
RuleID string
}
ErrRuleNotCompiled error returned by functions that require to have the rule compiled
func (ErrRuleNotCompiled) Error ¶ added in v0.34.0
func (e ErrRuleNotCompiled) Error() string
type ErrRuleParse ¶
type ErrRuleParse struct {
// contains filtered or unexported fields
}
ErrRuleParse describes a parsing error and its position in the expression
func (*ErrRuleParse) Error ¶
func (e *ErrRuleParse) Error() string
type ErrValueTypeMismatch ¶
type ErrValueTypeMismatch struct {
Field string
}
ErrValueTypeMismatch error when the given value is not having the correct type
func (ErrValueTypeMismatch) Error ¶
func (e ErrValueTypeMismatch) Error() string
type Evaluator ¶
type Evaluator interface { Eval(ctx *Context) interface{} IsDeterministicFor(field Field) bool GetField() string IsStatic() bool }
Evaluator is the interface of an evaluator
type Event ¶
type Event interface { // GetType returns the Type of the Event GetType() EventType // GetFieldEventType returns the Event Type for the given Field GetFieldEventType(field Field) (EventType, error) // SetFieldValue sets the value of the given Field SetFieldValue(field Field, value interface{}) error // GetFieldValue returns the value of the given Field GetFieldValue(field Field) (interface{}, error) // GetFieldType returns the Type of the Field GetFieldType(field Field) (reflect.Kind, error) // GetPointer returns an unsafe.Pointer of this object GetPointer() unsafe.Pointer // GetTags returns a list of tags GetTags() []string }
Event is an interface that an Event has to implement for the evaluation
type FieldValue ¶
type FieldValue struct { Value interface{} Type FieldValueType IPMatcher IPMatcher }
FieldValue describes a field value with its type
func NewIPFieldValue ¶ added in v0.36.0
func NewIPFieldValue(ip net.IP, net *net.IPNet) *FieldValue
NewIPFieldValue returns a new FieldValue pointer initiailised with the provided IP
func (*FieldValue) Compile ¶ added in v0.34.0
func (f *FieldValue) Compile() error
Compile the regular expression or the pattern
type FieldValueType ¶
type FieldValueType int
FieldValueType represents the type of the value of a field
const ( ScalarValueType FieldValueType = 1 << 0 PatternValueType FieldValueType = 1 << 1 RegexpValueType FieldValueType = 1 << 2 BitmaskValueType FieldValueType = 1 << 3 VariableValueType FieldValueType = 1 << 4 IPValueType FieldValueType = 1 << 5 CIDRValueType FieldValueType = 1 << 6 )
Field value types
type Glob ¶ added in v0.34.0
type Glob struct {
// contains filtered or unexported fields
}
Glob describes file glob object
type GlobStringMatcher ¶ added in v0.34.0
type GlobStringMatcher struct {
// contains filtered or unexported fields
}
GlobStringMatcher defines a glob pattern matcher
func (*GlobStringMatcher) Compile ¶ added in v0.34.0
func (g *GlobStringMatcher) Compile(pattern string, caseInsensitive bool) error
Compile a simple pattern
func (*GlobStringMatcher) Contains ¶ added in v0.34.0
func (g *GlobStringMatcher) Contains(value string) bool
Contains returns whether the pattern contains the value
func (*GlobStringMatcher) Matches ¶ added in v0.34.0
func (g *GlobStringMatcher) Matches(value string) bool
Matches returns whether the value matches
type GlobalVariables ¶ added in v0.35.0
type GlobalVariables struct{}
GlobalVariables holds a set of global variables
func (*GlobalVariables) GetVariable ¶ added in v0.35.0
func (v *GlobalVariables) GetVariable(name string, value interface{}) (VariableValue, error)
GetVariable returns new variable of the type of the specified value
type IPMatcher ¶ added in v0.36.0
type IPMatcher interface { Compile(pattern string) error IPMatches(value net.IP) bool Matches(value IPMatcher) bool GetType() FieldValueType String() string }
IPMatcher defines an IP matcher
func NewIPMatcher ¶ added in v0.36.0
func NewIPMatcher(kind FieldValueType, pattern string) (IPMatcher, error)
NewIPMatcher returns a new IP matcher
type IntArrayEvaluator ¶
type IntArrayEvaluator struct { EvalFnc func(ctx *Context) []int Field Field Values []int Weight int OpOverrides *OpOverrides // contains filtered or unexported fields }
IntArrayEvaluator returns an array of int
func (*IntArrayEvaluator) AppendValues ¶ added in v0.34.0
func (i *IntArrayEvaluator) AppendValues(values ...int)
AppendValues to the array evaluator
func (*IntArrayEvaluator) Eval ¶
func (i *IntArrayEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*IntArrayEvaluator) GetField ¶
func (i *IntArrayEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*IntArrayEvaluator) IsDeterministicFor ¶ added in v0.35.0
func (i *IntArrayEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*IntArrayEvaluator) IsStatic ¶ added in v0.36.0
func (i *IntArrayEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
type IntArrayVariable ¶ added in v0.35.0
type IntArrayVariable struct { Variable // contains filtered or unexported fields }
IntArrayVariable describes an integer array variable
func NewIntArrayVariable ¶ added in v0.35.0
func NewIntArrayVariable(intFnc func(ctx *Context) []int, setFnc func(ctx *Context, value interface{}) error) *IntArrayVariable
NewIntArrayVariable returns a new integer array variable
func (*IntArrayVariable) Append ¶ added in v0.35.0
func (s *IntArrayVariable) Append(ctx *Context, value interface{}) error
Append a value to the array
func (*IntArrayVariable) GetEvaluator ¶ added in v0.35.0
func (s *IntArrayVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
func (*IntArrayVariable) Set ¶ added in v0.35.0
func (s *IntArrayVariable) Set(ctx *Context, value interface{}) error
Set the array values
type IntEvaluator ¶
type IntEvaluator struct { EvalFnc func(ctx *Context) int Field Field Value int Weight int OpOverrides *OpOverrides // contains filtered or unexported fields }
IntEvaluator returns an int as result of the evaluation
func IntAnd ¶
func IntAnd(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*IntEvaluator, error)
func IntNot ¶
func IntNot(a *IntEvaluator, opts *Opts, state *State) *IntEvaluator
IntNot - ^int operator
func IntOr ¶
func IntOr(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*IntEvaluator, error)
func IntXor ¶
func IntXor(a *IntEvaluator, b *IntEvaluator, opts *Opts, state *State) (*IntEvaluator, error)
func Minus ¶
func Minus(a *IntEvaluator, opts *Opts, state *State) *IntEvaluator
Minus - -int operator
func (*IntEvaluator) Eval ¶
func (i *IntEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*IntEvaluator) GetField ¶
func (i *IntEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*IntEvaluator) IsDeterministicFor ¶ added in v0.35.0
func (i *IntEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*IntEvaluator) IsStatic ¶ added in v0.36.0
func (i *IntEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
type IntVariable ¶ added in v0.35.0
type IntVariable struct { Variable // contains filtered or unexported fields }
IntVariable describes an integer variable
func NewIntVariable ¶ added in v0.35.0
func NewIntVariable(intFnc func(ctx *Context) int, setFnc func(ctx *Context, value interface{}) error) *IntVariable
NewIntVariable returns a new integer variable
func (*IntVariable) GetEvaluator ¶ added in v0.35.0
func (i *IntVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
type Macro ¶
Macro - Macro object identified by an `ID` containing a SECL `Expression`
func NewStringValuesMacro ¶ added in v0.35.0
NewStringValuesMacro returns a new macro from an array of strings
func (*Macro) GenEvaluator ¶
GenEvaluator - Compiles and generates the evalutor
func (*Macro) GetEvaluator ¶
func (m *Macro) GetEvaluator() *MacroEvaluator
GetEvaluator - Returns the MacroEvaluator of the Macro corresponding to the SECL `Expression`
func (*Macro) GetEventTypes ¶
GetEventTypes - Returns a list of all the Event Type that the `Expression` handles
type MacroEvaluator ¶
type MacroEvaluator struct { Value interface{} EventTypes []EventType FieldValues map[Field][]FieldValue }
MacroEvaluator - Evaluation part of a Macro
func (*MacroEvaluator) GetFields ¶
func (m *MacroEvaluator) GetFields() []Field
GetFields - Returns all the Field that the MacroEvaluator handles
type Model ¶
type Model interface { // GetEvaluator returns an evaluator for the given field GetEvaluator(field Field, regID RegisterID) (Evaluator, error) // ValidateField returns whether the value use against the field is valid, ex: for constant ValidateField(field Field, value FieldValue) error // GetIterator return an iterator GetIterator(field Field) (Iterator, error) // NewEvent returns a new event instance NewEvent() Event }
Model - interface that a model has to implement for the rule compilation
type MutableBoolVariable ¶ added in v0.35.0
type MutableBoolVariable struct {
Value bool
}
MutableBoolVariable describes a mutable boolean variable
func NewMutableBoolVariable ¶ added in v0.35.0
func NewMutableBoolVariable() *MutableBoolVariable
NewMutableBoolVariable returns a new mutable boolean variable
func (*MutableBoolVariable) Append ¶ added in v0.35.0
func (m *MutableBoolVariable) Append(ctx *Context, value interface{}) error
Append a value to the boolean
func (*MutableBoolVariable) GetEvaluator ¶ added in v0.35.0
func (m *MutableBoolVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
func (*MutableBoolVariable) Set ¶ added in v0.35.0
func (m *MutableBoolVariable) Set(ctx *Context, value interface{}) error
Set the variable with the specified value
type MutableIntArrayVariable ¶ added in v0.35.0
type MutableIntArrayVariable struct {
Values []int
}
MutableIntArrayVariable describes a mutable integer array variable
func NewMutableIntArrayVariable ¶ added in v0.35.0
func NewMutableIntArrayVariable() *MutableIntArrayVariable
NewMutableIntArrayVariable returns a new mutable integer array variable
func (*MutableIntArrayVariable) Append ¶ added in v0.35.0
func (m *MutableIntArrayVariable) Append(ctx *Context, value interface{}) error
Append a value to the array
func (*MutableIntArrayVariable) GetEvaluator ¶ added in v0.35.0
func (m *MutableIntArrayVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
func (*MutableIntArrayVariable) Set ¶ added in v0.35.0
func (m *MutableIntArrayVariable) Set(ctx *Context, values interface{}) error
Set the variable with the specified value
type MutableIntVariable ¶ added in v0.35.0
type MutableIntVariable struct {
Value int
}
MutableIntVariable describes a mutable integer variable
func NewMutableIntVariable ¶ added in v0.35.0
func NewMutableIntVariable() *MutableIntVariable
NewMutableIntVariable returns a new mutable integer variable
func (*MutableIntVariable) Append ¶ added in v0.35.0
func (m *MutableIntVariable) Append(ctx *Context, value interface{}) error
Append a value to the integer
func (*MutableIntVariable) GetEvaluator ¶ added in v0.35.0
func (m *MutableIntVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
func (*MutableIntVariable) Set ¶ added in v0.35.0
func (m *MutableIntVariable) Set(ctx *Context, value interface{}) error
Set the variable with the specified value
type MutableStringArrayVariable ¶ added in v0.35.0
type MutableStringArrayVariable struct {
StringValues
}
MutableStringArrayVariable describes a mutable string array variable
func NewMutableStringArrayVariable ¶ added in v0.35.0
func NewMutableStringArrayVariable() *MutableStringArrayVariable
NewMutableStringArrayVariable returns a new mutable string array variable
func (*MutableStringArrayVariable) Append ¶ added in v0.35.0
func (m *MutableStringArrayVariable) Append(ctx *Context, value interface{}) error
Append a value to the array
func (*MutableStringArrayVariable) GetEvaluator ¶ added in v0.35.0
func (m *MutableStringArrayVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
func (*MutableStringArrayVariable) Set ¶ added in v0.35.0
func (m *MutableStringArrayVariable) Set(ctx *Context, values interface{}) error
Set the variable with the specified value
type MutableStringVariable ¶ added in v0.35.0
type MutableStringVariable struct {
Value string
}
MutableStringVariable describes a mutable string variable
func NewMutableStringVariable ¶ added in v0.35.0
func NewMutableStringVariable() *MutableStringVariable
NewMutableStringVariable returns a new mutable string variable
func (*MutableStringVariable) Append ¶ added in v0.35.0
func (m *MutableStringVariable) Append(ctx *Context, value interface{}) error
Append a value to the string
func (*MutableStringVariable) GetEvaluator ¶ added in v0.35.0
func (m *MutableStringVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
func (*MutableStringVariable) Set ¶ added in v0.35.0
func (m *MutableStringVariable) Set(ctx *Context, value interface{}) error
Set the variable with the specified value
type MutableVariable ¶ added in v0.35.0
type MutableVariable interface { Set(ctx *Context, value interface{}) error Append(ctx *Context, value interface{}) error }
MutableVariable is the interface implemented by modifiable variables
type OpOverrides ¶ added in v0.34.0
type OpOverrides struct { StringEquals func(a *StringEvaluator, b *StringEvaluator, opts *Opts, state *State) (*BoolEvaluator, error) StringValuesContains func(a *StringEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error) StringArrayContains func(a *StringEvaluator, b *StringArrayEvaluator, opts *Opts, state *State) (*BoolEvaluator, error) StringArrayMatches func(a *StringArrayEvaluator, b *StringValuesEvaluator, opts *Opts, state *State) (*BoolEvaluator, error) }
OpOverrides defines operator override functions
type Opts ¶
type Opts struct { LegacyFields map[Field]Field Constants map[string]interface{} Macros map[MacroID]*Macro Variables map[string]VariableValue UserCtx interface{} }
Opts are the options to be passed to the evaluator
func (*Opts) WithConstants ¶ added in v0.34.0
WithConstants set constants
func (*Opts) WithLegacyFields ¶ added in v0.34.0
WithLegacyFields set legacy fields
func (*Opts) WithMacros ¶ added in v0.34.0
WithMacros set macros fields
func (*Opts) WithUserContext ¶ added in v0.34.0
WithUserContext set user context
func (*Opts) WithVariables ¶ added in v0.34.0
func (o *Opts) WithVariables(variables map[string]VariableValue) *Opts
WithVariables set variables
type RegexpStringMatcher ¶ added in v0.34.0
type RegexpStringMatcher struct {
// contains filtered or unexported fields
}
RegexpStringMatcher defines a regular expression pattern matcher
func (*RegexpStringMatcher) Compile ¶ added in v0.34.0
func (r *RegexpStringMatcher) Compile(pattern string, caseInsensitive bool) error
Compile a regular expression based pattern
func (*RegexpStringMatcher) Matches ¶ added in v0.34.0
func (r *RegexpStringMatcher) Matches(value string) bool
Matches returns whether the value matches
type Rule ¶
type Rule struct { ID RuleID Expression string Tags []string Opts *Opts Model Model // contains filtered or unexported fields }
Rule - Rule object identified by an `ID` containing a SECL `Expression`
func (*Rule) GenEvaluator ¶
GenEvaluator - Compile and generates the RuleEvaluator
func (*Rule) GenPartials ¶
GenPartials - Compiles and generates partial Evaluators
func (*Rule) GetEvaluator ¶
func (r *Rule) GetEvaluator() *RuleEvaluator
GetEvaluator - Returns the RuleEvaluator of the Rule corresponding to the SECL `Expression`
func (*Rule) GetEventTypes ¶
GetEventTypes - Returns a list of all the event that the `Expression` handles
func (*Rule) GetFieldValues ¶
func (r *Rule) GetFieldValues(field Field) []FieldValue
GetFieldValues returns the values of the given field
func (*Rule) GetFields ¶
GetFields - Returns all the Field of the Rule including field of the Macro used
func (*Rule) GetPartialEval ¶
func (r *Rule) GetPartialEval(field Field) BoolEvalFnc
GetPartialEval - Returns the Partial RuleEvaluator for the given Field
type RuleEvaluator ¶
type RuleEvaluator struct { Eval BoolEvalFnc EventTypes []EventType FieldValues map[Field][]FieldValue // contains filtered or unexported fields }
RuleEvaluator - Evaluation part of a Rule
func (*RuleEvaluator) GetFields ¶
func (r *RuleEvaluator) GetFields() []Field
GetFields - Returns all the Field that the RuleEvaluator handles
func (*RuleEvaluator) PartialEval ¶
func (r *RuleEvaluator) PartialEval(ctx *Context, field Field) (bool, error)
PartialEval partially evaluation of the Rule with the given Field.
type ScalarStringMatcher ¶ added in v0.36.0
type ScalarStringMatcher struct {
// contains filtered or unexported fields
}
ScalarStringMatcher defines a scalar matcher
func (*ScalarStringMatcher) Compile ¶ added in v0.36.0
func (s *ScalarStringMatcher) Compile(pattern string, caseInsensitive bool) error
Compile a simple pattern
func (*ScalarStringMatcher) Matches ¶ added in v0.36.0
func (s *ScalarStringMatcher) Matches(value string) bool
Matches returns whether the value matches
type ScopedVariables ¶ added in v0.35.0
type ScopedVariables struct {
// contains filtered or unexported fields
}
ScopedVariables holds a set of scoped variables
func NewScopedVariables ¶ added in v0.35.0
func NewScopedVariables(scoper Scoper, onNewVariables func(unsafe.Pointer)) *ScopedVariables
NewScopedVariables returns a new set of scope variables
func (*ScopedVariables) GetVariable ¶ added in v0.35.0
func (v *ScopedVariables) GetVariable(name string, value interface{}) (VariableValue, error)
GetVariable returns new variable of the type of the specified value
func (*ScopedVariables) ReleaseVariable ¶ added in v0.35.0
func (v *ScopedVariables) ReleaseVariable(key unsafe.Pointer)
ReleaseVariable releases a scoped variable
type SingleIPMatcher ¶ added in v0.36.0
type SingleIPMatcher struct {
// contains filtered or unexported fields
}
SingleIPMatcher defines an IPv4/IPv6 matcher
func (*SingleIPMatcher) Compile ¶ added in v0.36.0
func (sipm *SingleIPMatcher) Compile(pattern string) error
Compile the string representation of an IP to a net.IP
func (*SingleIPMatcher) GetType ¶ added in v0.36.0
func (sipm *SingleIPMatcher) GetType() FieldValueType
GetType returns the FieldValueType of the IPMatcher
func (*SingleIPMatcher) IPMatches ¶ added in v0.36.0
func (sipm *SingleIPMatcher) IPMatches(value net.IP) bool
IPMatches returns true the value matches
func (*SingleIPMatcher) Matches ¶ added in v0.36.0
func (sipm *SingleIPMatcher) Matches(value IPMatcher) bool
Matches matches with an IPMatcher
func (*SingleIPMatcher) String ¶ added in v0.36.0
func (sipm *SingleIPMatcher) String() string
type State ¶ added in v0.34.0
type State struct {
// contains filtered or unexported fields
}
State defines the current state of the rule compilation
func NewState ¶ added in v0.36.0
func NewState(model Model, field Field, macros map[MacroID]*MacroEvaluator) *State
NewState returns a new State
func (*State) UpdateFieldValues ¶ added in v0.34.0
func (s *State) UpdateFieldValues(field Field, value FieldValue) error
UpdateFieldValues updates the field values
func (*State) UpdateFields ¶ added in v0.34.0
UpdateFields updates the fields used in the rule
type StringArrayEvaluator ¶
type StringArrayEvaluator struct { EvalFnc func(ctx *Context) []string Values []string Field Field Weight int OpOverrides *OpOverrides StringCmpOpts StringCmpOpts // only Field evaluator can set this value // contains filtered or unexported fields }
StringArrayEvaluator returns an array of strings
func (*StringArrayEvaluator) AppendValue ¶ added in v0.34.0
func (s *StringArrayEvaluator) AppendValue(value string)
AppendValue append the given value
func (*StringArrayEvaluator) Eval ¶
func (s *StringArrayEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*StringArrayEvaluator) GetField ¶
func (s *StringArrayEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*StringArrayEvaluator) IsDeterministicFor ¶ added in v0.35.0
func (s *StringArrayEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*StringArrayEvaluator) IsStatic ¶ added in v0.36.0
func (s *StringArrayEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
type StringArrayVariable ¶ added in v0.35.0
type StringArrayVariable struct { Variable // contains filtered or unexported fields }
StringArrayVariable describes a string array variable
func NewStringArrayVariable ¶ added in v0.35.0
func NewStringArrayVariable(strFnc func(ctx *Context) []string, setFnc func(ctx *Context, value interface{}) error) *StringArrayVariable
NewStringArrayVariable returns a new string array variable
func (*StringArrayVariable) Append ¶ added in v0.35.0
func (s *StringArrayVariable) Append(ctx *Context, value interface{}) error
Append a value to the array
func (*StringArrayVariable) GetEvaluator ¶ added in v0.35.0
func (s *StringArrayVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
func (*StringArrayVariable) Set ¶ added in v0.35.0
func (s *StringArrayVariable) Set(ctx *Context, value interface{}) error
Set the array values
type StringCmpOpts ¶ added in v0.36.0
type StringCmpOpts struct { ScalarCaseInsensitive bool GlobCaseInsensitive bool RegexpCaseInsensitive bool }
StringCmpOpts defines options to apply during string comparison
type StringEvaluator ¶
type StringEvaluator struct { EvalFnc func(ctx *Context) string Field Field Value string Weight int OpOverrides *OpOverrides ValueType FieldValueType StringCmpOpts StringCmpOpts // only Field evaluator can set this value // contains filtered or unexported fields }
StringEvaluator returns a string as result of the evaluation
func (*StringEvaluator) Eval ¶
func (s *StringEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*StringEvaluator) GetField ¶
func (s *StringEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*StringEvaluator) GetValue ¶ added in v0.34.0
func (s *StringEvaluator) GetValue(ctx *Context) string
GetValue returns the evaluator value
func (*StringEvaluator) IsDeterministicFor ¶ added in v0.35.0
func (s *StringEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*StringEvaluator) IsStatic ¶ added in v0.36.0
func (s *StringEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
func (*StringEvaluator) ToStringMatcher ¶ added in v0.36.0
func (s *StringEvaluator) ToStringMatcher(opts StringCmpOpts) (StringMatcher, error)
ToStringMatcher returns a StringMatcher of the evaluator
type StringMatcher ¶ added in v0.34.0
type StringMatcher interface { Compile(pattern string, caseInsensitive bool) error Matches(value string) bool }
StringMatcher defines a pattern matcher
func NewStringMatcher ¶ added in v0.34.0
func NewStringMatcher(kind FieldValueType, pattern string, opts StringCmpOpts) (StringMatcher, error)
NewStringMatcher returns a new string matcher
type StringValues ¶ added in v0.34.0
type StringValues struct {
// contains filtered or unexported fields
}
StringValues describes a set of string values, either regex or scalar
func (*StringValues) AppendFieldValue ¶ added in v0.34.0
func (s *StringValues) AppendFieldValue(value FieldValue)
AppendFieldValue append a FieldValue
func (*StringValues) AppendScalarValue ¶ added in v0.34.0
func (s *StringValues) AppendScalarValue(value string)
AppendScalarValue append a scalar string value
func (*StringValues) Compile ¶ added in v0.36.0
func (s *StringValues) Compile(opts StringCmpOpts) error
Compile all the values
func (*StringValues) GetScalarValues ¶ added in v0.34.0
func (s *StringValues) GetScalarValues() []string
GetScalarValues return the scalar values
func (*StringValues) GetStringMatchers ¶ added in v0.34.0
func (s *StringValues) GetStringMatchers() []StringMatcher
GetStringMatchers return the pattern matchers
func (*StringValues) Matches ¶ added in v0.34.0
func (s *StringValues) Matches(value string) bool
Matches returns whether the value matches the string values
func (*StringValues) SetFieldValues ¶ added in v0.34.0
func (s *StringValues) SetFieldValues(values ...FieldValue) error
SetFieldValues apply field values
type StringValuesEvaluator ¶ added in v0.34.0
type StringValuesEvaluator struct { EvalFnc func(ctx *Context) *StringValues Values StringValues Weight int // contains filtered or unexported fields }
StringValuesEvaluator returns an array of strings
func (*StringValuesEvaluator) AppendFieldValues ¶ added in v0.34.0
func (s *StringValuesEvaluator) AppendFieldValues(values ...FieldValue)
AppendFieldValues append field values
func (*StringValuesEvaluator) AppendMembers ¶ added in v0.34.0
func (s *StringValuesEvaluator) AppendMembers(members ...ast.StringMember)
AppendMembers add members to the evaluator
func (*StringValuesEvaluator) Compile ¶ added in v0.36.0
func (s *StringValuesEvaluator) Compile(opts StringCmpOpts) error
Compile the underlying StringValues
func (*StringValuesEvaluator) Eval ¶ added in v0.34.0
func (s *StringValuesEvaluator) Eval(ctx *Context) interface{}
Eval returns the result of the evaluation
func (*StringValuesEvaluator) GetField ¶ added in v0.34.0
func (s *StringValuesEvaluator) GetField() string
GetField returns field name used by this evaluator
func (*StringValuesEvaluator) IsDeterministicFor ¶ added in v0.35.0
func (s *StringValuesEvaluator) IsDeterministicFor(field Field) bool
IsDeterministicFor returns whether the evaluator is partial
func (*StringValuesEvaluator) IsStatic ¶ added in v0.36.0
func (s *StringValuesEvaluator) IsStatic() bool
IsStatic returns whether the evaluator is a scalar
func (*StringValuesEvaluator) SetFieldValues ¶ added in v0.34.0
func (s *StringValuesEvaluator) SetFieldValues(values ...FieldValue) error
SetFieldValues apply field values
type StringVariable ¶ added in v0.35.0
type StringVariable struct { Variable // contains filtered or unexported fields }
StringVariable describes a string variable
func NewStringVariable ¶ added in v0.35.0
func NewStringVariable(strFnc func(ctx *Context) string, setFnc func(ctx *Context, value interface{}) error) *StringVariable
NewStringVariable returns a new string variable
func (*StringVariable) GetEvaluator ¶ added in v0.35.0
func (s *StringVariable) GetEvaluator() interface{}
GetEvaluator returns the variable SECL evaluator
type Variable ¶ added in v0.35.0
type Variable struct {
// contains filtered or unexported fields
}
Variable describes a SECL variable
type VariableValue ¶
type VariableValue interface {
GetEvaluator() interface{}
}
VariableValue describes a SECL variable value
type Variables ¶ added in v0.35.0
type Variables struct {
// contains filtered or unexported fields
}
Variables holds a set of variables
func (*Variables) GetBool ¶ added in v0.35.0
GetBool returns the boolean value of the specified variable
func (*Variables) GetInt ¶ added in v0.35.0
GetInt returns the integer value of the specified variable
func (*Variables) GetIntArray ¶ added in v0.35.0
GetIntArray returns the integer array value of the specified variable
func (*Variables) GetString ¶ added in v0.35.0
GetString returns the string value of the specified variable
func (*Variables) GetStringArray ¶ added in v0.35.0
GetStringArray returns the string array value of the specified variable