-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Allow the "*,-*" ("no-index") pattern for destructive actions when destructive_requires_name is true #68021
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
Allow the "*,-*" ("no-index") pattern for destructive actions when destructive_requires_name is true #68021
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.
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Todo:
|
I created #68079 for the test failure. |
@elasticmachine run elasticsearch-ci/2 |
1 similar comment
@elasticmachine run elasticsearch-ci/2 |
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.
LGTM
@@ -59,6 +61,9 @@ public void failDestructive(String[] aliasesOrIndices) { | |||
if (hasWildcardUsage(aliasesOrIndices[0])) { | |||
throw new IllegalArgumentException("Wildcard expressions or all indices are not allowed"); | |||
} | |||
} else if (Arrays.equals(aliasesOrIndices, new String[]{"*", "-*"})) { |
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.
Can you make the String[] a static final variable?
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.
Also you could simplify the code and remove the else below by making the check Arrays.equals() == false. Either way is fine
…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.
Backport commit for 7.x: ddda5f2 |
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.