Skip to content

Commit d6d5075

Browse files
committed
fix correlation engine trigger even if no rules are present
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
1 parent 85351a1 commit d6d5075

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,20 @@ private void onAutoCorrelations(Detector detector, Finding finding, Map<String,
253253
CorrelationRule rule = CorrelationRule.parse(xcp, hit.getId(), hit.getVersion());
254254
correlationRules.add(rule);
255255
}
256-
getValidDocuments(detectorType, indices, correlationRules, relatedDocIds, autoCorrelations);
256+
if (!correlationRules.isEmpty() || !autoCorrelations.isEmpty()) {
257+
getValidDocuments(detectorType, indices, correlationRules, relatedDocIds, autoCorrelations);
258+
} else {
259+
correlateFindingAction.onOperation();
260+
}
257261
}, e -> {
258262
try {
259263
log.error("[CORRELATIONS] Exception encountered while searching correlation rule index for finding id {}",
260264
finding.getId(), e);
261-
getValidDocuments(detectorType, indices, List.of(), List.of(), autoCorrelations);
265+
if (!autoCorrelations.isEmpty()) {
266+
getValidDocuments(detectorType, indices, List.of(), List.of(), autoCorrelations);
267+
} else {
268+
correlateFindingAction.onOperation();
269+
}
262270
} catch (Exception ex) {
263271
onFailure(ex);
264272
}

src/test/java/org/opensearch/securityanalytics/correlation/CorrelationEngineRestApiIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ public void testListCorrelationsWorkflow() throws IOException, InterruptedExcept
164164

165165
@SuppressWarnings("unchecked")
166166
public void testBasicCorrelationEngineWorkflowWithoutRules() throws IOException, InterruptedException {
167-
updateClusterSetting(SecurityAnalyticsSettings.ENABLE_AUTO_CORRELATIONS.getKey(), "true");
168167
LogIndices indices = createIndices();
169168

170169
String vpcFlowMonitorId = createVpcFlowDetector(indices.vpcFlowsIndex);
@@ -220,7 +219,8 @@ public void testBasicCorrelationEngineWorkflowWithoutRules() throws IOException,
220219
}
221220
return false;
222221
} catch (Exception ex) {
223-
return false;
222+
// because no findings are found
223+
return true;
224224
}
225225
},
226226
2, TimeUnit.MINUTES

0 commit comments

Comments
 (0)