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

Support bare IP in ip_range fields #40179

Closed
ZLightning opened this issue Mar 18, 2019 · 9 comments
Closed

Support bare IP in ip_range fields #40179

ZLightning opened this issue Mar 18, 2019 · 9 comments
Labels
discuss >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@ZLightning
Copy link

Describe the feature:

The ip_range should have a default mask to accept bare IP addresses that are appropriate for the type (/32 for IPv4 and /128 for IPv6) rather than rejecting the input. Using the example of an ip whitelist (as shown in the docs)

{
  "ip_whitelist" : "192.168.0.1"
}

should be equally as valid as

{
  "ip_whitelist" : "192.168.0.1/32"
}

They both represent a range starting and ending on a single IPv4 address, and it makes sense to support both formats since a large portion of whitelists/blocklists support both IP and CIDR notation in one file. Presently, an exception is thrown for the bare IP "Expected [ip/prefix] but was [192.168.0.1]".

@jtibshirani jtibshirani added the :Search Foundations/Mapping Index mappings, including merging and defining field types label Mar 19, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@jakelandis
Copy link
Contributor

Related: #38064

@pcsanwald
Copy link
Contributor

We discussed this briefly on our FixIt call, and we don't see any downsides to making this change, assuming the IP spec allows single values for ranges (i.e. the / is not required).

CC @jtibshirani for visibility and also @not-napoleon who has been working in this space lately (aggs for range fields)

@pcsanwald pcsanwald removed the discuss label May 23, 2019
@rjernst
Copy link
Member

rjernst commented May 23, 2019

I don't think the spec allows for the suffix to be optional. As noted in the original description, many whitelist implementations (including our own within security) allow direct IPs as well as CIDR ranges. One thing to note, though, is that in those cases a single range of ips is not being defined, but a list of allowed whitelists. My main concern would be a user accidentally leaving off the suffix, unknowingly only indexing a single ip within a range instead of an intended range. Perhaps an alternative would be to support a single value key within an object for a range field, as a shortcut for specifying both ends of the range.

@ZLightning
Copy link
Author

My main concern would be a user accidentally leaving off the suffix, unknowingly only indexing a single ip within a range instead of an intended range.

I'll admit there is a risk that users might accidentally leave off the block size in a range, but does that mean it should be required to put a + in front of a positive number so you can be sure that the person didn't leave off a - on a negative number?

The bigger threat I see is that someone intends to index a single IP and leaves off the /32 (or /128 for IPv6) and then ignores/misses the error, perhaps in a bulk indexing request. In this case, the data is lost entirely, whereas with an accidental listing of a single IP where a range was intended, the listing for the single IP would still be better than not listing anything. Note, I am not suggesting that ignoring errors is a good idea, but rather that data preservation should take precedence over forcing extra verbosity to prevent users from making mistakes.

@jtibshirani
Copy link
Contributor

I'm going to mark this for discussion again so that @rjernst has the chance to weigh in. The main question seems to be whether we want to favor flexibility by default, and risk users accidentally indexing single IPs into the range field.

@eskibars
Copy link
Contributor

eskibars commented Jun 1, 2019

I personally think this type of mistake is a very low risk as long as we aren't doing very lenient parsing.

@rjernst
Copy link
Member

rjernst commented Jun 6, 2019

After a followup fix-it-day discussion, we have decided against this proposal. In addition to the already existing ability to pass a single value by using /32 or by specifying both gte and lte (as works for any range field type), the possibility to muddy the user intention is too great. For example, if we were to start accepting these values without the suffix, one might suggest masks should be implicit based on significant bits, eg interpreting 192.168.0.0 as 192.168.0.0/16. Saving a few characters input is not worth the confusion in interpretation.

@rjernst rjernst closed this as completed Jun 6, 2019
@javanna javanna added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

8 participants