-
Notifications
You must be signed in to change notification settings - Fork 25k
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
[DOCS] EQL: Document cidrMatch
function
#54216
Conversation
Pinging @elastic/es-docs (>docs) |
Pinging @elastic/es-search (:Search/EQL) |
@elastic/es-ql |
// 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 |
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.
@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
]
}
]
}
}
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.
I created #55709 to track this bug.
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.
For what is worth, this LGTM.
I've created #55709, though, to track the issue brought up in one of your comments.
Thanks for tracking that bug @astefan. |
Adds documentation for the EQL
cidrMatch
function.Depends on #54186