-
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.
[8.14] [Security Solution] - Security solution ES|QL configurable via…
… advanced setting (#181616) (#182517) # Backport This will backport the following commits from `main` to `8.14`: - [[Security Solution] - Security solution ES|QL configurable via advanced setting (#181616)](#181616) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Michael Olorunnisola","email":"michael.olorunnisola@elastic.co"},"sourceCommit":{"committedDate":"2024-05-02T17:02:46Z","message":"[Security Solution] - Security solution ES|QL configurable via advanced setting (#181616)\n\n## Summary\r\n\r\nThis PR links the ESQL functionality in security solution to the\r\n`discover:enableESQL` advanced setting. The advanced setting will only\r\nbe present in ESS, but not serverless\r\n\r\nThe way this should work to maintain parity with the rest of Kibana such\r\nas discover and stack rules:\r\n\r\n- By default ES|QL will be enabled across all Kibana\r\n- When the ES|QL advanced setting is disabled:\r\n - Timeline\r\n - ES|QL tab should not be accessible on any newly created timelines\r\n- Existing Timelines with an ES|QL query should still have the tab\r\naccessible\r\n - Rules\r\n- New ES|QL rule should not be available to be created in the *Rule\r\nCreation* workflow\r\n - Existing ES|QL rules should still run and be able to be edited\r\n\r\n\r\n\r\n**Timeline Demo Video:**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17211684/d5429be9-de37-43e2-882d-687b3371beb4\r\n\r\n**Rules Demo Video:**\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17211684/7df2fd11-bd2b-4e50-ad97-b6e1d0f7867a\r\n\r\n---------\r\n\r\nCo-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"963391ed0f7513c24c4827444feb971e460c53c0","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Threat Hunting:Investigations","ci:build-serverless-image","v8.14.0","v8.15.0"],"number":181616,"url":"https://github.com/elastic/kibana/pull/181616","mergeCommit":{"message":"[Security Solution] - Security solution ES|QL configurable via advanced setting (#181616)\n\n## Summary\r\n\r\nThis PR links the ESQL functionality in security solution to the\r\n`discover:enableESQL` advanced setting. The advanced setting will only\r\nbe present in ESS, but not serverless\r\n\r\nThe way this should work to maintain parity with the rest of Kibana such\r\nas discover and stack rules:\r\n\r\n- By default ES|QL will be enabled across all Kibana\r\n- When the ES|QL advanced setting is disabled:\r\n - Timeline\r\n - ES|QL tab should not be accessible on any newly created timelines\r\n- Existing Timelines with an ES|QL query should still have the tab\r\naccessible\r\n - Rules\r\n- New ES|QL rule should not be available to be created in the *Rule\r\nCreation* workflow\r\n - Existing ES|QL rules should still run and be able to be edited\r\n\r\n\r\n\r\n**Timeline Demo Video:**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17211684/d5429be9-de37-43e2-882d-687b3371beb4\r\n\r\n**Rules Demo Video:**\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17211684/7df2fd11-bd2b-4e50-ad97-b6e1d0f7867a\r\n\r\n---------\r\n\r\nCo-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"963391ed0f7513c24c4827444feb971e460c53c0"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","labelRegex":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/181616","number":181616,"mergeCommit":{"message":"[Security Solution] - Security solution ES|QL configurable via advanced setting (#181616)\n\n## Summary\r\n\r\nThis PR links the ESQL functionality in security solution to the\r\n`discover:enableESQL` advanced setting. The advanced setting will only\r\nbe present in ESS, but not serverless\r\n\r\nThe way this should work to maintain parity with the rest of Kibana such\r\nas discover and stack rules:\r\n\r\n- By default ES|QL will be enabled across all Kibana\r\n- When the ES|QL advanced setting is disabled:\r\n - Timeline\r\n - ES|QL tab should not be accessible on any newly created timelines\r\n- Existing Timelines with an ES|QL query should still have the tab\r\naccessible\r\n - Rules\r\n- New ES|QL rule should not be available to be created in the *Rule\r\nCreation* workflow\r\n - Existing ES|QL rules should still run and be able to be edited\r\n\r\n\r\n\r\n**Timeline Demo Video:**\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17211684/d5429be9-de37-43e2-882d-687b3371beb4\r\n\r\n**Rules Demo Video:**\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/17211684/7df2fd11-bd2b-4e50-ad97-b6e1d0f7867a\r\n\r\n---------\r\n\r\nCo-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"963391ed0f7513c24c4827444feb971e460c53c0"}}]}] BACKPORT--> --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
32fd7e4
commit d6fa87e
Showing
13 changed files
with
174 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.
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
/* | ||
* 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 { ENABLE_ESQL } from '@kbn/esql-utils'; | ||
import { useKibana } from '../../lib/kibana'; | ||
import { useIsExperimentalFeatureEnabled } from '../use_experimental_features'; | ||
|
||
/** | ||
* This hook combines the checks for esql availability within the security solution | ||
* If the advanced setting is disabled, ESQL will not be accessible in the UI for any new timeline or new rule creation workflows | ||
* The feature flags are still available to provide users an escape hatch in case of any esql related performance issues | ||
*/ | ||
export const useEsqlAvailability = () => { | ||
const { uiSettings } = useKibana().services; | ||
const isEsqlAdvancedSettingEnabled = uiSettings?.get(ENABLE_ESQL); | ||
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