-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution][Detection Engine] fixes ES|QL ECS multifiefields issue #167769
[Security Solution][Detection Engine] fixes ES|QL ECS multifiefields issue #167769
Conversation
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
@vitaliidm to explicitly validate that this will fix the issue described in https://github.com/elastic/sdh-security-team/issues/736, we can add a regression unit test: diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/factories/utils/strip_non_ecs_fields.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/factories/utils/strip_non_ecs_fields.test.ts
index 9c10a317ee1..fe66c695f63 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/factories/utils/strip_non_ecs_fields.test.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/factories/utils/strip_non_ecs_fields.test.ts
@@ -71,6 +71,26 @@ describe('stripNonEcsFields', () => {
]);
});
+ describe('with an object field that exists in the alerts mapping but not our local ECS definition', () => {
+ it('strips that field if it is supplied as a keyword', () => {
+ const { result, removed } = stripNonEcsFields({
+ device: 'test',
+ message: 'test message',
+ });
+
+ expect(result).toEqual({
+ message: 'test message',
+ });
+
+ expect(removed).toEqual([
+ {
+ key: 'device',
+ value: 'test',
+ },
+ ]);
+ });
+ });
+
describe('array fields', () => {
it('should not strip arrays of objects when an object is expected', () => {
const { result, removed } = stripNonEcsFields({
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me!
I had a few questions about unit tests changing, but the integration tests answered my questions. Thanks!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @vitaliidm |
…issue (elastic#167769) ## Summary - fixes elastic/security-team#7741 by replacing `ecsMap` from hardcoded `@kbn/rule-registry-plugin` to actual mapping for alerts indices from `@kbn/alerts-as-data-utils` - when converting ES|QL row table results to object, `null` values skipped, since its results consists of all existing mappings in searched indices, if fields in query are not filtered ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit 4ebe45d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…fields issue (#167769) (#168206) # Backport This will backport the following commits from `main` to `8.11`: - [[Security Solution][Detection Engine] fixes ES|QL ECS multifiefields issue (#167769)](#167769) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Vitalii Dmyterko","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-06T10:59:41Z","message":"[Security Solution][Detection Engine] fixes ES|QL ECS multifiefields issue (#167769)\n\n## Summary\r\n\r\n- fixes elastic/security-team#7741 by\r\nreplacing `ecsMap` from hardcoded `@kbn/rule-registry-plugin` to actual\r\nmapping for alerts indices from `@kbn/alerts-as-data-utils`\r\n- when converting ES|QL row table results to object, `null` values\r\nskipped, since its results consists of all existing mappings in searched\r\nindices, if fields in query are not filtered\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"4ebe45d77ee46c2b502c87aee0f89b73f0d3e40f","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Detections and Resp","Team: SecuritySolution","backport:prev-minor","Team:Detection Engine","v8.11.0","v8.12.0"],"number":167769,"url":"https://github.com/elastic/kibana/pull/167769","mergeCommit":{"message":"[Security Solution][Detection Engine] fixes ES|QL ECS multifiefields issue (#167769)\n\n## Summary\r\n\r\n- fixes elastic/security-team#7741 by\r\nreplacing `ecsMap` from hardcoded `@kbn/rule-registry-plugin` to actual\r\nmapping for alerts indices from `@kbn/alerts-as-data-utils`\r\n- when converting ES|QL row table results to object, `null` values\r\nskipped, since its results consists of all existing mappings in searched\r\nindices, if fields in query are not filtered\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"4ebe45d77ee46c2b502c87aee0f89b73f0d3e40f"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/167769","number":167769,"mergeCommit":{"message":"[Security Solution][Detection Engine] fixes ES|QL ECS multifiefields issue (#167769)\n\n## Summary\r\n\r\n- fixes elastic/security-team#7741 by\r\nreplacing `ecsMap` from hardcoded `@kbn/rule-registry-plugin` to actual\r\nmapping for alerts indices from `@kbn/alerts-as-data-utils`\r\n- when converting ES|QL row table results to object, `null` values\r\nskipped, since its results consists of all existing mappings in searched\r\nindices, if fields in query are not filtered\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"4ebe45d77ee46c2b502c87aee0f89b73f0d3e40f"}}]}] BACKPORT--> Co-authored-by: Vitalii Dmyterko <[email protected]>
…issue (elastic#167769) ## Summary - fixes elastic/security-team#7741 by replacing `ecsMap` from hardcoded `@kbn/rule-registry-plugin` to actual mapping for alerts indices from `@kbn/alerts-as-data-utils` - when converting ES|QL row table results to object, `null` values skipped, since its results consists of all existing mappings in searched indices, if fields in query are not filtered ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Summary
ecsMap
from hardcoded@kbn/rule-registry-plugin
to actual mapping for alerts indices from@kbn/alerts-as-data-utils
null
values skipped, since its results consists of all existing mappings in searched indices, if fields in query are not filteredChecklist
Delete any items that are not applicable to this PR.