Skip to content
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

Merged
merged 4 commits into from
Apr 24, 2020
Merged

[DOCS] EQL: Document cidrMatch function #54216

merged 4 commits into from
Apr 24, 2020

Conversation

jrodewig
Copy link
Contributor

Adds documentation for the EQL cidrMatch function.

Depends on #54186

@jrodewig jrodewig added >docs General docs changes :Analytics/EQL EQL querying labels Mar 25, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs (>docs)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/EQL)

@matriv
Copy link
Contributor

matriv commented Mar 30, 2020

@elastic/es-ql

@jrodewig jrodewig marked this pull request as ready for review April 8, 2020 16:24
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
Copy link
Contributor Author

@jrodewig jrodewig Apr 8, 2020

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
        ]
      }
    ]
  }
}

Copy link
Contributor

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.

Copy link
Contributor

@astefan astefan left a 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.

@jrodewig
Copy link
Contributor Author

Thanks for tracking that bug @astefan.

@jrodewig jrodewig merged commit d222404 into elastic:master Apr 24, 2020
@jrodewig jrodewig deleted the docs__eql-cidrmatch-fn branch April 24, 2020 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/EQL EQL querying >docs General docs changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants