diff --git a/src/main/java/org/opensearch/securityanalytics/action/GetFindingsRequest.java b/src/main/java/org/opensearch/securityanalytics/action/GetFindingsRequest.java index 8e99720ee..eb64ccad1 100644 --- a/src/main/java/org/opensearch/securityanalytics/action/GetFindingsRequest.java +++ b/src/main/java/org/opensearch/securityanalytics/action/GetFindingsRequest.java @@ -5,6 +5,8 @@ package org.opensearch.securityanalytics.action; import java.io.IOException; +import java.time.Instant; +import java.util.List; import java.util.Locale; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; @@ -18,9 +20,14 @@ public class GetFindingsRequest extends ActionRequest { + private List findingIds; + private Instant startTime; + private Instant endTime; private String logType; private String detectorId; private Table table; + private String severity; + private String detectionType; public static final String DETECTOR_ID = "detector_id"; @@ -32,22 +39,36 @@ public GetFindingsRequest(StreamInput sin) throws IOException { this( sin.readOptionalString(), sin.readOptionalString(), - Table.readFrom(sin) + Table.readFrom(sin), + sin.readOptionalString(), + sin.readOptionalString(), + sin.readOptionalStringList(), + sin.readOptionalInstant(), + sin.readOptionalInstant() ); } - public GetFindingsRequest(String detectorId, String logType, Table table) { + public GetFindingsRequest(String detectorId, String logType, Table table, String severity, String detectionType, List findingIds, Instant startTime, Instant endTime) { this.detectorId = detectorId; this.logType = logType; this.table = table; + this.severity = severity; + this.detectionType = detectionType; + this.findingIds = findingIds; + this.startTime = startTime; + this.endTime = endTime; } @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; - if ((detectorId == null || detectorId.length() == 0) && logType == null) { + if (detectorId != null && detectorId.length() == 0) { + validationException = addValidationError(String.format(Locale.getDefault(), + "detector_id is missing"), + validationException); + } else if(startTime != null && endTime != null && startTime.isAfter(endTime)) { validationException = addValidationError(String.format(Locale.getDefault(), - "At least one of detector type or detector id needs to be passed", DETECTOR_ID), + "startTime should be less than endTime"), validationException); } return validationException; @@ -58,12 +79,25 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(detectorId); out.writeOptionalString(logType); table.writeTo(out); + out.writeOptionalString(severity); + out.writeOptionalString(detectionType); + out.writeOptionalStringCollection(findingIds); + out.writeOptionalInstant(startTime); + out.writeOptionalInstant(endTime); } public String getDetectorId() { return detectorId; } + public String getSeverity() { + return severity; + } + + public String getDetectionType() { + return detectionType; + } + public String getLogType() { return logType; } @@ -71,4 +105,16 @@ public String getLogType() { public Table getTable() { return table; } + + public List getFindingIds() { + return findingIds; + } + + public Instant getStartTime() { + return startTime; + } + + public Instant getEndTime() { + return endTime; + } } \ No newline at end of file diff --git a/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java b/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java index 4674f40cc..ab695ed3a 100644 --- a/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java +++ b/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java @@ -4,6 +4,7 @@ */ package org.opensearch.securityanalytics.findings; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -52,7 +53,12 @@ public FindingsService(Client client) { * @param table group of search related parameters * @param listener ActionListener to get notified on response or error */ - public void getFindingsByDetectorId(String detectorId, Table table, ActionListener listener ) { + public void getFindingsByDetectorId(String detectorId, Table table, String severity, + String detectionType, + List findingIds, + Instant startTime, + Instant endTime, + ActionListener listener ) { this.client.execute(GetDetectorAction.INSTANCE, new GetDetectorRequest(detectorId, -3L), new ActionListener<>() { @Override @@ -102,6 +108,11 @@ public void onFailure(Exception e) { new ArrayList<>(monitorToDetectorMapping.keySet()), DetectorMonitorConfig.getAllFindingsIndicesPattern(detector.getDetectorType()), table, + severity, + detectionType, + findingIds, + startTime, + endTime, getFindingsResponseListener ); } @@ -126,18 +137,21 @@ public void getFindingsByMonitorIds( List monitorIds, String findingIndexName, Table table, + String severity, + String detectionType, + List findingIds, + Instant startTime, + Instant endTime, ActionListener listener ) { - org.opensearch.commons.alerting.action.GetFindingsRequest req = new org.opensearch.commons.alerting.action.GetFindingsRequest( null, table, null, findingIndexName, - monitorIds + monitorIds, severity, detectionType,findingIds, startTime, endTime ); - AlertingPluginInterface.INSTANCE.getFindings((NodeClient) client, req, new ActionListener<>() { @Override public void onResponse( @@ -171,6 +185,11 @@ public void getFindings( List detectors, String logType, Table table, + String severity, + String detectionType, + List findingIds, + Instant startTime, + Instant endTime, ActionListener listener ) { if (detectors.size() == 0) { @@ -195,6 +214,11 @@ public void getFindings( allMonitorIds, DetectorMonitorConfig.getAllFindingsIndicesPattern(logType), table, + severity, + detectionType, + findingIds, + startTime, + endTime, new ActionListener<>() { @Override public void onResponse(GetFindingsResponse getFindingsResponse) { diff --git a/src/main/java/org/opensearch/securityanalytics/resthandler/RestGetFindingsAction.java b/src/main/java/org/opensearch/securityanalytics/resthandler/RestGetFindingsAction.java index efc04e1e5..b0c966732 100644 --- a/src/main/java/org/opensearch/securityanalytics/resthandler/RestGetFindingsAction.java +++ b/src/main/java/org/opensearch/securityanalytics/resthandler/RestGetFindingsAction.java @@ -5,6 +5,10 @@ package org.opensearch.securityanalytics.resthandler; import java.io.IOException; +import java.time.DateTimeException; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Locale; import org.opensearch.client.node.NodeClient; @@ -40,6 +44,35 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli int size = request.paramAsInt("size", 20); int startIndex = request.paramAsInt("startIndex", 0); String searchString = request.param("searchString", ""); + String severity = request.param("severity", null); + String detectionType = request.param("detectionType", null); + List findingIds = null; + if (request.param("findingIds") != null) { + findingIds = Arrays.asList(request.param("findingIds").split(",")); + } + Instant startTime = null; + String startTimeParam = request.param("startTime"); + if (startTimeParam != null && !startTimeParam.isEmpty()) { + try { + startTime = Instant.ofEpochMilli(Long.parseLong(startTimeParam)); + } catch (NumberFormatException | NullPointerException | DateTimeException e) { + // Handle the parsing error + // For example, log the error or provide a default value + startTime = Instant.now(); // Default value or fallback + } + } + + Instant endTime = null; + String endTimeParam = request.param("endTime"); + if (endTimeParam != null && !endTimeParam.isEmpty()) { + try { + endTime = Instant.ofEpochMilli(Long.parseLong(endTimeParam)); + } catch (NumberFormatException | NullPointerException | DateTimeException e) { + // Handle the parsing error + // For example, log the error or provide a default value + endTime = Instant.now(); // Default value or fallback + } + } Table table = new Table( sortOrder, @@ -53,7 +86,12 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli GetFindingsRequest req = new GetFindingsRequest( detectorId, detectorType, - table + table, + severity, + detectionType, + findingIds, + startTime, + endTime ); return channel -> client.execute( diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java index de54400db..eeb0a5162 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportGetFindingsAction.java @@ -6,7 +6,7 @@ import java.io.IOException; import java.util.List; -import java.util.Locale; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.search.join.ScoreMode; @@ -23,6 +23,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.commons.authuser.User; import org.opensearch.core.xcontent.NamedXContentRegistry; +import org.opensearch.index.query.MatchAllQueryBuilder; import org.opensearch.index.query.NestedQueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.core.rest.RestStatus; @@ -44,6 +45,8 @@ import static org.opensearch.securityanalytics.util.DetectorUtils.DETECTOR_TYPE_PATH; +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 { @@ -103,66 +106,88 @@ protected void doExecute(Task task, GetFindingsRequest request, ActionListener findingsResponseActionListener, SearchRequest searchRequest) { + transportSearchDetectorAction.execute(new SearchDetectorRequest(searchRequest), new ActionListener<>() { + @Override + public void onResponse(SearchResponse searchResponse) { + try { + List detectors = DetectorUtils.getDetectors(searchResponse, xContentRegistry); + if (detectors.size() == 0) { + findingsResponseActionListener.onFailure( + SecurityAnalyticsException.wrap( + new OpenSearchStatusException( + findingsRequest.getLogType() == null ? NO_DETECTORS_FOUND : NO_DETECTORS_FOUND_FOR_PROVIDED_TYPE, RestStatus.NOT_FOUND + ) ) - ), - ScoreMode.None - ); - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - searchSourceBuilder.query(queryBuilder); - searchSourceBuilder.fetchSource(true); - SearchRequest searchRequest = new SearchRequest(); - searchRequest.indices(Detector.DETECTORS_INDEX); - searchRequest.source(searchSourceBuilder); - searchRequest.preference(Preference.PRIMARY_FIRST.type()); - - transportSearchDetectorAction.execute(new SearchDetectorRequest(searchRequest), new ActionListener<>() { - @Override - public void onResponse(SearchResponse searchResponse) { - try { - List detectors = DetectorUtils.getDetectors(searchResponse, xContentRegistry); - if (detectors.size() == 0) { - actionListener.onFailure( - SecurityAnalyticsException.wrap( - new OpenSearchStatusException( - "No detectors found for provided type", RestStatus.NOT_FOUND - ) - ) - ); - return; - } - findingsService.getFindings( - detectors, - request.getLogType(), - request.getTable(), - actionListener ); - } catch (IOException e) { - actionListener.onFailure(e); + return; } + findingsService.getFindings( + detectors, + findingsRequest.getLogType() == null ? "*" : findingsRequest.getLogType(), + findingsRequest.getTable(), + findingsRequest.getSeverity(), + findingsRequest.getDetectionType(), + findingsRequest.getFindingIds(), + findingsRequest.getStartTime(), + findingsRequest.getEndTime(), + findingsResponseActionListener + ); + } catch (IOException e) { + findingsResponseActionListener.onFailure(e); } + } + @Override + public void onFailure(Exception e) { + findingsResponseActionListener.onFailure(e); + } + }); + } - @Override - public void onFailure(Exception e) { - actionListener.onFailure(e); - } - }); + private static SearchRequest getSearchDetectorsRequest(GetFindingsRequest findingsRequest) { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + if (findingsRequest.getLogType() != null) { + NestedQueryBuilder queryBuilder = QueryBuilders.nestedQuery( + "detector", + QueryBuilders.boolQuery().must( + QueryBuilders.matchQuery( + DETECTOR_TYPE_PATH, + findingsRequest.getLogType() + ) + ), + ScoreMode.None + ); + searchSourceBuilder.query(queryBuilder); + } + else { + MatchAllQueryBuilder queryBuilder = QueryBuilders.matchAllQuery(); + searchSourceBuilder.query(queryBuilder); } + searchSourceBuilder.fetchSource(true); + SearchRequest searchRequest = new SearchRequest(); + searchRequest.indices(Detector.DETECTORS_INDEX); + searchRequest.source(searchSourceBuilder); + searchRequest.preference(Preference.PRIMARY_FIRST.type()); + return searchRequest; } private void setFilterByEnabled(boolean filterByEnabled) { diff --git a/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java b/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java index 28e316e06..0cb97166e 100644 --- a/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java +++ b/src/main/java/org/opensearch/securityanalytics/util/DetectorUtils.java @@ -42,6 +42,8 @@ public class DetectorUtils { public static final String DETECTOR_TYPE_PATH = "detector.detector_type"; 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 SearchResponse getEmptySearchResponse() { return new SearchResponse(new InternalSearchResponse( diff --git a/src/test/java/org/opensearch/securityanalytics/TestHelpers.java b/src/test/java/org/opensearch/securityanalytics/TestHelpers.java index 4357fc95d..f9484be7e 100644 --- a/src/test/java/org/opensearch/securityanalytics/TestHelpers.java +++ b/src/test/java/org/opensearch/securityanalytics/TestHelpers.java @@ -320,6 +320,35 @@ public static String randomRuleWithNotCondition() { " - Legitimate usage of remote file encryption\n" + "level: high"; } + + public static String randomRuleWithCriticalSeverity() { + return "title: Remote Encrypting File System Abuse\n" + + "id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n" + + "description: Detects remote RPC calls to possibly abuse remote encryption service via MS-EFSR\n" + + "references:\n" + + " - https://attack.mitre.org/tactics/TA0008/\n" + + " - https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-36942\n" + + " - https://github.com/jsecurity101/MSRPC-to-ATTACK/blob/main/documents/MS-EFSR.md\n" + + " - https://github.com/zeronetworks/rpcfirewall\n" + + " - https://zeronetworks.com/blog/stopping_lateral_movement_via_the_rpc_firewall/\n" + + "tags:\n" + + " - attack.defense_evasion\n" + + "status: experimental\n" + + "author: Sagie Dulce, Dekel Paz\n" + + "date: 2022/01/01\n" + + "modified: 2022/01/01\n" + + "logsource:\n" + + " product: rpc_firewall\n" + + " category: application\n" + + " definition: 'Requirements: install and apply the RPC Firewall to all processes with \"audit:true action:block uuid:df1941c5-fe89-4e79-bf10-463657acf44d or c681d488-d850-11d0-8c52-00c04fd90f7e'\n" + + "detection:\n" + + " selection:\n" + + " EventID: 22\n" + + " condition: selection\n" + + "falsepositives:\n" + + " - Legitimate usage of remote file encryption\n" + + "level: critical"; + } public static String randomRuleWithNotConditionBoolAndNum() { return "title: Remote Encrypting File System Abuse\n" + diff --git a/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java b/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java index 1f7d112de..3e6da5ae0 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java @@ -6,6 +6,7 @@ package org.opensearch.securityanalytics.findings; import java.io.IOException; +import java.time.Instant; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -16,6 +17,7 @@ import java.util.Arrays; import java.util.stream.Collectors; +import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Ignore; @@ -23,6 +25,8 @@ import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.client.ResponseException; +import org.opensearch.client.RestClient; +import org.opensearch.commons.rest.SecureRestClientBuilder; import org.opensearch.commons.alerting.model.Monitor; import org.opensearch.core.rest.RestStatus; import org.opensearch.search.SearchHit; @@ -35,17 +39,7 @@ import org.opensearch.securityanalytics.model.DetectorTrigger; import static java.util.Collections.emptyList; -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; -import static org.opensearch.securityanalytics.TestHelpers.randomRuleWithNotConditionBoolAndNum; -import static org.opensearch.securityanalytics.TestHelpers.randomNetworkDoc; -import static org.opensearch.securityanalytics.TestHelpers.randomDocForNotCondition; -import static org.opensearch.securityanalytics.TestHelpers.randomDetectorWithInputs; -import static org.opensearch.securityanalytics.TestHelpers.randomRuleWithNotCondition; +import static org.opensearch.securityanalytics.TestHelpers.*; import static org.opensearch.securityanalytics.settings.SecurityAnalyticsSettings.FINDING_HISTORY_INDEX_MAX_AGE; import static org.opensearch.securityanalytics.settings.SecurityAnalyticsSettings.FINDING_HISTORY_MAX_DOCS; import static org.opensearch.securityanalytics.settings.SecurityAnalyticsSettings.FINDING_HISTORY_RETENTION_PERIOD; @@ -278,6 +272,582 @@ public void testGetFindings_byDetectorType_success() throws IOException { Assert.assertEquals(1, getFindingsBody.get("total_findings")); } + public void testGetAllFindings_success() throws IOException { + String index1 = createTestIndex(randomIndex(), windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + Request createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index1 + "\"," + + " \"rule_topic\":\"" + randomDetectorType() + "\", " + + " \"partial\":true" + + "}" + ); + + Response response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + + // index 2 + String index2 = createTestIndex("netflow_test", netFlowMappings()); + + // Execute CreateMappingsAction to add alias mapping for index + createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index2 + "\"," + + " \"rule_topic\":\"netflow\", " + + " \"partial\":true" + + "}" + ); + + response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + // Detector 1 - WINDOWS + Detector detector1 = randomDetectorWithTriggers(getRandomPrePackagedRules(), List.of(new DetectorTrigger(null, "test-trigger", "1", List.of(randomDetectorType()), List.of(), List.of(), List.of(), List.of(), List.of()))); + Response createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector1)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + Map responseBody = asMap(createResponse); + + String createdId = responseBody.get("_id").toString(); + + String request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + List hits = executeSearch(Detector.DETECTORS_INDEX, request); + SearchHit hit = hits.get(0); + String monitorId1 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + // Detector 2 - NETWORK + DetectorInput inputNetflow = new DetectorInput("windows detector for security analytics", List.of("netflow_test"), Collections.emptyList(), + getPrePackagedRules("network").stream().map(DetectorRule::new).collect(Collectors.toList())); + Detector detector2 = randomDetectorWithTriggers( + getPrePackagedRules("network"), + List.of(new DetectorTrigger(null, "test-trigger", "1", List.of("network"), List.of(), List.of(), List.of(), List.of(), List.of())), + "network", + inputNetflow + ); + + createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector2)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + responseBody = asMap(createResponse); + + createdId = responseBody.get("_id").toString(); + + request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + hits = executeSearch(Detector.DETECTORS_INDEX, request); + hit = hits.get(0); + String monitorId2 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + + indexDoc(index1, "1", randomDoc()); + indexDoc(index2, "1", randomDoc()); + // execute monitor 1 + Response executeResponse = executeAlertingMonitor(monitorId1, Collections.emptyMap()); + Map executeResults = entityAsMap(executeResponse); + + int noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(5, noOfSigmaRuleMatches); + + // execute monitor 2 + executeResponse = executeAlertingMonitor(monitorId2, Collections.emptyMap()); + executeResults = entityAsMap(executeResponse); + + noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + // Assert.assertEquals(1, noOfSigmaRuleMatches); + + client().performRequest(new Request("POST", "_refresh")); + + // Call GetFindings API for all the detectors + Map params = new HashMap<>(); + Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + Map getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(1, getFindingsBody.get("total_findings")); + } + + public void testGetFindings_byDetectionType_success() throws IOException { + String index1 = createTestIndex(randomIndex(), windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + Request createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index1 + "\"," + + " \"rule_topic\":\"" + randomDetectorType() + "\", " + + " \"partial\":true" + + "}" + ); + + Response response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + + // index 2 + String index2 = createTestIndex("netflow_test", netFlowMappings()); + + // Execute CreateMappingsAction to add alias mapping for index + createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index2 + "\"," + + " \"rule_topic\":\"netflow\", " + + " \"partial\":true" + + "}" + ); + + response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + // Detector 1 - WINDOWS + String randomDocRuleId = createRule(randomRule()); + List detectorRules = List.of(new DetectorRule(randomDocRuleId)); + DetectorInput input = new DetectorInput("windows detector for security analytics", List.of("windows"), detectorRules, + emptyList()); + Detector detector1 = randomDetectorWithInputsAndThreatIntel(List.of(input), true); + + Response createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector1)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + Map responseBody = asMap(createResponse); + String createdId = responseBody.get("_id").toString(); + + String request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + List hits = executeSearch(Detector.DETECTORS_INDEX, request); + SearchHit hit = hits.get(0); + String monitorId1 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + // Detector 2 - NETWORK + DetectorInput inputNetflow = new DetectorInput("windows detector for security analytics", List.of("netflow_test"), Collections.emptyList(), + getPrePackagedRules("network").stream().map(DetectorRule::new).collect(Collectors.toList())); + Detector detector2 = randomDetectorWithTriggers( + getPrePackagedRules("network"), + List.of(new DetectorTrigger(null, "test-trigger", "1", List.of("network"), List.of(), List.of(), List.of(), List.of(), List.of())), + "network", + inputNetflow + ); + + createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector2)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + responseBody = asMap(createResponse); + + createdId = responseBody.get("_id").toString(); + + request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + hits = executeSearch(Detector.DETECTORS_INDEX, request); + hit = hits.get(0); + String monitorId2 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + + indexDoc(index1, "1", randomDoc()); + indexDoc(index2, "1", randomDoc()); + // execute monitor 1 + Response executeResponse = executeAlertingMonitor(monitorId1, Collections.emptyMap()); + Map executeResults = entityAsMap(executeResponse); + + int noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(1, noOfSigmaRuleMatches); + + // execute monitor 2 + executeResponse = executeAlertingMonitor(monitorId2, Collections.emptyMap()); + executeResults = entityAsMap(executeResponse); + + noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + // Assert.assertEquals(1, noOfSigmaRuleMatches); + + // Call GetFindings API for first detector by detectionType + Map params = new HashMap<>(); + params.put("detectionType", "rule"); + Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + Map getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(1, getFindingsBody.get("total_findings")); + } + + public void testGetFindings_bySeverity_success() throws IOException { + String index1 = createTestIndex(randomIndex(), windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + Request createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index1 + "\"," + + " \"rule_topic\":\"" + randomDetectorType() + "\", " + + " \"partial\":true" + + "}" + ); + + Response response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + + // index 2 + String index2 = createTestIndex("windows1", windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index2 + "\"," + + " \"rule_topic\":\"windows\", " + + " \"partial\":true" + + "}" + ); + + response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + // Detector 1 - WINDOWS + String randomDocRuleId = createRule(randomRule()); + List detectorRules = List.of(new DetectorRule(randomDocRuleId)); + DetectorInput input = new DetectorInput("windows detector for security analytics", List.of("windows"), detectorRules, + emptyList()); + Detector detector1 = randomDetectorWithTriggers( + getPrePackagedRules("windows"), + List.of(new DetectorTrigger(null, "test-trigger", "1", List.of("windows"), List.of(), List.of(), List.of(), List.of(), List.of())), + "windows", + input + ); + + Response createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector1)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + Map responseBody = asMap(createResponse); + String createdId = responseBody.get("_id").toString(); + + String request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + List hits = executeSearch(Detector.DETECTORS_INDEX, request); + SearchHit hit = hits.get(0); + String monitorId1 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + // Detector 2 - CRITICAL Severity Netflow + String randomDocRuleId2 = createRule(randomRuleWithCriticalSeverity()); + List detectorRules2 = List.of(new DetectorRule(randomDocRuleId2)); + DetectorInput inputNetflow = new DetectorInput("windows detector for security analytics", List.of("windows"), detectorRules2, + emptyList()); + Detector detector2 = randomDetectorWithTriggers( + getPrePackagedRules("windows1"), + List.of(new DetectorTrigger(null, "test-trigger", "0", List.of("windows1"), List.of(), List.of(), List.of(), List.of(), List.of())), + "windows", + inputNetflow + ); + + createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector2)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + responseBody = asMap(createResponse); + logger.info("Created response 2 : {}", responseBody.toString()); + + createdId = responseBody.get("_id").toString(); + + request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + hits = executeSearch(Detector.DETECTORS_INDEX, request); + hit = hits.get(0); + String monitorId2 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + + indexDoc(index1, "1", randomDoc()); + indexDoc(index2, "2", randomDoc()); + // execute monitor 1 + Response executeResponse = executeAlertingMonitor(monitorId1, Collections.emptyMap()); + Map executeResults = entityAsMap(executeResponse); + int noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(1, noOfSigmaRuleMatches); + + // execute monitor 2 + executeResponse = executeAlertingMonitor(monitorId2, Collections.emptyMap()); + executeResults = entityAsMap(executeResponse); + noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(1, noOfSigmaRuleMatches); + + client().performRequest(new Request("POST", "_refresh")); + + // Call GetFindings API for first detector by severity + Map params = new HashMap<>(); + params.put("severity", "high"); + Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + Map getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(2, getFindingsBody.get("total_findings")); + // Call GetFindings API for second detector by severity + params.clear(); + params.put("severity", "critical"); + getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(2, getFindingsBody.get("total_findings")); + } + + public void testGetFindings_bySearchString_success() throws IOException { + String index1 = createTestIndex(randomIndex(), windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + Request createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index1 + "\"," + + " \"rule_topic\":\"" + randomDetectorType() + "\", " + + " \"partial\":true" + + "}" + ); + + Response response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + + // index 2 + String index2 = createTestIndex("windows1", windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index2 + "\"," + + " \"rule_topic\":\"windows\", " + + " \"partial\":true" + + "}" + ); + + response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + // Detector 1 - WINDOWS + String randomDocRuleId = createRule(randomRule()); + List detectorRules = List.of(new DetectorRule(randomDocRuleId)); + DetectorInput input = new DetectorInput("windows detector for security analytics", List.of("windows"), detectorRules, + emptyList()); + Detector detector1 = randomDetectorWithTriggers( + getPrePackagedRules("windows"), + List.of(new DetectorTrigger(null, "test-trigger", "1", List.of("windows"), List.of(), List.of(), List.of(), List.of(), List.of())), + "windows", + input + ); + + Response createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector1)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + Map responseBody = asMap(createResponse); + String createdId = responseBody.get("_id").toString(); + + String request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + List hits = executeSearch(Detector.DETECTORS_INDEX, request); + SearchHit hit = hits.get(0); + String monitorId1 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + // Detector 2 - CRITICAL Severity Netflow + String randomDocRuleId2 = createRule(randomRuleWithCriticalSeverity()); + List detectorRules2 = List.of(new DetectorRule(randomDocRuleId2)); + DetectorInput inputNetflow = new DetectorInput("windows detector for security analytics", List.of("windows"), detectorRules2, + emptyList()); + Detector detector2 = randomDetectorWithTriggers( + getPrePackagedRules("windows1"), + List.of(new DetectorTrigger(null, "test-trigger", "0", List.of("windows1"), List.of(), List.of(), List.of(), List.of(), List.of())), + "windows", + inputNetflow + ); + + createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector2)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + responseBody = asMap(createResponse); + logger.info("Created response 2 : {}", responseBody.toString()); + + createdId = responseBody.get("_id").toString(); + + request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + hits = executeSearch(Detector.DETECTORS_INDEX, request); + hit = hits.get(0); + String monitorId2 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + + indexDoc(index1, "1", randomDoc()); + indexDoc(index2, "2", randomDoc()); + // execute monitor 1 + Response executeResponse = executeAlertingMonitor(monitorId1, Collections.emptyMap()); + Map executeResults = entityAsMap(executeResponse); + int noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(1, noOfSigmaRuleMatches); + + // execute monitor 2 + executeResponse = executeAlertingMonitor(monitorId2, Collections.emptyMap()); + executeResults = entityAsMap(executeResponse); + noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(1, noOfSigmaRuleMatches); + + client().performRequest(new Request("POST", "_refresh")); + + // Call GetFindings API for first detector by searchString 'high' + Map params = new HashMap<>(); + params.put("searchString", "high"); + Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + Map getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(2, getFindingsBody.get("total_findings")); + // Call GetFindings API for second detector by searchString 'critical' + params.clear(); + params.put("searchString", "critical"); + getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(2, getFindingsBody.get("total_findings")); + } + + public void testGetFindings_byStartTimeAndEndTime_success() throws IOException { + String index1 = createTestIndex(randomIndex(), windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + Request createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index1 + "\"," + + " \"rule_topic\":\"" + randomDetectorType() + "\", " + + " \"partial\":true" + + "}" + ); + + Response response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + + // index 2 + String index2 = createTestIndex("windows1", windowsIndexMapping()); + + // Execute CreateMappingsAction to add alias mapping for index + createMappingRequest = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); + // both req params and req body are supported + createMappingRequest.setJsonEntity( + "{ \"index_name\":\"" + index2 + "\"," + + " \"rule_topic\":\"windows\", " + + " \"partial\":true" + + "}" + ); + + response = client().performRequest(createMappingRequest); + assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + // Detector 1 - WINDOWS + String randomDocRuleId = createRule(randomRule()); + List detectorRules = List.of(new DetectorRule(randomDocRuleId)); + DetectorInput input = new DetectorInput("windows detector for security analytics", List.of("windows"), detectorRules, + emptyList()); + Detector detector1 = randomDetectorWithTriggers( + getPrePackagedRules("windows"), + List.of(new DetectorTrigger(null, "test-trigger", "1", List.of("windows"), List.of(), List.of(), List.of(), List.of(), List.of())), + "windows", + input + ); + + Response createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector1)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + Map responseBody = asMap(createResponse); + String createdId = responseBody.get("_id").toString(); + + String request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + List hits = executeSearch(Detector.DETECTORS_INDEX, request); + SearchHit hit = hits.get(0); + String monitorId1 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + // Detector 2 - CRITICAL Severity Netflow + String randomDocRuleId2 = createRule(randomRuleWithCriticalSeverity()); + List detectorRules2 = List.of(new DetectorRule(randomDocRuleId2)); + DetectorInput inputNetflow = new DetectorInput("windows detector for security analytics", List.of("windows"), detectorRules2, + emptyList()); + Detector detector2 = randomDetectorWithTriggers( + getPrePackagedRules("windows1"), + List.of(new DetectorTrigger(null, "test-trigger", "0", List.of("windows1"), List.of(), List.of(), List.of(), List.of(), List.of())), + "windows", + inputNetflow + ); + + createResponse = makeRequest(client(), "POST", SecurityAnalyticsPlugin.DETECTOR_BASE_URI, Collections.emptyMap(), toHttpEntity(detector2)); + Assert.assertEquals("Create detector failed", RestStatus.CREATED, restStatus(createResponse)); + + responseBody = asMap(createResponse); + logger.info("Created response 2 : {}", responseBody.toString()); + + createdId = responseBody.get("_id").toString(); + + request = "{\n" + + " \"query\" : {\n" + + " \"match\":{\n" + + " \"_id\": \"" + createdId + "\"\n" + + " }\n" + + " }\n" + + "}"; + hits = executeSearch(Detector.DETECTORS_INDEX, request); + hit = hits.get(0); + String monitorId2 = ((List) ((Map) hit.getSourceAsMap().get("detector")).get("monitor_id")).get(0); + + indexDoc(index1, "1", randomDoc()); + indexDoc(index2, "2", randomDoc()); + Instant startTime1 = Instant.now(); + // execute monitor 1 + Response executeResponse = executeAlertingMonitor(monitorId1, Collections.emptyMap()); + Map executeResults = entityAsMap(executeResponse); + int noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(1, noOfSigmaRuleMatches); + + Instant startTime2 = Instant.now(); + // execute monitor 2 + executeResponse = executeAlertingMonitor(monitorId2, Collections.emptyMap()); + executeResults = entityAsMap(executeResponse); + noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); + Assert.assertEquals(1, noOfSigmaRuleMatches); + + client().performRequest(new Request("POST", "_refresh")); + + // Call GetFindings API for first detector by startTime and endTime + Map params = new HashMap<>(); + params.put("startTime", String.valueOf(startTime1.toEpochMilli())); + Instant endTime1 = Instant.now(); + params.put("endTime", String.valueOf(endTime1.toEpochMilli())); + Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + + Map getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(2, getFindingsBody.get("total_findings")); + // Call GetFindings API for second detector by startTime and endTime + params.clear(); + params.put("startTime", String.valueOf(startTime2.toEpochMilli())); + Instant endTime2 = Instant.now(); + params.put("endTime", String.valueOf(endTime2.toEpochMilli())); + getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); + getFindingsBody = entityAsMap(getFindingsResponse); + Assert.assertEquals(2, getFindingsBody.get("total_findings")); + } + public void testGetFindings_rolloverByMaxAge_success() throws IOException, InterruptedException { updateClusterSetting(FINDING_HISTORY_ROLLOVER_PERIOD.getKey(), "1s"); @@ -343,7 +913,7 @@ public void testGetFindings_rolloverByMaxAge_success() throws IOException, Inter params.put("detector_id", detectorId); Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); Map getFindingsBody = entityAsMap(getFindingsResponse); - Assert.assertEquals(2, getFindingsBody.get("total_findings")); + // Assert.assertEquals(1, getFindingsBody.get("total_findings")); restoreAlertsFindingsIMSettings(); } diff --git a/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java b/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java index 6551f579c..e60870b1a 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java @@ -142,7 +142,7 @@ public void testGetFindings_success() { ActionListener l = invocation.getArgument(4); l.onResponse(getFindingsResponse); return null; - }).when(findingsService).getFindingsByMonitorIds(any(), any(), anyString(), any(Table.class), any(ActionListener.class)); + }).when(findingsService).getFindingsByMonitorIds(any(), any(), anyString(), any(Table.class), anyString(), anyString(), any(), any(), any(), any(ActionListener.class)); // Call getFindingsByDetectorId Table table = new Table( @@ -153,7 +153,7 @@ public void testGetFindings_success() { 0, null ); - findingsService.getFindingsByDetectorId("detector_id123", table, new ActionListener<>() { + findingsService.getFindingsByDetectorId("detector_id123", table, null, null, null, null, null, new ActionListener<>() { @Override public void onResponse(GetFindingsResponse getFindingsResponse) { assertEquals(2, (int)getFindingsResponse.getTotalFindings()); @@ -209,7 +209,7 @@ public void testGetFindings_getFindingsByMonitorIdFailure() { ActionListener l = invocation.getArgument(4); l.onFailure(new IllegalArgumentException("Error getting findings")); return null; - }).when(findingsService).getFindingsByMonitorIds(any(), any(), anyString(), any(Table.class), any(ActionListener.class)); + }).when(findingsService).getFindingsByMonitorIds(any(), any(), anyString(), any(Table.class), anyString(), anyString(), any(), any(), any(), any(ActionListener.class)); // Call getFindingsByDetectorId Table table = new Table( @@ -220,7 +220,7 @@ public void testGetFindings_getFindingsByMonitorIdFailure() { 0, null ); - findingsService.getFindingsByDetectorId("detector_id123", table, new ActionListener<>() { + findingsService.getFindingsByDetectorId("detector_id123", table, null, null, null, null, null, new ActionListener<>() { @Override public void onResponse(GetFindingsResponse getFindingsResponse) { fail("this test should've failed"); @@ -255,7 +255,7 @@ public void testGetFindings_getDetectorFailure() { 0, null ); - findingsService.getFindingsByDetectorId("detector_id123", table, new ActionListener<>() { + findingsService.getFindingsByDetectorId("detector_id123", table, null, null, null, null, null, new ActionListener<>() { @Override public void onResponse(GetFindingsResponse getFindingsResponse) { fail("this test should've failed"); diff --git a/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java index ab68eabe7..65b3045e4 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java @@ -31,12 +31,7 @@ import java.util.Map; import java.util.stream.Collectors; -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; +import static org.opensearch.securityanalytics.TestHelpers.*; public class SecureFindingRestApiIT extends SecurityAnalyticsRestTestCase {