forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Detections][BUG] ES|QL rule execution error when …
…source document has a non-ECS compliant sub-field with data under event field (elastic#187384) (elastic#187549) ## Summary Ticket elastic#187384 These changes fix the error on saving the alert > An error occurred during rule execution: message: "[1:6778] failed to parse field [kibana.alert.original_event.action] of type [keyword] in document with id '027b925ae2799635a0dee97a6aa9d58dc87d9771'." which happens due to not stripping non-ECS compliant sub-fields of the `event.action` field. See the main ticket for steps to reproduce the issue.
- Loading branch information
Showing
5 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...y_solution/server/lib/detection_engine/rule_types/factories/utils/build_bulk_body.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { sampleDocWithNonEcsCompliantFields } from '../../__mocks__/es_results'; | ||
import { buildBulkBody } from './build_bulk_body'; | ||
import { getCompleteRuleMock, getEsqlRuleParams } from '../../../rule_schema/mocks'; | ||
import { ruleExecutionLogMock } from '../../../rule_monitoring/mocks'; | ||
|
||
const SPACE_ID = 'space'; | ||
const publicBaseUrl = 'testKibanaBasePath.com'; | ||
const alertUuid = 'test-uuid'; | ||
const docId = 'd5e8eb51-a6a0-456d-8a15-4b79bfec3d71'; | ||
const ruleExecutionLogger = ruleExecutionLogMock.forExecutors.create(); | ||
|
||
describe('buildBulkBody', () => { | ||
test('should strip non-ECS compliant sub-fields of `event.action` field', () => { | ||
const doc = sampleDocWithNonEcsCompliantFields(docId, { | ||
'event.action': 'process', | ||
'event.action.keyword': 'process', | ||
}); | ||
const completeRule = getCompleteRuleMock(getEsqlRuleParams()); | ||
const buildReasonMessageStub = jest.fn(); | ||
const alert = buildBulkBody( | ||
SPACE_ID, | ||
completeRule, | ||
doc, | ||
'missingFields', | ||
[], | ||
true, | ||
buildReasonMessageStub, | ||
[], | ||
undefined, | ||
ruleExecutionLogger, | ||
alertUuid, | ||
publicBaseUrl | ||
); | ||
|
||
expect(alert['kibana.alert.original_event.action']).toEqual('process'); | ||
expect(alert['kibana.alert.original_event.action.keyword']).toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters