Documentation
¶
Index ¶
- Constants
- Variables
- func Hash(h string) string
- func HashRule(rule ParseRuleT) (string, error)
- func ParseCres(data []byte) (map[string]ParseCreT, error)
- func RootNode(data []byte) (*yaml.Node, error)
- func StableHash(rule ParseRuleT) (string, error)
- func WithGenIds() func(*parseOptsT)
- type EventT
- type ExtractT
- type FieldT
- type MatcherT
- type NegateOptsT
- type NodeMetadataT
- type NodeT
- type ParseApplicationT
- type ParseCreT
- type ParseEventT
- type ParseExtractT
- type ParseNegateOptsT
- type ParseOptT
- type ParsePromQL
- type ParseRuleDataT
- type ParseRuleMetadataT
- type ParseRuleT
- type ParseSequenceT
- type ParseSetT
- type ParseTermT
- type PromQLT
- type RulesT
- type TermsT
- type TreeT
Constants ¶
View Source
const ( SeverityCritical = 0 SeverityHigh = 1 SeverityMedium = 2 SeverityLow = 3 SeverityInfo = 4 )
Variables ¶
View Source
var ( ErrRuleNotFound = errors.New("rule not found") ErrRuleRootNotFound = errors.New("missing rule section") ErrNotSupported = errors.New("not supported") ErrTermNotFound = errors.New("term not found") ErrMissingOrder = errors.New("'sequence' missing 'order'") ErrMissingMatch = errors.New("'set' missing 'match'") ErrInvalidWindow = errors.New("invalid 'window'") ErrTermsMapping = errors.New("'terms' must be a mapping") ErrDuplicateTerm = errors.New("duplicate term name") ErrMissingRuleId = errors.New("missing rule id") ErrMissingRuleHash = errors.New("missing rule hash") ErrMissingCreId = errors.New("missing cre id") ErrInvalidCreId = errors.New("invalid cre id") ErrInvalidRuleId = errors.New("invalid rule id (must be base58)") ErrInvalidRuleHash = errors.New("invalid rule hash (must be base58)") ErrExtractName = errors.New("invalid extract name (alphanumeric and underscores only)") ErrInnerEvent = errors.New("invalid event on inner node") )
View Source
var PromQLValidator = func(expr string) error { return nil }
PromQLValidator validates a PromQL expression. Hook exposed to avoid importing promql dependencies in compiler.
Functions ¶
func HashRule ¶ added in v0.0.11
func HashRule(rule ParseRuleT) (string, error)
func StableHash ¶ added in v0.0.16
func StableHash(rule ParseRuleT) (string, error)
func WithGenIds ¶ added in v0.0.11
func WithGenIds() func(*parseOptsT)
Types ¶
type NegateOptsT ¶
type NodeMetadataT ¶
type NodeMetadataT struct {
RuleHash string `json:"rule_hash"`
RuleId string `json:"rule_id"`
CreId string `json:"cre_id"`
Window time.Duration `json:"window"`
Event *EventT `json:"event"`
Type schema.NodeTypeT `json:"type"`
Correlations []string `json:"correlations"`
NegateOpts *NegateOptsT `json:"negate_opts"`
Pos pqerr.Pos `json:"pos"`
}
type NodeT ¶
type NodeT struct {
Metadata NodeMetadataT `json:"metadata"`
NegIdx int `json:"neg_idx"`
Children []any `json:"children"`
}
func (*NodeT) IsMatcherNode ¶ added in v0.0.19
func (*NodeT) IsPromNode ¶ added in v0.0.19
type ParseApplicationT ¶
type ParseApplicationT struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
ProcessName string `yaml:"processName,omitempty" json:"process_name,omitempty"`
ProcessPath string `yaml:"processPath,omitempty" json:"process_path,omitempty"`
ContainerName string `yaml:"containerName,omitempty" json:"container_name,omitempty"`
ImageUrl string `yaml:"imageUrl,omitempty" json:"image_url,omitempty"`
RepoUrl string `yaml:"repoUrl,omitempty" json:"repo_url,omitempty"`
Version string `yaml:"version,omitempty" json:"version,omitempty"`
}
type ParseCreT ¶
type ParseCreT struct {
Id string `yaml:"id,omitempty" json:"id,omitempty"`
Severity uint `yaml:"severity" json:"severity"`
Title string `yaml:"title,omitempty" json:"title,omitempty"`
Category string `yaml:"category,omitempty" json:"category,omitempty"`
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
Author string `yaml:"author,omitempty" json:"author,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Impact string `yaml:"impact,omitempty" json:"impact,omitempty"`
ImpactScore uint `yaml:"impactScore,omitempty" json:"impact_score,omitempty"`
Cause string `yaml:"cause,omitempty" json:"cause,omitempty"`
Mitigation string `yaml:"mitigation,omitempty" json:"mitigation,omitempty"`
MitigationScore uint `yaml:"mitigationScore,omitempty" json:"mitigation_score,omitempty"`
References []string `yaml:"references,omitempty" json:"references,omitempty"`
Reports uint `yaml:"reports,omitempty" json:"reports,omitempty"`
Applications []ParseApplicationT `yaml:"applications,omitempty" json:"applications,omitempty"`
}
type ParseEventT ¶
type ParseExtractT ¶ added in v0.0.17
type ParseNegateOptsT ¶
type ParsePromQL ¶ added in v0.0.19
type ParsePromQL struct {
Expr string `yaml:"expr"`
Interval string `yaml:"interval,omitempty"`
For string `yaml:"for,omitempty"`
Event *ParseEventT `yaml:"event,omitempty"`
}
type ParseRuleDataT ¶
type ParseRuleDataT struct {
Sequence *ParseSequenceT `yaml:"sequence,omitempty"`
Set *ParseSetT `yaml:"set,omitempty"`
}
type ParseRuleMetadataT ¶
type ParseRuleMetadataT struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Id string `yaml:"id,omitempty" json:"id,omitempty"`
Hash string `yaml:"hash,omitempty" json:"hash,omitempty"`
Gen uint `yaml:"generation" json:"generation"`
Kind string `yaml:"kind,omitempty" json:"kind,omitempty"`
Version string `yaml:"version,omitempty" json:"version,omitempty"`
}
type ParseRuleT ¶
type ParseRuleT struct {
Metadata ParseRuleMetadataT `yaml:"metadata,omitempty" json:"metadata,omitempty"`
Cre ParseCreT `yaml:"cre,omitempty" json:"cre,omitempty"`
Rule ParseRuleDataT `yaml:"rule,omitempty" json:"rule,omitempty"`
}
type ParseSequenceT ¶
type ParseSequenceT struct {
Window string `yaml:"window"`
Correlations []string `yaml:"correlations,omitempty"`
Event *ParseEventT `yaml:"event,omitempty"`
Origin bool `yaml:"origin,omitempty"`
Order []ParseTermT `yaml:"order,omitempty"`
Negate []ParseTermT `yaml:"negate,omitempty"`
}
type ParseSetT ¶
type ParseSetT struct {
Window string `yaml:"window,omitempty"`
Correlations []string `yaml:"correlations,omitempty"`
Event *ParseEventT `yaml:"event,omitempty"`
Match []ParseTermT `yaml:"match,omitempty"`
Negate []ParseTermT `yaml:"negate,omitempty"`
}
type ParseTermT ¶
type ParseTermT struct {
Field string `yaml:"field,omitempty"`
StrValue string `yaml:"value,omitempty"`
JqValue string `yaml:"jq,omitempty"`
RegexValue string `yaml:"regex,omitempty"`
Count int `yaml:"count,omitempty"`
Set *ParseSetT `yaml:"set,omitempty"`
Sequence *ParseSequenceT `yaml:"sequence,omitempty"`
NegateOpts *ParseNegateOptsT `yaml:",inline,omitempty"`
PromQL *ParsePromQL `yaml:"promql,omitempty"`
Extract []ParseExtractT `yaml:"extract,omitempty"`
}
func (*ParseTermT) UnmarshalYAML ¶
func (o *ParseTermT) UnmarshalYAML(unmarshal func(any) error) error
type RulesT ¶
type RulesT struct {
Rules []ParseRuleT `yaml:"rules"`
Root *yaml.Node `yaml:"-"`
TermsT map[string]ParseTermT `yaml:"terms,omitempty"`
TermsY map[string]*yaml.Node `yaml:"-"`
}
Click to show internal directories.
Click to hide internal directories.