From 2407128e22d88f6331286e9936cce60bb59f0809 Mon Sep 17 00:00:00 2001 From: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Date: Tue, 25 Apr 2023 09:28:32 -0400 Subject: [PATCH 1/6] Resolve ImmutableOpenMap issue from core refactor (#2715) --- .../security/privileges/PrivilegesEvaluator.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java index 5fbff60042..5f57633171 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -37,6 +38,7 @@ import java.util.StringJoiner; import java.util.regex.Pattern; +import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import org.apache.logging.log4j.LogManager; @@ -78,7 +80,6 @@ import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.Strings; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; @@ -677,6 +678,7 @@ public static boolean isClusterPerm(String action0) { ); } + @SuppressWarnings("unchecked") private boolean checkFilteredAliases(Resolved requestedResolved, String action, boolean isDebugEnabled) { final String faMode = dcm.getFilteredAliasMode();// getConfigSettings().dynamic.filtered_alias_mode; @@ -694,7 +696,7 @@ private boolean checkFilteredAliases(Resolved requestedResolved, String action, indexMetaDataCollection = new Iterable() { @Override public Iterator iterator() { - return clusterService.state().getMetadata().getIndices().valuesIt(); + return clusterService.state().getMetadata().getIndices().values().iterator(); } }; } else { @@ -719,15 +721,18 @@ public Iterator iterator() { final List filteredAliases = new ArrayList(); - final ImmutableOpenMap aliases = indexMetaData.getAliases(); + final Map aliases = new HashMap<>(); + for (ObjectObjectCursor cursor : indexMetaData.getAliases()) { + aliases.put(cursor.key, cursor.value); + } if (aliases != null && aliases.size() > 0) { if (isDebugEnabled) { log.debug("Aliases for {}: {}", indexMetaData.getIndex().getName(), aliases); } - final Iterator it = aliases.keysIt(); - while (it.hasNext()) { + final Iterator it = aliases.keySet().iterator(); + while(it.hasNext()) { final String alias = it.next(); final AliasMetadata aliasMetadata = aliases.get(alias); From 52f79f03b36d9975db7c5b87f5cccea4a74f7aa8 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 26 Apr 2023 17:45:15 -0400 Subject: [PATCH 2/6] Switch from ImmutableOpenMap to Map in AliasExistsMatcher (#2725) * Remove references to ObjectObjectCursor Signed-off-by: Craig Perkins --- .../security/privileges/PrivilegesEvaluator.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java index 5f57633171..57f6390e00 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -38,7 +37,6 @@ import java.util.StringJoiner; import java.util.regex.Pattern; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import org.apache.logging.log4j.LogManager; @@ -721,10 +719,7 @@ public Iterator iterator() { final List filteredAliases = new ArrayList(); - final Map aliases = new HashMap<>(); - for (ObjectObjectCursor cursor : indexMetaData.getAliases()) { - aliases.put(cursor.key, cursor.value); - } + final Map aliases = indexMetaData.getAliases(); if (aliases != null && aliases.size() > 0) { if (isDebugEnabled) { From 2fb50a4f6a7d20d9ef74d328561ddcea5b7f8162 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 26 Apr 2023 17:45:15 -0400 Subject: [PATCH 3/6] Switch from ImmutableOpenMap to Map in AliasExistsMatcher (#2725) * Remove references to ObjectObjectCursor Signed-off-by: Craig Perkins From 28fb0bd4bc34d4830819131de01dfd1e482ae962 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com> Date: Fri, 28 Apr 2023 11:48:32 -0400 Subject: [PATCH 4/6] Removes a missed reference for ImmutableOpenMap (#2726) Signed-off-by: Darshit Chanpura From 91f6792cf62b3a4548ffd41691823f86768a9fab Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 27 Jun 2023 10:09:49 -0400 Subject: [PATCH 5/6] Update ClusterInfoHolder Signed-off-by: Craig Perkins --- .../opensearch/security/configuration/ClusterInfoHolder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java index 4706817929..2cbc876434 100644 --- a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java +++ b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java @@ -112,7 +112,7 @@ private static boolean clusterHas6xNodes(ClusterState state) { } private static boolean clusterHas6xIndices(ClusterState state) { - final Iterator indices = state.metadata().indices().valuesIt(); + final Iterator indices = state.metadata().indices().values().iterator(); while (indices.hasNext()) { final IndexMetadata indexMetadata = indices.next(); if (indexMetadata.getCreationVersion().before(LegacyESVersion.V_7_0_0)) { From 4b7ff5026ee17ccc123540e7359c7b5768c069b4 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 27 Jun 2023 10:11:12 -0400 Subject: [PATCH 6/6] Run spotlessApply Signed-off-by: Craig Perkins --- .../org/opensearch/security/privileges/PrivilegesEvaluator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java index 57f6390e00..7383c6b4b6 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java @@ -727,7 +727,7 @@ public Iterator iterator() { } final Iterator it = aliases.keySet().iterator(); - while(it.hasNext()) { + while (it.hasNext()) { final String alias = it.next(); final AliasMetadata aliasMetadata = aliases.get(alias);