From 0ac03b50e22391e507abfd5624408b8a5968cfee Mon Sep 17 00:00:00 2001 From: Riya Saxena Date: Wed, 13 Mar 2024 09:24:56 -0700 Subject: [PATCH] address the pr comments Signed-off-by: Riya Saxena --- .../transport/TransportGetFindingsAction.java | 5 ++--- .../opensearch/securityanalytics/util/DetectorUtils.java | 1 + .../securityanalytics/findings/SecureFindingRestApiIT.java | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java index eeb0a5162..21ed09674 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java @@ -42,14 +42,12 @@ import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; - - import static org.opensearch.securityanalytics.util.DetectorUtils.DETECTOR_TYPE_PATH; +import static org.opensearch.securityanalytics.util.DetectorUtils.MAX_DETECTORS_SEARCH_SIZE; import static org.opensearch.securityanalytics.util.DetectorUtils.NO_DETECTORS_FOUND; import static org.opensearch.securityanalytics.util.DetectorUtils.NO_DETECTORS_FOUND_FOR_PROVIDED_TYPE; public class TransportGetFindingsAction extends HandledTransportAction implements SecureTransportAction { - private final TransportSearchDetectorAction transportSearchDetectorAction; private final NamedXContentRegistry xContentRegistry; @@ -181,6 +179,7 @@ private static SearchRequest getSearchDetectorsRequest(GetFindingsRequest findin else { MatchAllQueryBuilder queryBuilder = QueryBuilders.matchAllQuery(); searchSourceBuilder.query(queryBuilder); + searchSourceBuilder.size(MAX_DETECTORS_SEARCH_SIZE); // Set the size to 10000 } searchSourceBuilder.fetchSource(true); SearchRequest searchRequest = new SearchRequest(); diff --git a/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java b/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java index 0cb97166e..119de62cf 100644 --- a/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java +++ b/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java @@ -44,6 +44,7 @@ public class DetectorUtils { public static final String DETECTOR_ID_FIELD = "detector_id"; public static final String NO_DETECTORS_FOUND = "No detectors found "; public static final String NO_DETECTORS_FOUND_FOR_PROVIDED_TYPE = "No detectors found for provided type"; + public static final int MAX_DETECTORS_SEARCH_SIZE = 10000; public static SearchResponse getEmptySearchResponse() { return new SearchResponse(new InternalSearchResponse( diff --git a/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java index 65b3045e4..ab68eabe7 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java @@ -31,7 +31,12 @@ import java.util.Map; import java.util.stream.Collectors; -import static org.opensearch.securityanalytics.TestHelpers.*; +import static org.opensearch.securityanalytics.TestHelpers.netFlowMappings; +import static org.opensearch.securityanalytics.TestHelpers.randomDetectorType; +import static org.opensearch.securityanalytics.TestHelpers.randomDetectorWithTriggers; +import static org.opensearch.securityanalytics.TestHelpers.randomDoc; +import static org.opensearch.securityanalytics.TestHelpers.randomIndex; +import static org.opensearch.securityanalytics.TestHelpers.windowsIndexMapping; public class SecureFindingRestApiIT extends SecurityAnalyticsRestTestCase {