-
Notifications
You must be signed in to change notification settings - Fork 343
Fix IllegalArgumentException when resolved indices are empty #5797
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
base: main
Are you sure you want to change the base?
Fix IllegalArgumentException when resolved indices are empty #5797
Conversation
|
That looks quite good to me, thank you! Just a few things:
|
4692a36 to
b9d0dec
Compare
96c8e4e to
91a7097
Compare
|
@nibix during the implementation of the integration test, I encountered another edge case: if there are no indices, and users do not have any indices priveleges for the action at all, such requests should be also forbidden. To check this edge case I've added - a new method You've also mentioned IndexAuthorizationReadOnlyIntTests.java to add a new ingegration test there. I've added new
wdyt? |
|
Thanks for the update! On Friday, I will be quite busy with other stuff, so I will only have time to take a closer look on Monday.
We need to take a closer look at this:
Of course, this is a discussable topic - at the moment, we are working on some fundamental behavior changes (see #3905, #5367 and #5399 ; I also need to write an updated RFC soon). Feel invited to discuss there. |
|
Sorry for the late reply, was just too busy :-( That looks generally very good to me! Yet, I think we need to briefly reflect on this:
If I see this correctly, this would have the following effect:
This is a kind of inconsistent behavior which we should avoid IMHO (even though it might be a case that seldomly happens in the real word). For now, I would propose not to do the At the moment, we are busy on revising the index authorization behavior, see #5814. We could use that chance and implement the behavior change in that go. Feel invited to have a look there and comment :) @cwperks wdyt? |
Signed-off-by: Maxim Muzafarov <[email protected]>
91a7097 to
1c46d7d
Compare
|
@nibix thanks for the comment! I agree with your suggestion. Let's keep the fix short and simple to avoid any problems with backwards compatibility, bearing in mind that the refactoring is still ongoing in other PRs. I've updated the PR to reflect our discussion and amended the description. Is there anything else I need to do to get this into the next security plugin release (2.19.4.0)? |
Description
This PR fixes an
IllegalArgumentExceptionthat occured when resolved indices are empty in thePrivilegesEvaluator. This issue occurs when all indices are closed (e.g., during cluster maintenance) and operations like_cat/recoveryare executed.Category
Bug fix
Why these changes are required?
When all indices in a cluster are closed, certain operations like
_cat/recoverycan still be valid and should be authorized. However, whengetAllIndicesResolved()returns an empty set, the code was attempting to create aCheckTablewith an empty collection, which throws anIllegalArgumentException.This prevents valid operations from being authorized when indices are closed.
What is the old behavior before changes and new behavior after changes?
Old behavior:
getAllIndicesResolved()returned an empty set, the code would attempt to create aCheckTablewith an empty collection and throw an exception.New behavior:
getAllIndicesResolved()returns an empty set allow operations to proceed_cat/recoverynow succeed when users have the appropriate permissions, even when all indices are closedIssues Resolved
Resolves #5794
Is this a backport?
No
Do these changes introduce new permission(s) to be displayed in the static dropdown on the front-end?
No
Testing
hasIndexPrivilegeEmptyResolvedIndices()IndexAuthorizationWithClosedIndicesIntTestsManual Testing
_cat/recoveryand similar operations work correctly when all indices are closedCheck List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.