Allow the "*,-*" ("no-index") pattern for destructive actions when destructive_requires_name is true#68021
Merged
williamrandolph merged 8 commits intoelastic:masterfrom Jan 28, 2021
Conversation
Since the "*,-*" pattern resolves to "no indices", it makes a normally destructive action into a non-destructive one. Rather than throwing a wildcards-not-allowed exception, we can allow this pattern to pass without triggering an exception. This allows the security layer to safely use a "*,-*" pattern to indicate a "no indices" result for its index resolution step, which is important because otherwise we get wildcards-not-allowed exceptions when trying to delete nonexistent concrete indices.
Collaborator
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Contributor
Author
|
Todo:
|
Contributor
Author
|
I created #68079 for the test failure. |
Contributor
Author
|
@elasticmachine run elasticsearch-ci/2 |
1 similar comment
Contributor
Author
|
@elasticmachine run elasticsearch-ci/2 |
jaymode
approved these changes
Jan 28, 2021
| if (hasWildcardUsage(aliasesOrIndices[0])) { | ||
| throw new IllegalArgumentException("Wildcard expressions or all indices are not allowed"); | ||
| } | ||
| } else if (Arrays.equals(aliasesOrIndices, new String[]{"*", "-*"})) { |
Member
There was a problem hiding this comment.
Can you make the String[] a static final variable?
Member
There was a problem hiding this comment.
Also you could simplify the code and remove the else below by making the check Arrays.equals() == false. Either way is fine
williamrandolph
added a commit
that referenced
this pull request
Jan 28, 2021
…destructive_requires_name is true (#68021) Since the "*,-*" pattern resolves to "no indices", it makes a normally destructive action into a non-destructive one. Rather than throwing a wildcards-not-allowed exception, we can allow this pattern to pass without triggering an exception. This allows the security layer to safely use a "*,-*" pattern to indicate a "no indices" result for its index resolution step, which is important because otherwise we get wildcards-not-allowed exceptions when trying to delete nonexistent concrete indices. For simplicity, we require exactly "*,-*", rather than any other wildcards that might be logically equivalent.
Contributor
Author
|
Backport commit for 7.x: ddda5f2 |
34 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Since the
*,-*index name pattern resolves to "no indices", it makes a normally destructive action into a non-destructive one. Rather than throwing a wildcards-not-allowed exception, we can allow this pattern to pass without triggering an exception. This allows the security layer to safely use a*,-*pattern to indicate a "no indices" result for its index resolution step, which is important because otherwise we get wildcards-not-allowed exceptions when trying to delete nonexistent concrete indices, e.g.:This is a fix for #67958.
I don't have the domain knowledge to know if there is a better way to avoid this issue by changing the security layer, but, if so, it would be fine by me to decline this PR in favor of that approach.