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] - Security solution ES|QL configurable via advanc…
…ed setting (elastic#181616) ## Summary This PR links the ESQL functionality in security solution to the `discover:enableESQL` advanced setting. The advanced setting will only be present in ESS, but not serverless The way this should work to maintain parity with the rest of Kibana such as discover and stack rules: - By default ES|QL will be enabled across all Kibana - When the ES|QL advanced setting is disabled: - Timeline - ES|QL tab should not be accessible on any newly created timelines - Existing Timelines with an ES|QL query should still have the tab accessible - Rules - New ES|QL rule should not be available to be created in the *Rule Creation* workflow - Existing ES|QL rules should still run and be able to be edited **Timeline Demo Video:** https://github.com/elastic/kibana/assets/17211684/d5429be9-de37-43e2-882d-687b3371beb4 **Rules Demo Video:** https://github.com/elastic/kibana/assets/17211684/7df2fd11-bd2b-4e50-ad97-b6e1d0f7867a --------- Co-authored-by: Vitalii Dmyterko <[email protected]> Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
187f22a
commit 963391e
Showing
13 changed files
with
168 additions
and
56 deletions.
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
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
8 changes: 0 additions & 8 deletions
8
x-pack/plugins/security_solution/public/common/components/hooks/index.ts
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...plugins/security_solution/public/common/components/hooks/use_is_esql_rule_type_enabled.ts
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/security_solution/public/common/hooks/esql/use_esql_availability.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,28 @@ | ||
/* | ||
* 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 { useMemo } from 'react'; | ||
import { useKibana } from '../../lib/kibana'; | ||
import { useIsExperimentalFeatureEnabled } from '../use_experimental_features'; | ||
|
||
export const useEsqlAvailability = () => { | ||
const { uiSettings } = useKibana().services; | ||
const isEsqlAdvancedSettingEnabled = uiSettings?.get('discover:enableESQL'); | ||
const isEsqlRuleTypeEnabled = | ||
!useIsExperimentalFeatureEnabled('esqlRulesDisabled') && isEsqlAdvancedSettingEnabled; | ||
const isESQLTabInTimelineEnabled = | ||
!useIsExperimentalFeatureEnabled('timelineEsqlTabDisabled') && isEsqlAdvancedSettingEnabled; | ||
|
||
return useMemo( | ||
() => ({ | ||
isEsqlAdvancedSettingEnabled, | ||
isEsqlRuleTypeEnabled, | ||
isESQLTabInTimelineEnabled, | ||
}), | ||
[isESQLTabInTimelineEnabled, isEsqlAdvancedSettingEnabled, isEsqlRuleTypeEnabled] | ||
); | ||
}; |
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
82 changes: 82 additions & 0 deletions
82
x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.test.tsx
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,82 @@ | ||
/* | ||
* 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 React from 'react'; | ||
|
||
import { createMockStore, mockGlobalState } from '../../../../common/mock'; | ||
import { TestProviders } from '../../../../common/mock/test_providers'; | ||
|
||
import { TabsContent } from '.'; | ||
import { TimelineId, TimelineTabs } from '../../../../../common/types/timeline'; | ||
import { TimelineType } from '../../../../../common/api/timeline'; | ||
import { useEsqlAvailability } from '../../../../common/hooks/esql/use_esql_availability'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
|
||
jest.mock('../../../../common/hooks/esql/use_esql_availability', () => ({ | ||
useEsqlAvailability: jest.fn().mockReturnValue({ | ||
isESQLTabInTimelineEnabled: true, | ||
}), | ||
})); | ||
|
||
const useEsqlAvailabilityMock = useEsqlAvailability as jest.Mock; | ||
|
||
describe('Timeline', () => { | ||
describe('esql tab', () => { | ||
const esqlTabSubj = `timelineTabs-${TimelineTabs.esql}`; | ||
const defaultProps = { | ||
renderCellValue: () => {}, | ||
rowRenderers: [], | ||
timelineId: TimelineId.test, | ||
timelineType: TimelineType.default, | ||
timelineDescription: '', | ||
}; | ||
|
||
it('should show the esql tab', () => { | ||
render( | ||
<TestProviders> | ||
<TabsContent {...defaultProps} /> | ||
</TestProviders> | ||
); | ||
expect(screen.getByTestId(esqlTabSubj)).toBeVisible(); | ||
}); | ||
|
||
it('should not show the esql tab when the advanced setting is disabled', async () => { | ||
useEsqlAvailabilityMock.mockReturnValue({ | ||
isESQLTabInTimelineEnabled: false, | ||
}); | ||
render( | ||
<TestProviders> | ||
<TabsContent {...defaultProps} /> | ||
</TestProviders> | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.queryByTestId(esqlTabSubj)).toBeNull(); | ||
}); | ||
}); | ||
|
||
it('should show the esql tab when the advanced setting is disabled, but an esql query is present', async () => { | ||
useEsqlAvailabilityMock.mockReturnValue({ | ||
isESQLTabInTimelineEnabled: false, | ||
}); | ||
|
||
const stateWithSavedSearchId = structuredClone(mockGlobalState); | ||
stateWithSavedSearchId.timeline.timelineById[TimelineId.test].savedSearchId = 'test-id'; | ||
const mockStore = createMockStore(stateWithSavedSearchId); | ||
|
||
render( | ||
<TestProviders store={mockStore}> | ||
<TabsContent {...defaultProps} /> | ||
</TestProviders> | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.queryByTestId(esqlTabSubj)).toBeVisible(); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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