rules

package
v0.0.0-...-4e65831 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateIsRegex

func ValidateIsRegex(fl validator.FieldLevel) bool

ValidateIsRegex implements validator.Func

Types

type Configuration

type Configuration struct {
	Rules []*Rule `yaml:"rules" validate:"required,dive"`
}

Configuration configuration containing our rules which are used to filter events

func Load

func Load(rawCfg string) (*Configuration, error)

Load load the configuration from the provided string

func LoadFromSSMAndValidate

func LoadFromSSMAndValidate(ctx context.Context, ssm ssmcache.Cache, path string) (*Configuration, error)

LoadFromSSMAndValidate load the configuration from ssmcache and validate it

func (*Configuration) EvalRules

func (cr *Configuration) EvalRules(evt map[string]interface{}) (bool, error)

EvalRules iterate over all rules and return a match if one evaluates to true

func (*Configuration) Validate

func (cr *Configuration) Validate() error

Validate validate the configuration rules

type Match

type Match struct {
	FieldName string `yaml:"field_name" validate:"required,oneof=eventName eventSource awsRegion recipientAccountId"`
	Regex     string `yaml:"regex" validate:"is-regex"`
}

Match match containing the field to be checked and the REGEX used to match

type Rule

type Rule struct {
	Name    string   `yaml:"name" validate:"required"`
	Matches []*Match `yaml:"matches" validate:"required,dive"`
}

Rule rule with a name, and one or more matches

func (*Rule) Eval

func (mc *Rule) Eval(evt map[string]interface{}) (bool, error)

Eval evaluate the match for a given event, this will run each field check in the rule if ALL evaluate to true

Jump to

Keyboard shortcuts

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