2020-05-15 09:39:16 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2020-11-30 09:37:17 +00:00
|
|
|
|
|
|
|
"github.com/antonmedv/expr/vm"
|
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/models"
|
2020-05-15 09:39:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
LOG = iota
|
|
|
|
OVFLW
|
|
|
|
)
|
|
|
|
|
2020-11-30 09:37:17 +00:00
|
|
|
//Event is the structure representing a runtime event (log or overflow)
|
2020-05-15 09:39:16 +00:00
|
|
|
type Event struct {
|
|
|
|
/* is it a log or an overflow */
|
2020-11-30 09:37:17 +00:00
|
|
|
Type int `yaml:"Type,omitempty" json:"Type,omitempty"` //Can be types.LOG (0) or types.OVFLOW (1)
|
|
|
|
ExpectMode int `yaml:"ExpectMode,omitempty" json:"ExpectMode,omitempty"` //how to buckets should handle event : leaky.TIMEMACHINE or leaky.LIVE
|
|
|
|
Whitelisted bool `yaml:"Whitelisted,omitempty" json:"Whitelisted,omitempty"`
|
|
|
|
WhiteListReason string `yaml:"whitelist_reason,omitempty" json:"whitelist_reason,omitempty"`
|
2020-05-15 09:39:16 +00:00
|
|
|
//should add whitelist reason ?
|
|
|
|
/* the current stage of the line being parsed */
|
2020-11-30 09:37:17 +00:00
|
|
|
Stage string `yaml:"Stage,omitempty" json:"Stage,omitempty"`
|
2020-05-15 09:39:16 +00:00
|
|
|
/* original line (produced by acquisition) */
|
2020-11-30 09:37:17 +00:00
|
|
|
Line Line `yaml:"Line,omitempty" json:"Line,omitempty"`
|
2020-05-15 09:39:16 +00:00
|
|
|
/* output of groks */
|
2020-11-30 09:37:17 +00:00
|
|
|
Parsed map[string]string `yaml:"Parsed,omitempty" json:"Parsed,omitempty"`
|
2020-05-15 09:39:16 +00:00
|
|
|
/* output of enrichment */
|
2020-11-30 09:37:17 +00:00
|
|
|
Enriched map[string]string `yaml:"Enriched,omitempty" json:"Enriched,omitempty"`
|
2020-05-15 09:39:16 +00:00
|
|
|
/* Overflow */
|
2020-11-30 09:37:17 +00:00
|
|
|
Overflow RuntimeAlert `yaml:"Alert,omitempty" json:"Alert,omitempty"`
|
|
|
|
Time time.Time `yaml:"Time,omitempty" json:"Time,omitempty"` //parsed time `json:"-"` ``
|
|
|
|
StrTime string `yaml:"StrTime,omitempty" json:"StrTime,omitempty"`
|
|
|
|
MarshaledTime string `yaml:"MarshaledTime,omitempty" json:"MarshaledTime,omitempty"`
|
|
|
|
Process bool `yaml:"Process,omitempty" json:"Process,omitempty"` //can be set to false to avoid processing line
|
2020-05-15 09:39:16 +00:00
|
|
|
/* Meta is the only part that will make it to the API - it should be normalized */
|
2020-11-30 09:37:17 +00:00
|
|
|
Meta map[string]string `yaml:"Meta,omitempty" json:"Meta,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//Move in leakybuckets
|
|
|
|
const (
|
|
|
|
Undefined = ""
|
|
|
|
Ip = "Ip"
|
|
|
|
Range = "Range"
|
|
|
|
Filter = "Filter"
|
|
|
|
)
|
|
|
|
|
|
|
|
//Move in leakybuckets
|
|
|
|
type ScopeType struct {
|
|
|
|
Scope string `yaml:"type"`
|
|
|
|
Filter string `yaml:"expression"`
|
|
|
|
RunTimeFilter *vm.Program
|
|
|
|
}
|
|
|
|
|
|
|
|
type RuntimeAlert struct {
|
|
|
|
Mapkey string `yaml:"MapKey,omitempty" json:"MapKey,omitempty"`
|
|
|
|
BucketId string `yaml:"BucketId,omitempty" json:"BucketId,omitempty"`
|
|
|
|
Whitelisted bool `yaml:"Whitelisted,omitempty" json:"Whitelisted,omitempty"`
|
|
|
|
Reprocess bool `yaml:"Reprocess,omitempty" json:"Reprocess,omitempty"`
|
|
|
|
Sources map[string]models.Source `yaml:"Sources,omitempty" json:"Sources,omitempty"`
|
|
|
|
Alert *models.Alert `yaml:"Alert,omitempty" json:"Alert,omitempty"` //this one is a pointer to APIAlerts[0] for convenience.
|
|
|
|
//APIAlerts will be populated at the end when there is more than one source
|
|
|
|
APIAlerts []models.Alert `yaml:"APIAlerts,omitempty" json:"APIAlerts,omitempty"`
|
2020-05-15 09:39:16 +00:00
|
|
|
}
|