-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SECURITY SOLUTION] exclude cloud alias index from our query (#81551)
* exclude cloud alias index * only exclude cloud alias when logs-* is there
- Loading branch information
Showing
2 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
x-pack/plugins/security_solution/public/common/store/sourcerer/selectors.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,70 @@ | ||
/* | ||
* 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 { cloneDeep } from 'lodash/fp'; | ||
import { mockGlobalState } from '../../mock'; | ||
import { SourcererScopeName } from './model'; | ||
import { getSourcererScopeSelector } from './selectors'; | ||
|
||
describe('Sourcerer selectors', () => { | ||
describe('getSourcererScopeSelector', () => { | ||
it('Should exclude elastic cloud alias when selected patterns include "logs-*" as an alias', () => { | ||
const mapStateToProps = getSourcererScopeSelector(); | ||
expect( | ||
mapStateToProps(mockGlobalState, SourcererScopeName.default).selectedPatterns | ||
).toEqual([ | ||
'apm-*-transaction*', | ||
'auditbeat-*', | ||
'endgame-*', | ||
'filebeat-*', | ||
'logs-*', | ||
'packetbeat-*', | ||
'winlogbeat-*', | ||
'-*elastic-cloud-logs-*', | ||
]); | ||
}); | ||
|
||
it('Should NOT exclude elastic cloud alias when selected patterns does NOT include "logs-*" as an alias', () => { | ||
const mapStateToProps = getSourcererScopeSelector(); | ||
const myMockGlobalState = cloneDeep(mockGlobalState); | ||
myMockGlobalState.sourcerer.sourcererScopes.default.selectedPatterns = myMockGlobalState.sourcerer.sourcererScopes.default.selectedPatterns.filter( | ||
(index) => !index.includes('logs-*') | ||
); | ||
expect( | ||
mapStateToProps(myMockGlobalState, SourcererScopeName.default).selectedPatterns | ||
).toEqual([ | ||
'apm-*-transaction*', | ||
'auditbeat-*', | ||
'endgame-*', | ||
'filebeat-*', | ||
'packetbeat-*', | ||
'winlogbeat-*', | ||
]); | ||
}); | ||
|
||
it('Should NOT exclude elastic cloud alias when selected patterns include "logs-endpoint.event-*" as an alias', () => { | ||
const mapStateToProps = getSourcererScopeSelector(); | ||
const myMockGlobalState = cloneDeep(mockGlobalState); | ||
myMockGlobalState.sourcerer.sourcererScopes.default.selectedPatterns = [ | ||
...myMockGlobalState.sourcerer.sourcererScopes.default.selectedPatterns.filter( | ||
(index) => !index.includes('logs-*') | ||
), | ||
'logs-endpoint.event-*', | ||
]; | ||
expect( | ||
mapStateToProps(myMockGlobalState, SourcererScopeName.default).selectedPatterns | ||
).toEqual([ | ||
'apm-*-transaction*', | ||
'auditbeat-*', | ||
'endgame-*', | ||
'filebeat-*', | ||
'packetbeat-*', | ||
'winlogbeat-*', | ||
'logs-endpoint.event-*', | ||
]); | ||
}); | ||
}); | ||
}); |
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