From 4d6b2c7ac60471e8eeda129980d9b6771026fc83 Mon Sep 17 00:00:00 2001 From: Ashish Agrawal Date: Tue, 21 Feb 2023 10:41:19 -0800 Subject: [PATCH 1/3] bump to 2.6 Signed-off-by: Ashish Agrawal --- build.gradle | 2 +- .../transport/TransportDeleteDetectorAction.java | 2 +- .../transport/TransportIndexDetectorAction.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 48984a3f9..490e8af29 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ import org.opensearch.gradle.test.RestIntegTestTask buildscript { ext { - opensearch_version = System.getProperty("opensearch.version", "2.5.0-SNAPSHOT") + opensearch_version = System.getProperty("opensearch.version", "2.6.0-SNAPSHOT") isSnapshot = "true" == System.getProperty("build.snapshot", "true") buildVersionQualifier = System.getProperty("build.version_qualifier", "") version_tokens = opensearch_version.tokenize('-') diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteDetectorAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteDetectorAction.java index 1bcfa635c..7691e2f48 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteDetectorAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteDetectorAction.java @@ -6,7 +6,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.lucene.util.SetOnce; +import org.opensearch.common.SetOnce; import org.opensearch.OpenSearchStatusException; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRunnable; diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java index d7b7ae879..f2a43ac50 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java @@ -8,7 +8,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.search.join.ScoreMode; -import org.apache.lucene.util.SetOnce; +import org.opensearch.common.SetOnce; import org.opensearch.OpenSearchStatusException; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRunnable; From 82f9ad9b8c70d0a5f15b085311e940fd7618c7e9 Mon Sep 17 00:00:00 2001 From: Ashish Agrawal Date: Tue, 21 Feb 2023 11:20:20 -0800 Subject: [PATCH 2/3] fix compile issues Signed-off-by: Ashish Agrawal --- .../action/GetIndexMappingsResponse.java | 13 +++++++- .../action/GetMappingsViewResponse.java | 31 ++++++++++--------- .../action/ValidateRulesResponse.java | 24 +++++++++----- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/opensearch/securityanalytics/action/GetIndexMappingsResponse.java b/src/main/java/org/opensearch/securityanalytics/action/GetIndexMappingsResponse.java index 59512d793..f4dc1dab0 100644 --- a/src/main/java/org/opensearch/securityanalytics/action/GetIndexMappingsResponse.java +++ b/src/main/java/org/opensearch/securityanalytics/action/GetIndexMappingsResponse.java @@ -5,6 +5,8 @@ package org.opensearch.securityanalytics.action; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opensearch.Version; import org.opensearch.action.ActionResponse; import org.opensearch.cluster.metadata.MappingMetadata; @@ -13,14 +15,18 @@ import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.common.xcontent.ToXContent; import org.opensearch.common.xcontent.ToXContentObject; import org.opensearch.common.xcontent.XContentBuilder; +import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.index.mapper.MapperService; import java.io.IOException; public class GetIndexMappingsResponse extends ActionResponse implements ToXContentObject { + private Logger logger = LogManager.getLogger(GetIndexMappingsResponse.class); + private static final ParseField MAPPINGS = new ParseField("mappings"); private final ImmutableOpenMap mappings; @@ -99,7 +105,12 @@ public ImmutableOpenMap getMappings() { @Override public String toString() { - return Strings.toString(this); + try { + return Strings.toString(this.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)); + } catch (IOException e) { + logger.error(e.getMessage()); + return ""; + } } @Override diff --git a/src/main/java/org/opensearch/securityanalytics/action/GetMappingsViewResponse.java b/src/main/java/org/opensearch/securityanalytics/action/GetMappingsViewResponse.java index 8502cba05..01c178ea7 100644 --- a/src/main/java/org/opensearch/securityanalytics/action/GetMappingsViewResponse.java +++ b/src/main/java/org/opensearch/securityanalytics/action/GetMappingsViewResponse.java @@ -4,30 +4,28 @@ */ package org.opensearch.securityanalytics.action; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import org.opensearch.Version; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opensearch.action.ActionResponse; -import org.opensearch.cluster.metadata.MappingMetadata; -import org.opensearch.common.ParseField; import org.opensearch.common.Strings; -import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.ImmutableOpenMap; -import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.common.xcontent.ToXContent; import org.opensearch.common.xcontent.ToXContentObject; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.index.mapper.MapperService; import org.opensearch.securityanalytics.mapper.MapperUtils; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + public class GetMappingsViewResponse extends ActionResponse implements ToXContentObject { + private Logger logger = LogManager.getLogger(GetMappingsViewResponse.class); + public static final String UNMAPPED_INDEX_FIELDS = "unmapped_index_fields"; public static final String UNMAPPED_FIELD_ALIASES = "unmapped_field_aliases"; @@ -133,7 +131,12 @@ public List getUnmappedIndexFields() { @Override public String toString() { - return Strings.toString(this); + try { + return Strings.toString(this.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)); + } catch (IOException e) { + logger.error(e.getMessage()); + return ""; + } } @Override diff --git a/src/main/java/org/opensearch/securityanalytics/action/ValidateRulesResponse.java b/src/main/java/org/opensearch/securityanalytics/action/ValidateRulesResponse.java index 7403753cf..3bb04aae2 100644 --- a/src/main/java/org/opensearch/securityanalytics/action/ValidateRulesResponse.java +++ b/src/main/java/org/opensearch/securityanalytics/action/ValidateRulesResponse.java @@ -4,21 +4,26 @@ */ package org.opensearch.securityanalytics.action; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opensearch.action.ActionResponse; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.common.xcontent.ToXContent; import org.opensearch.common.xcontent.ToXContentObject; import org.opensearch.common.xcontent.XContentBuilder; -import org.opensearch.securityanalytics.mapper.MapperUtils; +import org.opensearch.common.xcontent.XContentFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; public class ValidateRulesResponse extends ActionResponse implements ToXContentObject { + private Logger logger = LogManager.getLogger(ValidateRulesResponse.class); + public static final String NONAPPLICABLE_FIELDS = "nonapplicable_fields"; List nonapplicableFields; @@ -66,7 +71,12 @@ public List getNonapplicableFields() { @Override public String toString() { - return Strings.toString(this); + try { + return Strings.toString(this.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)); + } catch (IOException e) { + logger.error(e.getMessage()); + return ""; + } } @Override From ef8de0df6afd1fb2400d6b8b7a11ff46c7479393 Mon Sep 17 00:00:00 2001 From: Ashish Agrawal Date: Tue, 21 Feb 2023 11:24:33 -0800 Subject: [PATCH 3/3] fix test issue Signed-off-by: Ashish Agrawal --- .../securityanalytics/SecurityAnalyticsRestTestCase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java b/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java index a4f2df778..3f95c8c42 100644 --- a/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java +++ b/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java @@ -164,7 +164,8 @@ protected String createTestIndex(String index, String mapping, Settings settings protected String createTestIndex(RestClient client, String index, String mapping, Settings settings) throws IOException { Request request = new Request("PUT", "/" + index); - String entity = "{\"settings\": " + Strings.toString(settings); + String entity = "{\"settings\": " + Strings.toString( + settings.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)); if (mapping != null) { entity = entity + ",\"mappings\" : {" + mapping + "}"; }