mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-12 12:55:53 +02:00
Fix 1737 (#1738)
* add GetMeta to *types.Event Co-authored-by: sabban <15465465+sabban@users.noreply.github.com>
This commit is contained in:
parent
9d199fd4a9
commit
b2130b1593
2 changed files with 28 additions and 0 deletions
|
@ -41,6 +41,15 @@ func (e *Event) GetMeta(key string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Alert) GetMeta(key string) string {
|
||||||
|
for _, meta := range a.Meta {
|
||||||
|
if meta.Key == key {
|
||||||
|
return meta.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (s Source) GetValue() string {
|
func (s Source) GetValue() string {
|
||||||
if s.Value == nil {
|
if s.Value == nil {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -52,6 +52,25 @@ func (e *Event) GetType() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Event) GetMeta(key string) string {
|
||||||
|
if e.Type == OVFLW {
|
||||||
|
for _, alert := range e.Overflow.APIAlerts {
|
||||||
|
for _, event := range alert.Events {
|
||||||
|
if event.GetMeta(key) != "" {
|
||||||
|
return event.GetMeta(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if e.Type == LOG {
|
||||||
|
for k, v := range e.Meta {
|
||||||
|
if k == key {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
//Move in leakybuckets
|
//Move in leakybuckets
|
||||||
const (
|
const (
|
||||||
Undefined = ""
|
Undefined = ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue