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.
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
Add support for CIDR ranges in ignore_hosts setting. #5099
base: main
Are you sure you want to change the base?
Add support for CIDR ranges in ignore_hosts setting. #5099
Changes from 4 commits
9b598de
6603a89
8aca1e6
6efe00b
ac5cd05
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 169 in src/main/java/org/opensearch/security/support/SecurityUtils.java
src/main/java/org/opensearch/security/support/SecurityUtils.java#L167-L169
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.
Nit: As this method only works for
AuthFailureListener
instances, it should be probably an instance method ofAuthFailureListener
.Alternatively: Have you considered to create a new class that encapsulates a combination of
WildcardMatcher
and CIDR matching?This combination of matching is something what is not only useful for the
ignore_hosts
setting, but for quite a few functionalities. Having a reusable component for that would be nice.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 do not think that using
/
is sufficient for identifying CIDRs. Theignore_hosts
property supports the whole wildcard matcher feature set which also supports specifying regexes using the/regex/
syntax. This would also hit on these regexes.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.
good catch. one of the options is to implement regex check for ipv4/ipv6 addresses to identify CIDRs specifically - will check other options and update the PR
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 can also keep it simple and get the last index of
/
as long as/
is not the final char in the stringThere 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.
If I see it correctly,
SubnetUtils
andSubnetInfo
only support IPv4. IfhostAddress
is in IPv6 format, it will throw anIllegalArgumentException
:https://github.com/apache/commons-net/blob/aeaa37e9753ce9920c91d22493e074781ef69ff3/src/main/java/org/apache/commons/net/util/SubnetUtils.java#L395C19-L395C43
I guess, we also need to support IPv6?
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.
sure, will add support for ipv6.
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.
Just as a recommendation: I have used in other projects this library:
https://seancfoley.github.io/IPAddress/
It supports both IPv4 and IPv6, is super flexible and has a clean API.