File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 2626import org .elasticsearch .common .regex .Regex ;
2727import org .elasticsearch .common .settings .ClusterSettings ;
2828import org .elasticsearch .common .settings .Settings ;
29+ import org .elasticsearch .core .Assertions ;
2930import org .elasticsearch .core .Nullable ;
3031import org .elasticsearch .core .Tuple ;
3132import org .elasticsearch .index .Index ;
@@ -509,6 +510,7 @@ private static List<String> replaceWildcardsWithAuthorizedAliases(String[] alias
509510 }
510511
511512 for (String aliasExpression : aliases ) {
513+ assertOnlyDataSelector (aliasExpression );
512514 boolean include = true ;
513515 if (aliasExpression .charAt (0 ) == '-' ) {
514516 include = false ;
@@ -536,6 +538,14 @@ private static List<String> replaceWildcardsWithAuthorizedAliases(String[] alias
536538 return finalAliases ;
537539 }
538540
541+ private static void assertOnlyDataSelector (String expression ) {
542+ if (Assertions .ENABLED ) {
543+ Tuple <String , String > tuple = IndexNameExpressionResolver .splitSelectorExpression (expression );
544+ assert tuple .v2 () == null || IndexComponentSelector .getByKey (tuple .v2 ()) == IndexComponentSelector .DATA
545+ : "Selector [" + tuple .v2 () + "] is not allowed in expression [" + expression + "]" ;
546+ }
547+ }
548+
539549 private static List <String > indicesList (String [] list ) {
540550 return (list == null ) ? null : Arrays .asList (list );
541551 }
You can’t perform that action at this time.
0 commit comments