-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skip query of detections page when we do not have .siem-signals index (…
…#74580) (#74609) * skip query of detections page when we do not have .siem-signals index * review I
- Loading branch information
Showing
3 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/security_solution/public/timelines/containers/helpers.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,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { TimelineId } from '../../../common/types/timeline'; | ||
import { skipQueryForDetectionsPage } from './helpers'; | ||
|
||
describe('skipQueryForDetectionsPage', () => { | ||
test('Make sure to NOT skip the query when it is not a timeline from a detection pages', () => { | ||
expect(skipQueryForDetectionsPage(TimelineId.active, ['auditbeat-*', 'filebeat-*'])).toBe( | ||
false | ||
); | ||
expect( | ||
skipQueryForDetectionsPage(TimelineId.hostsPageEvents, ['auditbeat-*', 'filebeat-*']) | ||
).toBe(false); | ||
expect( | ||
skipQueryForDetectionsPage(TimelineId.hostsPageExternalAlerts, ['auditbeat-*', 'filebeat-*']) | ||
).toBe(false); | ||
expect( | ||
skipQueryForDetectionsPage(TimelineId.networkPageExternalAlerts, [ | ||
'auditbeat-*', | ||
'filebeat-*', | ||
]) | ||
).toBe(false); | ||
}); | ||
|
||
test('Make sure to SKIP the query when it is a timeline from a detection pages without the siem-signals', () => { | ||
expect( | ||
skipQueryForDetectionsPage(TimelineId.detectionsPage, ['auditbeat-*', 'filebeat-*']) | ||
).toBe(true); | ||
expect( | ||
skipQueryForDetectionsPage(TimelineId.detectionsRulesDetailsPage, [ | ||
'auditbeat-*', | ||
'filebeat-*', | ||
]) | ||
).toBe(true); | ||
}); | ||
|
||
test('Make sure to NOT skip the query when it is a timeline from a detection pages with the siem-signals', () => { | ||
expect( | ||
skipQueryForDetectionsPage(TimelineId.detectionsPage, [ | ||
'auditbeat-*', | ||
'.siem-signals-rainbow-butterfly', | ||
]) | ||
).toBe(false); | ||
expect( | ||
skipQueryForDetectionsPage(TimelineId.detectionsRulesDetailsPage, [ | ||
'.siem-signals-rainbow-butterfly', | ||
]) | ||
).toBe(false); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/security_solution/public/timelines/containers/helpers.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,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { TimelineId } from '../../../common/types/timeline'; | ||
|
||
export const detectionsTimelineIds = [ | ||
TimelineId.detectionsPage, | ||
TimelineId.detectionsRulesDetailsPage, | ||
]; | ||
|
||
export const skipQueryForDetectionsPage = (id: string, defaultIndex: string[]) => | ||
id != null && | ||
detectionsTimelineIds.some((timelineId) => timelineId === id) && | ||
!defaultIndex.some((di) => di.toLowerCase().startsWith('.siem-signals')); |
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