Skip to content

Commit 2408bac

Browse files
committed
Fixing details
1 parent 9141e64 commit 2408bac

File tree

5 files changed

+10
-40
lines changed

5 files changed

+10
-40
lines changed

server/src/main/java/org/elasticsearch/action/support/IndexComponentSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static IndexComponentSelector read(StreamInput in) throws IOException {
7777
if (in.getTransportVersion().onOrAfter(TransportVersions.REMOVE_ALL_APPLICABLE_SELECTOR)) {
7878
return getById(id);
7979
} else {
80-
// Legacy value ::*
80+
// Legacy value ::*, converted to ::data
8181
return id == 2 ? DATA : getById(id);
8282
}
8383
}

server/src/main/java/org/elasticsearch/cluster/metadata/IndexAbstractionResolver.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ && isIndexVisible(
8181
indexNameExpressionResolver,
8282
includeDataStreams
8383
)) {
84-
// Resolve any ::* suffixes on the expression. We need to resolve them all to their final valid selectors
85-
resolveSelectorsAndCombine(authorizedIndex, selectorString, indicesOptions, resolvedIndices, metadata);
84+
resolveSelectorsAndCollect(authorizedIndex, selectorString, indicesOptions, resolvedIndices, metadata);
8685
}
8786
}
8887
if (resolvedIndices.isEmpty()) {
@@ -98,9 +97,8 @@ && isIndexVisible(
9897
}
9998
}
10099
} else {
101-
// Resolve any ::* suffixes on the expression. We need to resolve them all to their final valid selectors
102100
Set<String> resolvedIndices = new HashSet<>();
103-
resolveSelectorsAndCombine(indexAbstraction, selectorString, indicesOptions, resolvedIndices, metadata);
101+
resolveSelectorsAndCollect(indexAbstraction, selectorString, indicesOptions, resolvedIndices, metadata);
104102
if (minus) {
105103
finalIndices.removeAll(resolvedIndices);
106104
} else if (indicesOptions.ignoreUnavailable() == false || isAuthorized.test(indexAbstraction)) {
@@ -114,7 +112,7 @@ && isIndexVisible(
114112
return finalIndices;
115113
}
116114

117-
private static void resolveSelectorsAndCombine(
115+
private static void resolveSelectorsAndCollect(
118116
String indexAbstraction,
119117
String selectorString,
120118
IndicesOptions indicesOptions,
@@ -132,19 +130,8 @@ private static void resolveSelectorsAndCombine(
132130
selectorString = IndexComponentSelector.DATA.getKey();
133131
}
134132

135-
if (Regex.isMatchAllPattern(selectorString)) {
136-
// Always accept data
137-
collect.add(IndexNameExpressionResolver.combineSelectorExpression(indexAbstraction, IndexComponentSelector.DATA.getKey()));
138-
// Only put failures on the expression if the abstraction supports it.
139-
if (acceptsAllSelectors) {
140-
collect.add(
141-
IndexNameExpressionResolver.combineSelectorExpression(indexAbstraction, IndexComponentSelector.FAILURES.getKey())
142-
);
143-
}
144-
} else {
145-
// A non-wildcard selector is always passed along as-is, it's validity for this kind of abstraction is tested later
146-
collect.add(IndexNameExpressionResolver.combineSelectorExpression(indexAbstraction, selectorString));
147-
}
133+
// A selector is always passed along as-is, it's validity for this kind of abstraction is tested later
134+
collect.add(IndexNameExpressionResolver.combineSelectorExpression(indexAbstraction, selectorString));
148135
} else {
149136
assert selectorString == null
150137
: "A selector string [" + selectorString + "] is present but selectors are disabled in this context";

server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,8 +1329,7 @@ private static boolean ensureAliasOrIndexExists(Context context, String name, In
13291329
if (context.options.allowSelectors()) {
13301330
// Ensure that the selectors are present and that they are compatible with the abstractions they are used with
13311331
assert selector != null : "Earlier logic should have parsed selectors or added the default selectors already";
1332-
// Check if ::failures has been explicitly requested, since requesting ::* for non-data-stream abstractions would just
1333-
// return their data components.
1332+
// Check if ::failures has been explicitly requested
13341333
if (IndexComponentSelector.FAILURES.equals(selector) && indexAbstraction.isDataStreamRelated() == false) {
13351334
// If requested abstraction is not data stream related, then you cannot use ::failures
13361335
if (ignoreUnavailable) {

server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ protected Map<String, List<String>> groupClusterIndices(Set<String> remoteCluste
157157
if (indexName.equals("*") == false) {
158158
throw new IllegalArgumentException(
159159
Strings.format(
160-
"To exclude a cluster you must specify the '*' wildcard for " + "the index expression, but found: [%s]",
160+
"To exclude a cluster you must specify the '*' wildcard for the index expression, but found: [%s]",
161161
indexName
162162
)
163163
);
164164
}
165-
if (selectorString != null && selectorString.equals("*") == false) {
165+
if (selectorString != null) {
166166
throw new IllegalArgumentException(
167167
Strings.format(
168-
"To exclude a cluster you must specify the '::*' selector or leave it off, but found: [%s]",
168+
"To exclude a cluster you must not specify the a selector, but found selector: [%s]",
169169
selectorString
170170
)
171171
);

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -465,22 +465,6 @@ public void testSelectorsDoNotImpactWildcardDetection() {
465465
);
466466
}
467467

468-
public void testWildcardSelectorsAreNotAllowedInShardLevelRequests() {
469-
ShardSearchRequest request = mock(ShardSearchRequest.class);
470-
when(request.indices()).thenReturn(new String[] { "index10::*" });
471-
IllegalArgumentException exception = expectThrows(
472-
IllegalArgumentException.class,
473-
() -> defaultIndicesResolver.resolveIndicesAndAliasesWithoutWildcards(TransportSearchAction.TYPE.name() + "[s]", request)
474-
);
475-
assertThat(
476-
exception,
477-
throwableWithMessage(
478-
"the action indices:data/read/search[s] does not support wildcard selectors;"
479-
+ " the provided index expression(s) [index10::*] are not allowed"
480-
)
481-
);
482-
}
483-
484468
public void testAllIsNotAllowedInShardLevelRequests() {
485469
ShardSearchRequest request = mock(ShardSearchRequest.class);
486470
final boolean literalAll = randomBoolean();

0 commit comments

Comments
 (0)