Skip to content

Commit 2ccbcdf

Browse files
committed
More fixes
1 parent 0b09483 commit 2ccbcdf

File tree

6 files changed

+9
-5
lines changed

6 files changed

+9
-5
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
@@ -79,7 +79,7 @@ public static IndexComponentSelector getByKeyOrThrow(@Nullable String key) {
7979
IndexComponentSelector selector = getByKey(key);
8080
if (selector == null) {
8181
throw new IllegalArgumentException(
82-
"Unknown key of index component selector [" + key + "], available options are: " + KEY_REGISTRY
82+
"Unknown key of index component selector [" + key + "], available options are: " + KEY_REGISTRY.keySet()
8383
);
8484
}
8585
return selector;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public List<String> resolveIndexAbstractions(
6363
+ "]"
6464
);
6565
}
66-
IndexComponentSelector selector = IndexComponentSelector.getByKeyOrThrow(selectorString);
6766
indexAbstraction = expressionAndSelector.v1();
67+
IndexComponentSelector selector = IndexComponentSelector.getByKeyOrThrow(selectorString);
6868

6969
// we always need to check for date math expressions
7070
indexAbstraction = IndexNameExpressionResolver.resolveDateMathExpression(indexAbstraction);

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/IndicesAccessControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected IndicesAccessControl(IndicesAccessControl copy) {
5757
}
5858

5959
/**
60-
* @return The document and field permissions for an index if exist, otherwise <code>null</code> is returned.
60+
* @return The document and field permissions for an index if they exist, otherwise <code>null</code> is returned.
6161
* If <code>null</code> is being returned this means that there are no field or document level restrictions.
6262
*/
6363
@Nullable

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ public boolean isPartOfDataStream() {
451451
public boolean checkIndex(Group group) {
452452
final DataStream ds = indexAbstraction == null ? null : indexAbstraction.getParentDataStream();
453453
if (ds != null) {
454+
// failure indices are special: when accessed directly (not through ::failures on parent data stream) they are accessed
455+
// implicitly as data. However, authz to the parent data stream happens via the failures selector
454456
final IndexComponentSelector selectorToCheck = indexAbstraction.isFailureIndexOfDataStream()
455457
? IndexComponentSelector.FAILURES
456458
: selector;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,7 @@ public Function<String, FieldPredicate> getFieldFilter() {
22112211
return FieldPredicate.ACCEPT_ALL;
22122212
}
22132213
assert indicesAccessControl.isGranted();
2214+
IndexNameExpressionResolver.assertExpressionHasDefaultOrDataSelector(index);
22142215
IndicesAccessControl.IndexAccessControl indexPermissions = indicesAccessControl.getIndexPermissions(index);
22152216
if (indexPermissions == null) {
22162217
return FieldPredicate.ACCEPT_ALL;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ static AuthorizedIndices resolveAuthorizedIndicesFromRole(
885885
if (includeDataStreams) {
886886
for (IndexAbstraction indexAbstraction : lookup.values()) {
887887
// failure indices are special: when accessed directly (not through ::failures on parent data stream) they are accessed
888-
// as implicitly as data. However, authz to the parent data stream happens via the failures selector
888+
// implicitly as data. However, authz to the parent data stream happens via the failures selector
889889
if (indexAbstraction.isFailureIndexOfDataStream()
890890
&& predicate.test(indexAbstraction.getParentDataStream(), IndexComponentSelector.FAILURES)) {
891891
indicesAndAliases.add(indexAbstraction.getName());
@@ -1072,7 +1072,6 @@ private static boolean isAsyncRelatedAction(String action) {
10721072
}
10731073

10741074
static final class AuthorizedIndices implements AuthorizationEngine.AuthorizedIndices {
1075-
10761075
private final CachedSupplier<Set<String>> authorizedAndAvailableSupplier;
10771076
private final CachedSupplier<Set<String>> failureStoreAuthorizedAndAvailableSupplier;
10781077
private final BiPredicate<String, IndexComponentSelector> isAuthorizedPredicate;
@@ -1089,13 +1088,15 @@ static final class AuthorizedIndices implements AuthorizationEngine.AuthorizedIn
10891088

10901089
@Override
10911090
public Set<String> all(IndexComponentSelector selector) {
1091+
Objects.requireNonNull(selector);
10921092
return IndexComponentSelector.FAILURES.equals(selector)
10931093
? failureStoreAuthorizedAndAvailableSupplier.get()
10941094
: authorizedAndAvailableSupplier.get();
10951095
}
10961096

10971097
@Override
10981098
public boolean check(String name, IndexComponentSelector selector) {
1099+
Objects.requireNonNull(selector);
10991100
return isAuthorizedPredicate.test(name, selector);
11001101
}
11011102
}

0 commit comments

Comments
 (0)