-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Libbeat] Fix array matching in contains condition #11691
Conversation
Matching arrays of strings inside a `contains` condition doesn't work properly as it is expecting fields of type `[]string` when they are in fact `[]interface{}`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix #3138?
libbeat/conditions/matcher.go
Outdated
@@ -86,7 +86,7 @@ func (c Matcher) Check(event ValuesMap) bool { | |||
return false | |||
} | |||
|
|||
case []string: | |||
case []interface{}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What events were you seeing where it had []interface{}
rather than []string
? I assume this code would need to handle both data types. My guess is that []interface{}
is found in data parsed by Filebeat and that []string
is found in events that are natively generated in a Beat (such as a list of tags
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're completely right. Thanks. I got confused with maps from decoders where arrays are always of type []interface{}.
@andrewkroh yes, this is the issue reported in #3138 |
Matching arrays of strings inside a
contains
condition doesn't work properly with the output of JSON decoding as it is expecting fields of type[]string
when they are in this case[]interface{}
.It outputs the following error:
2019-04-08T12:10:31.866+0200 WARN [conditions] conditions/matcher.go:97 unexpected type []interface {} in contains condition as it accepts only strings.
Fixes: #3138