Skip to content

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 6 commits August 5, 2025 11:12
 - const threatListItem = getThreatListSearchResponseMock().hits.hits[0]; +const threatListItem = getThreatListItemMock();
…/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`
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