[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly#259199
Conversation
1b8fad7 to
af055cf
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
Pinging @elastic/security-detection-engine (Team:Detection Engine) |
nkhristinin
left a comment
There was a problem hiding this comment.
Thanks for fix, it LGTM!
But I have question about create_threat_signal.ts, we right now passing there currentResult and there case where we return it
// empty threat list and we do not want to return everything as being
// a hit so opt to return the existing result.
ruleExecutionLogger.trace(
'Indicator items are empty after filtering for missing data, returning without attempting a match'
);
return currentResult;
}
Should we remove it, and add another use case for threat first search?
Good point, yeah I'll fix that one as well in this PR and add another test. |
|
@nkhristinin I added the suggested fix for threat-first search as well, and a similar test for that scenario. The test already passes without the fix that removes |
nkhristinin
left a comment
There was a problem hiding this comment.
LGTM! Thanks for fixing it!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
|
Starting backport for target branches: 9.2, 9.3 https://github.com/elastic/kibana/actions/runs/23601384010 |
…arning shows correctly (elastic#259199) Fixes elastic#259169 `createEventSignal` has a bug where it returns incorrect summary results for pages of source docs that matched no indicators. The calling code expects `createEventSignal` to return results pertaining only to the current page, but if no indicators are matched or an error is encountered, the function instead returns `currentResults` i.e. the sum of results from all prior pages. The effect is that each time a page matches no indicators the alert count we track in `createThreatSignals` _doubles_ because we add `currentResults` to itself. (cherry picked from commit 22c93a4)
…arning shows correctly (elastic#259199) Fixes elastic#259169 `createEventSignal` has a bug where it returns incorrect summary results for pages of source docs that matched no indicators. The calling code expects `createEventSignal` to return results pertaining only to the current page, but if no indicators are matched or an error is encountered, the function instead returns `currentResults` i.e. the sum of results from all prior pages. The effect is that each time a page matches no indicators the alert count we track in `createThreatSignals` _doubles_ because we add `currentResults` to itself. (cherry picked from commit 22c93a4)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…erts warning shows correctly (#259199) (#259805) # Backport This will backport the following commits from `main` to `9.3`: - [[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)](#259199) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Marshall Main","email":"55718608+marshallmain@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-03-26T15:00:15Z","message":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)\n\nFixes https://github.com/elastic/kibana/issues/259169\n\n`createEventSignal` has a bug where it returns incorrect summary results\nfor pages of source docs that matched no indicators. The calling code\nexpects `createEventSignal` to return results pertaining only to the\ncurrent page, but if no indicators are matched or an error is\nencountered, the function instead returns `currentResults` i.e. the sum\nof results from all prior pages. The effect is that each time a page\nmatches no indicators the alert count we track in `createThreatSignals`\n_doubles_ because we add `currentResults` to itself.","sha":"22c93a4b288217542614978c098814c6157f3b4d","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Indicator Match Rule","Team:Detection Engine","backport:version","v9.4.0","9.4.0","v9.3.3","v9.2.8"],"title":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly","number":259199,"url":"https://github.com/elastic/kibana/pull/259199","mergeCommit":{"message":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)\n\nFixes https://github.com/elastic/kibana/issues/259169\n\n`createEventSignal` has a bug where it returns incorrect summary results\nfor pages of source docs that matched no indicators. The calling code\nexpects `createEventSignal` to return results pertaining only to the\ncurrent page, but if no indicators are matched or an error is\nencountered, the function instead returns `currentResults` i.e. the sum\nof results from all prior pages. The effect is that each time a page\nmatches no indicators the alert count we track in `createThreatSignals`\n_doubles_ because we add `currentResults` to itself.","sha":"22c93a4b288217542614978c098814c6157f3b4d"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/259199","number":259199,"mergeCommit":{"message":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)\n\nFixes https://github.com/elastic/kibana/issues/259169\n\n`createEventSignal` has a bug where it returns incorrect summary results\nfor pages of source docs that matched no indicators. The calling code\nexpects `createEventSignal` to return results pertaining only to the\ncurrent page, but if no indicators are matched or an error is\nencountered, the function instead returns `currentResults` i.e. the sum\nof results from all prior pages. The effect is that each time a page\nmatches no indicators the alert count we track in `createThreatSignals`\n_doubles_ because we add `currentResults` to itself.","sha":"22c93a4b288217542614978c098814c6157f3b4d"}},{"branch":"9.3","label":"v9.3.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.8","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
…erts warning shows correctly (#259199) (#259804) # Backport This will backport the following commits from `main` to `9.2`: - [[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)](#259199) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Marshall Main","email":"55718608+marshallmain@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-03-26T15:00:15Z","message":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)\n\nFixes https://github.com/elastic/kibana/issues/259169\n\n`createEventSignal` has a bug where it returns incorrect summary results\nfor pages of source docs that matched no indicators. The calling code\nexpects `createEventSignal` to return results pertaining only to the\ncurrent page, but if no indicators are matched or an error is\nencountered, the function instead returns `currentResults` i.e. the sum\nof results from all prior pages. The effect is that each time a page\nmatches no indicators the alert count we track in `createThreatSignals`\n_doubles_ because we add `currentResults` to itself.","sha":"22c93a4b288217542614978c098814c6157f3b4d","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Indicator Match Rule","Team:Detection Engine","backport:version","v9.4.0","9.4.0","v9.3.3","v9.2.8"],"title":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly","number":259199,"url":"https://github.com/elastic/kibana/pull/259199","mergeCommit":{"message":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)\n\nFixes https://github.com/elastic/kibana/issues/259169\n\n`createEventSignal` has a bug where it returns incorrect summary results\nfor pages of source docs that matched no indicators. The calling code\nexpects `createEventSignal` to return results pertaining only to the\ncurrent page, but if no indicators are matched or an error is\nencountered, the function instead returns `currentResults` i.e. the sum\nof results from all prior pages. The effect is that each time a page\nmatches no indicators the alert count we track in `createThreatSignals`\n_doubles_ because we add `currentResults` to itself.","sha":"22c93a4b288217542614978c098814c6157f3b4d"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/259199","number":259199,"mergeCommit":{"message":"[Security Solution][Detection Engine] Fix alert count so max alerts warning shows correctly (#259199)\n\nFixes https://github.com/elastic/kibana/issues/259169\n\n`createEventSignal` has a bug where it returns incorrect summary results\nfor pages of source docs that matched no indicators. The calling code\nexpects `createEventSignal` to return results pertaining only to the\ncurrent page, but if no indicators are matched or an error is\nencountered, the function instead returns `currentResults` i.e. the sum\nof results from all prior pages. The effect is that each time a page\nmatches no indicators the alert count we track in `createThreatSignals`\n_doubles_ because we add `currentResults` to itself.","sha":"22c93a4b288217542614978c098814c6157f3b4d"}},{"branch":"9.3","label":"v9.3.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.8","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
…arning shows correctly (elastic#259199) Fixes elastic#259169 `createEventSignal` has a bug where it returns incorrect summary results for pages of source docs that matched no indicators. The calling code expects `createEventSignal` to return results pertaining only to the current page, but if no indicators are matched or an error is encountered, the function instead returns `currentResults` i.e. the sum of results from all prior pages. The effect is that each time a page matches no indicators the alert count we track in `createThreatSignals` _doubles_ because we add `currentResults` to itself.
…arning shows correctly (elastic#259199) Fixes elastic#259169 `createEventSignal` has a bug where it returns incorrect summary results for pages of source docs that matched no indicators. The calling code expects `createEventSignal` to return results pertaining only to the current page, but if no indicators are matched or an error is encountered, the function instead returns `currentResults` i.e. the sum of results from all prior pages. The effect is that each time a page matches no indicators the alert count we track in `createThreatSignals` _doubles_ because we add `currentResults` to itself.
Fixes #259169
createEventSignalhas a bug where it returns incorrect summary results for pages of source docs that matched no indicators. The calling code expectscreateEventSignalto return results pertaining only to the current page, but if no indicators are matched or an error is encountered, the function instead returnscurrentResultsi.e. the sum of results from all prior pages. The effect is that each time a page matches no indicators the alert count we track increateThreatSignalsdoubles because we addcurrentResultsto itself.