Skip to content

Commit ec81466

Browse files
Avoid redundant available indices check (#76540)
The resolved indices list contains name elements that either: - are concrete names that been explicitly mentioned in the original request, or - are authorized indices that are referred to by a date math expression from the request, or - are authorized indices that are covered by a wildcard from the request If the request option `ignoreUnavailable` is set to true the resolved indices list overall must silently ignore the names that are not in the authorized set. Consequently, only the names in the first category mentioned above must be verified; the check for the other names is redundant.
1 parent 0318758 commit ec81466

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public List<String> resolveIndexAbstractions(Iterable<String> indices, IndicesOp
103103
} else if (dateMathName.equals(indexAbstraction)) {
104104
if (minus) {
105105
finalIndices.remove(indexAbstraction);
106-
} else {
106+
} else if (indicesOptions.ignoreUnavailable() == false || availableIndexAbstractions.contains(indexAbstraction)) {
107107
finalIndices.add(indexAbstraction);
108108
}
109109
}

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ ResolvedIndices resolveIndicesAndAliases(String action, IndicesRequest indicesRe
229229
}
230230
List<String> replaced = indexAbstractionResolver.resolveIndexAbstractions(split.getLocal(), indicesOptions, metadata,
231231
authorizedIndices, replaceWildcards, indicesRequest.includeDataStreams());
232-
if (indicesOptions.ignoreUnavailable()) {
233-
//out of all the explicit names (expanded from wildcards and original ones that were left untouched)
234-
//remove all the ones that the current user is not authorized for and ignore them
235-
replaced = replaced.stream().filter(authorizedIndices::contains).collect(Collectors.toList());
236-
}
237232
resolvedIndicesBuilder.addLocal(replaced);
238233
resolvedIndicesBuilder.addRemote(split.getRemote());
239234
}

0 commit comments

Comments
 (0)