[Security Solution][Detection Engine] adds DOES NOT MATCH capability to IM rule type#227084
[Security Solution][Detection Engine] adds DOES NOT MATCH capability to IM rule type#227084vitaliidm merged 86 commits intoelastic:mainfrom
Conversation
# Conflicts: # x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types/indicator_match/threat_mapping/build_threat_mapping_filter.ts # x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types/indicator_match/threat_mapping/get_signals_map_from_threat_index.ts
… corner case scenario
…kibana into de_9_2/im-not-matches
…/detection_engine/rule_types/indicator_match/threat_mapping/utils.test.ts Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
|
@marshallmain, thanks for the review. I have addressed the comments |
…mon/components/threat_match/translations.ts Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
nastasha-solomon
left a comment
There was a problem hiding this comment.
Just the one small tweak. Otherwise, lgtm for now!
| message: i18n.translate( | ||
| 'xpack.securitySolution.detectionEngine.ruleManagement.threatMappingField.singleNotMatchClauseError', | ||
| { | ||
| defaultMessage: 'Conditions in AND clauses must have at least one MATCHES entry.', |
There was a problem hiding this comment.
| defaultMessage: 'Conditions in AND clauses must have at least one MATCHES entry.', | |
| defaultMessage: 'Conditions with AND clauses must have at least one MATCHES entry.', |
marshallmain
left a comment
There was a problem hiding this comment.
LGTM, thanks for addressing my comments 🚀
Understanding the changes to validateCompleteThreatMatches was by far the hardest part, and I hope we can drastically simplify that logic by adjusting the way we name query clauses. The remaining unresolved comments are for future (soon) work.
| return false; | ||
| }); | ||
| Object.values(threatQueriesMap).forEach((threatQueriesPerId) => { | ||
| const matchedThreatQueriesForAndGroup: ThreatMatchNamedQuery[] = []; |
There was a problem hiding this comment.
This const can go inside the inner loop as well?
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
Total ESLint disabled count
History
cc @vitaliidm |
…to IM rule type (elastic#227084) ## Summary - addresses elastic/security-team#13022 - allows selecting DOES NOT MATCH condition, it would create alert for any document that has at least one matching field and not matching. Single DOES NOT MATCH is **not allowed**, to prevent creation of large number of alerts. User would be able to select match first and then tune it with DOES NOT MATCH if needed - added `negate: boolean` value to ThreatMap entry schema to indicate this mapping should use as DOES NOT MATCH. Field name `negate` was chosen as it already used in Kibana filters to indicate field does not match some value. - Enrichments for DOES NOT MATCH field are omitted - If one of the DOES NOT MATCH fields is empty, we create an alert. If both empty - no alert should be created - I fixed issue within `validateCompleteThreatMatches`, where False Positive alert can be created if there partial matches across AND group in multiple threats - Removed `x-pack/solutions/security/packages/kbn-securitysolution-io-ts-alerting-types/src/threat_mapping/index.ts` in favour of OpenAPI schema ### Feature Flag ```yml xpack.securitySolution.enableExperimental: - doesNotMatchForIndicatorMatchRuleEnabled ``` ### UI 1. Having help text under label and for the first entry, DOES NOT MATCH option should be disabled <img width="1112" height="214" alt="Screenshot 2025-07-28 at 10 47 26" src="https://github.com/user-attachments/assets/740c8170-45ae-4773-a93b-ac2e0bf12c9c" /> 2. User can add DOES NOT MATCH as second AND condition <img width="1050" height="320" alt="Screenshot 2025-07-28 at 10 47 08" src="https://github.com/user-attachments/assets/56b1f26e-6951-47e7-b7a6-4ff62f5b44a5" /> 3. If user deletes first MATCH we would show validation error <img width="1040" height="241" alt="Screenshot 2025-07-28 at 10 47 43" src="https://github.com/user-attachments/assets/a61274b3-087d-450d-97cc-5ac2b40079db" /> 4. user cannot setup a match and not match condition for the same field, validation error <img width="1064" height="282" alt="Screenshot 2025-07-28 at 10 48 02" src="https://github.com/user-attachments/assets/0ae790e1-7e3d-4fb7-8550-fb3d92b9d678" /> ### Flaky test runner Cypress: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8886 FTR: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8885 ### Docs issue - elastic/docs-content#2295 ### Test plan - elastic/security-team#13367 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: florent-leborgne <florent.leborgne@elastic.co> Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
…to IM rule type (elastic#227084) ## Summary - addresses elastic/security-team#13022 - allows selecting DOES NOT MATCH condition, it would create alert for any document that has at least one matching field and not matching. Single DOES NOT MATCH is **not allowed**, to prevent creation of large number of alerts. User would be able to select match first and then tune it with DOES NOT MATCH if needed - added `negate: boolean` value to ThreatMap entry schema to indicate this mapping should use as DOES NOT MATCH. Field name `negate` was chosen as it already used in Kibana filters to indicate field does not match some value. - Enrichments for DOES NOT MATCH field are omitted - If one of the DOES NOT MATCH fields is empty, we create an alert. If both empty - no alert should be created - I fixed issue within `validateCompleteThreatMatches`, where False Positive alert can be created if there partial matches across AND group in multiple threats - Removed `x-pack/solutions/security/packages/kbn-securitysolution-io-ts-alerting-types/src/threat_mapping/index.ts` in favour of OpenAPI schema ### Feature Flag ```yml xpack.securitySolution.enableExperimental: - doesNotMatchForIndicatorMatchRuleEnabled ``` ### UI 1. Having help text under label and for the first entry, DOES NOT MATCH option should be disabled <img width="1112" height="214" alt="Screenshot 2025-07-28 at 10 47 26" src="https://github.com/user-attachments/assets/740c8170-45ae-4773-a93b-ac2e0bf12c9c" /> 2. User can add DOES NOT MATCH as second AND condition <img width="1050" height="320" alt="Screenshot 2025-07-28 at 10 47 08" src="https://github.com/user-attachments/assets/56b1f26e-6951-47e7-b7a6-4ff62f5b44a5" /> 3. If user deletes first MATCH we would show validation error <img width="1040" height="241" alt="Screenshot 2025-07-28 at 10 47 43" src="https://github.com/user-attachments/assets/a61274b3-087d-450d-97cc-5ac2b40079db" /> 4. user cannot setup a match and not match condition for the same field, validation error <img width="1064" height="282" alt="Screenshot 2025-07-28 at 10 48 02" src="https://github.com/user-attachments/assets/0ae790e1-7e3d-4fb7-8550-fb3d92b9d678" /> ### Flaky test runner Cypress: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8886 FTR: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8885 ### Docs issue - elastic/docs-content#2295 ### Test plan - elastic/security-team#13367 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: florent-leborgne <florent.leborgne@elastic.co> Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
…H operator (elastic#232996) ## Summary - follow up for elastic#227084 - enables FF `doesNotMatchForIndicatorMatchRuleEnabled`
…imental feature flag (elastic#249550) ## Summary - removes Indicator match **DOES NOT MATCH** experimental feature flag`doesNotMatchForIndicatorMatchRuleEnabled` and corresponding feature tour - feature flag was introduced in elastic#227084 (cherry picked from commit 7a7da04) # Conflicts: # x-pack/solutions/security/test/security_solution_api_integration/config/ess/config.base.ts # x-pack/solutions/security/test/security_solution_api_integration/config/serverless/config.base.ts # x-pack/solutions/security/test/security_solution_cypress/config.ts # x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/entity_analytics/threat_hunting/threat_hunting_page.cy.ts # x-pack/solutions/security/test/security_solution_cypress/serverless_config.ts
… experimental feature flag (#249550) (#250888) # Backport This will backport the following commits from `main` to `9.3`: - [[Security Solution][Detection Engine] removes IM DOES NOT MATCH experimental feature flag (#249550)](#249550) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Vitalii Dmyterko","email":"92328789+vitaliidm@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-01-27T10:13:41Z","message":"[Security Solution][Detection Engine] removes IM DOES NOT MATCH experimental feature flag (#249550)\n\n## Summary\n\n- removes Indicator match **DOES NOT MATCH** experimental feature\nflag`doesNotMatchForIndicatorMatchRuleEnabled` and corresponding feature\ntour\n- feature flag was introduced in\nhttps://github.com//pull/227084","sha":"7a7da04378473bebd2eab1a74f929212f9cecc9c","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","Team: SecuritySolution","Team:Detection Engine","backport:version","v9.3.0","v9.4.0"],"title":"[Security Solution][Detection Engine] removes IM DOES NOT MATCH experimental feature flag","number":249550,"url":"https://github.com/elastic/kibana/pull/249550","mergeCommit":{"message":"[Security Solution][Detection Engine] removes IM DOES NOT MATCH experimental feature flag (#249550)\n\n## Summary\n\n- removes Indicator match **DOES NOT MATCH** experimental feature\nflag`doesNotMatchForIndicatorMatchRuleEnabled` and corresponding feature\ntour\n- feature flag was introduced in\nhttps://github.com//pull/227084","sha":"7a7da04378473bebd2eab1a74f929212f9cecc9c"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/249550","number":249550,"mergeCommit":{"message":"[Security Solution][Detection Engine] removes IM DOES NOT MATCH experimental feature flag (#249550)\n\n## Summary\n\n- removes Indicator match **DOES NOT MATCH** experimental feature\nflag`doesNotMatchForIndicatorMatchRuleEnabled` and corresponding feature\ntour\n- feature flag was introduced in\nhttps://github.com//pull/227084","sha":"7a7da04378473bebd2eab1a74f929212f9cecc9c"}}]}] BACKPORT-->
Summary
negate: booleanvalue to ThreatMap entry schema to indicate this mapping should use as DOES NOT MATCH.Field name
negatewas chosen as it already used in Kibana filters to indicate field does not match some value.validateCompleteThreatMatches, where False Positive alert can be created if there partial matches across AND group in multiple threatsx-pack/solutions/security/packages/kbn-securitysolution-io-ts-alerting-types/src/threat_mapping/index.tsin favour of OpenAPI schemaFeature Flag
UI
Flaky test runner
Cypress: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8886
FTR: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8885
Docs issue
Test plan