Skip to content

[Security Solution][Detection Engine] adds DOES NOT MATCH capability to IM rule type#227084

Merged
vitaliidm merged 86 commits intoelastic:mainfrom
vitaliidm:de_9_2/im-not-matches
Aug 6, 2025
Merged

[Security Solution][Detection Engine] adds DOES NOT MATCH capability to IM rule type#227084
vitaliidm merged 86 commits intoelastic:mainfrom
vitaliidm:de_9_2/im-not-matches

Conversation

@vitaliidm
Copy link
Contributor

@vitaliidm vitaliidm commented Jul 8, 2025

Summary

  • addresses https://github.com/elastic/security-team/issues/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

xpack.securitySolution.enableExperimental:
  - doesNotMatchForIndicatorMatchRuleEnabled
 

UI

  1. Having help text under label and for the first entry, DOES NOT MATCH option should be disabled
Screenshot 2025-07-28 at 10 47 26
  1. User can add DOES NOT MATCH as second AND condition
Screenshot 2025-07-28 at 10 47 08
  1. If user deletes first MATCH we would show validation error
Screenshot 2025-07-28 at 10 47 43
  1. user cannot setup a match and not match condition for the same field, validation error
Screenshot 2025-07-28 at 10 48 02

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

@vitaliidm vitaliidm self-assigned this Jul 8, 2025
@vitaliidm vitaliidm added backport:skip This PR does not require backporting Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. release_note:feature Makes this part of the condensed release notes Team:Detection Engine Security Solution Detection Engine Area v9.2.0 labels Jul 8, 2025
vitaliidm and others added 23 commits July 9, 2025 12:26
# 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
vitaliidm and others added 2 commits August 5, 2025 12:12
…/detection_engine/rule_types/indicator_match/threat_mapping/utils.test.ts

Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
@vitaliidm
Copy link
Contributor Author

@marshallmain, thanks for the review. I have addressed the comments

@vitaliidm vitaliidm requested a review from marshallmain August 5, 2025 11:39
vitaliidm and others added 2 commits August 5, 2025 12:40
…mon/components/threat_match/translations.ts

Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
Copy link
Contributor

@nastasha-solomon nastasha-solomon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defaultMessage: 'Conditions in AND clauses must have at least one MATCHES entry.',
defaultMessage: 'Conditions with AND clauses must have at least one MATCHES entry.',

Copy link
Contributor

@marshallmain marshallmain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This const can go inside the inner loop as well?

@vitaliidm vitaliidm enabled auto-merge (squash) August 6, 2025 10:29
@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 6, 2025

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/securitysolution-io-ts-alerting-types 125 87 -38

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 10.3MB 10.3MB +1.8KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 94.5KB 94.5KB +45.0B
Unknown metric groups

API count

id before after diff
@kbn/securitysolution-io-ts-alerting-types 147 109 -38

ESLint disabled in files

id before after diff
@kbn/securitysolution-io-ts-alerting-types 9 8 -1

Total ESLint disabled count

id before after diff
@kbn/securitysolution-io-ts-alerting-types 9 8 -1

History

cc @vitaliidm

@vitaliidm vitaliidm merged commit 36d8883 into elastic:main Aug 6, 2025
12 checks passed
gergoabraham pushed a commit to gergoabraham/kibana that referenced this pull request Aug 7, 2025
…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>
@wildemat wildemat mentioned this pull request Aug 7, 2025
10 tasks
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Aug 18, 2025
…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>
vitaliidm added a commit that referenced this pull request Aug 28, 2025
…H operator (#232996)

## Summary

 - follow up for #227084
 - enables FF `doesNotMatchForIndicatorMatchRuleEnabled`
qn895 pushed a commit to qn895/kibana that referenced this pull request Sep 2, 2025
…H operator (elastic#232996)

## Summary

 - follow up for elastic#227084
 - enables FF `doesNotMatchForIndicatorMatchRuleEnabled`
vitaliidm added a commit that referenced this pull request Jan 27, 2026
…imental feature flag (#249550)

## Summary

- removes Indicator match **DOES NOT MATCH** experimental feature
flag`doesNotMatchForIndicatorMatchRuleEnabled` and corresponding feature
tour
- feature flag was introduced in
#227084
vitaliidm added a commit to vitaliidm/kibana that referenced this pull request Jan 29, 2026
…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
vitaliidm added a commit that referenced this pull request Jan 30, 2026
… 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-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting ci:cloud-redeploy Always create a new Cloud deployment release_note:feature Makes this part of the condensed release notes Team:Detection Engine Security Solution Detection Engine Area Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.