compiler

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpectedReteMatcher = errors.New("expected rete matcher")
	ErrExpectedJsonMatcher = errors.New("expected jq json matcher")
	ErrExpectedLogMatcher  = errors.New("expected log matcher")
	ErrExpectedCbDetect    = errors.New("expected detect callback")
	ErrInvalidCbArgs       = errors.New("invalid callback arguments")
	ErrNotFound            = errors.New("not found")
)
View Source
var (
	ErrUnsupportedMatcher = errors.New("unsupported matcher")
	ErrUnsupportedScope   = errors.New("unsupported scope")
	ErrInvalidMatcher     = errors.New("invalid matcher")
)
View Source
var (
	ErrUnsupportedNodeType  = errors.New("unsupported node type")
	ErrUnsupportedEventType = errors.New("unsupported event type")
	ErrSequenceSingleMatch  = errors.New("sequence with single match (use set instead)")
	ErrNoFields             = errors.New("no fields")
)

Functions

func GetJqMatcher

func GetJqMatcher(obj *ObjT) (lm.MatchFunc, error)

func GetLogInverseSeqMatcher

func GetLogInverseSeqMatcher(obj *ObjT) (*lm.InverseSeq, error)

func GetLogSeqMatcher

func GetLogSeqMatcher(obj *ObjT) (*lm.MatchSeq, error)

func GetLogSingleMatcher

func GetLogSingleMatcher(obj *ObjT) (*lm.MatchSingle, error)

Types

type AssertParamsT

type AssertParamsT struct {
	Address *ast.AstNodeAddressT
}

type CallbackT added in v0.0.8

type CallbackT func(ctx context.Context, param any) error

type CompilerOptT

type CompilerOptT func(*compilerOptsT)

func WithDebugTree

func WithDebugTree(path string) CompilerOptT

func WithPlugin

func WithPlugin(scope string, plugin PluginI) CompilerOptT

func WithRuntime

func WithRuntime(cb RuntimeI) CompilerOptT

type DefaultPlugin added in v0.0.17

type DefaultPlugin struct{}

func NewDefaultPlugin added in v0.0.17

func NewDefaultPlugin() *DefaultPlugin

func (*DefaultPlugin) Compile added in v0.0.17

func (p *DefaultPlugin) Compile(runtime RuntimeI, node *ast.AstNodeT) (ObjsT, error)

type MatchParamsT

type MatchParamsT struct {
	Address       *ast.AstNodeAddressT
	ParentAddress *ast.AstNodeAddressT
	Origin        bool
}

type NoopRuntime

type NoopRuntime struct{}

-----

func NewNoopRuntime

func NewNoopRuntime() *NoopRuntime

func (*NoopRuntime) NewCbAssert

func (f *NoopRuntime) NewCbAssert(params AssertParamsT) CallbackT

func (*NoopRuntime) NewCbMatch

func (f *NoopRuntime) NewCbMatch(params MatchParamsT) CallbackT

type ObjT

type ObjT struct {
	RuleId        string               `json:"rule_id"`
	Address       *ast.AstNodeAddressT `json:"address"`
	ParentAddress *ast.AstNodeAddressT `json:"parent_address"`
	Scope         string               `json:"scope"`
	AbstractType  schema.NodeTypeT     `json:"abstract_type"`
	ObjectType    ObjTypeT             `json:"object_type"`
	Event         ast.AstEventT        `json:"event"`
	Object        any                  `json:"object"`
	Cb            CallbackT            `json:"cb"`
}

func NewObj

func NewObj(node *ast.AstNodeT, objType ObjTypeT) *ObjT

func ObjLogMatcher

func ObjLogMatcher(runtime RuntimeI, node *ast.AstNodeT) (*ObjT, error)

type ObjTypeT added in v0.0.3

type ObjTypeT string
const (
	ObjTypeMatcher ObjTypeT = "match"
	ObjTypeAssert  ObjTypeT = "assert"
)

func (ObjTypeT) String added in v0.0.3

func (o ObjTypeT) String() string

type ObjsT

type ObjsT []*ObjT

func Compile

func Compile(data []byte, scope string, opts ...CompilerOptT) (ObjsT, error)

func CompileAst added in v0.0.3

func CompileAst(tree *ast.AstT, scope string, opts ...CompilerOptT) (ObjsT, error)

func CompileTree

func CompileTree(pt *parser.TreeT, scope string, opts ...CompilerOptT) (ObjsT, error)

type PluginI

type PluginI interface {
	Compile(runtime RuntimeI, node *ast.AstNodeT) (ObjsT, error)
}

type RuntimeI

type RuntimeI interface {
	NewCbMatch(params MatchParamsT) CallbackT
	NewCbAssert(params AssertParamsT) CallbackT
}

Jump to

Keyboard shortcuts

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