From 8552688b9806103aa381a1b2a500a9b6517c7b3a Mon Sep 17 00:00:00 2001 From: Megha Goyal Date: Thu, 8 Feb 2024 15:11:10 -0800 Subject: [PATCH] Fail the flow the when detectot type is missing in the log types index Signed-off-by: Megha Goyal --- .../correlation/VectorEmbeddingsEngine.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java b/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java index 9a423f6fb..0f9866766 100644 --- a/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java +++ b/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java @@ -229,6 +229,11 @@ public void onFailure(Exception e) { } public void insertOrphanFindings(String detectorType, Finding finding, float timestampFeature, Map logTypes) { + if (logTypes.get(detectorType) == null) { + log.error("LogTypes Index is missing the detector type {}", detectorType); + correlateFindingAction.onFailures(new OpenSearchStatusException("LogTypes Index is missing the detector type", RestStatus.INTERNAL_SERVER_ERROR)); + } + Map tags = logTypes.get(detectorType).getTags(); String correlationId = tags.get("correlation_id").toString();