[DOCS] EQL: Document cidrMatch function#54216
Merged
jrodewig merged 4 commits intoelastic:masterfrom Apr 24, 2020
jrodewig:docs__eql-cidrmatch-fn
Merged
[DOCS] EQL: Document cidrMatch function#54216jrodewig merged 4 commits intoelastic:masterfrom jrodewig:docs__eql-cidrmatch-fn
cidrMatch function#54216jrodewig merged 4 commits intoelastic:masterfrom
jrodewig:docs__eql-cidrmatch-fn
Conversation
Collaborator
|
Pinging @elastic/es-docs (>docs) |
Collaborator
|
Pinging @elastic/es-search (:Search/EQL) |
Contributor
|
@elastic/es-ql |
jrodewig
commented
Apr 8, 2020
Comment on lines
+30
to
+34
| // source.address = "192.168.152.12" | ||
| cidrMatch(source.address, "192.168.0.0/16") // returns true | ||
| cidrMatch(source.address, "192.168.0.0/16", "10.0.0.0/8") // returns true | ||
| cidrMatch(source.address, "10.0.0.0/8") // returns false | ||
| cidrMatch(source.address, "10.0.0.0/8", "10.128.0.0/9") // returns false |
Contributor
Author
There was a problem hiding this comment.
@aleksmaus When I tested this using the EQL search API, it didn't return results as expected. I included duplication steps below in case I made an error somewhere.
Create an index mapping to ensure source.address is an IP field.
PUT /my_index
{
"mappings": {
"properties": {
"source": {
"properties": {
"address": {
"type": "ip"
}
}
}
}
}
}
Index "192.168.152.12" as a source.address value.
PUT /my_index/_doc/1
{
"@timestamp": "2020-12-06T11:04:05.000Z",
"event": {
"category": "process"
},
"source": {
"address": "192.168.152.12"
}
}
Use cidrMatch to search for "192.168.152.12" in the "192.168.0.0/16" CIDR block. This should be true and return _doc 1 as a result.
{
GET /my_index/_eql/search
"query": "process where cidrMatch(source.address, \"192.168.0.0/16\") == true "
}
Instead, I get no results.
{
"took" : 2,
"timed_out" : false,
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"events" : [ ]
}
}
If I change true to false, the _doc is returned.
{
GET /my_index/_eql/search
"query": "process where cidrMatch(source.address, \"192.168.0.0/16\") == false "
}
Results:
{
"took" : 2,
"timed_out" : false,
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"events" : [
{
"_index" : "my_index",
"_id" : "1",
"_score" : null,
"_source" : {
"@timestamp" : "2020-12-06T11:04:05.000Z",
"event" : {
"category" : "process"
},
"source" : {
"address" : "192.168.152.12"
}
},
"sort" : [
1607252645000
]
}
]
}
}
35 tasks
Contributor
Author
|
Thanks for tracking that bug @astefan. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds documentation for the EQL
cidrMatchfunction.Depends on #54186