Skip to content

Commit 657b075

Browse files
committed
Minor tweaks
1 parent 40b4211 commit 657b075

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
package org.elasticsearch.xpack.core.security.authz.permission;
88

9+
import org.apache.logging.log4j.LogManager;
10+
import org.apache.logging.log4j.Logger;
911
import org.apache.lucene.util.automaton.Automaton;
1012
import org.apache.lucene.util.automaton.Operations;
1113
import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
@@ -57,6 +59,8 @@
5759
*/
5860
public final class IndicesPermission {
5961

62+
private final Logger logger = LogManager.getLogger(getClass());
63+
6064
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(IndicesPermission.class);
6165

6266
public static final IndicesPermission NONE = new IndicesPermission(new RestrictedIndices(Automatons.EMPTY), Group.EMPTY_ARRAY);
@@ -343,6 +347,7 @@ public boolean checkResourcePrivileges(
343347
return automaton;
344348
} catch (TooComplexToDeterminizeException e) {
345349
final String text = pattern.length() > 260 ? Strings.cleanTruncate(pattern, 256) + "..." : pattern;
350+
logger.info("refusing to check privileges against complex index pattern [{}]", text);
346351
throw new IllegalArgumentException("the provided index pattern [" + text + "] is too complex to be evaluated", e);
347352
}
348353
}));

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,19 +1101,11 @@ public void testCheckResourcePrivilegesWithTooComplexAutomaton() {
11011101
"my-index"
11021102
).build();
11031103

1104-
StringBuilder pattern = new StringBuilder("/");
1105-
for (int i = 0; i < 2048; i++) {
1106-
if (i > 0) {
1107-
pattern.append("|");
1108-
}
1109-
pattern.append(randomAlphaOfLength(64));
1110-
}
1111-
pattern.append("/");
11121104
var ex = expectThrows(
11131105
IllegalArgumentException.class,
1114-
() -> permission.checkResourcePrivileges(Set.of(pattern.toString()), false, Set.of("read"), null)
1106+
() -> permission.checkResourcePrivileges(Set.of("****a*b?c**d**e*f??*g**h???i??*j*k*l*m*n???o*"), false, Set.of("read"), null)
11151107
);
1116-
assertThat(ex.getMessage(), containsString("index pattern [/"));
1108+
assertThat(ex.getMessage(), containsString("index pattern [****a*b?c**d**e*f??*g**h???i??*j*k*l*m*n???o*]"));
11171109
assertThat(ex.getCause(), instanceOf(TooComplexToDeterminizeException.class));
11181110
}
11191111

0 commit comments

Comments
 (0)