-
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.
Browse files
Browse the repository at this point in the history
… (#201545) # Backport This will backport the following commits from `main` to `8.x`: - [[Rules migration][UI] Basic rule migrations UI (#10820) (#200978)](#200978) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-22T14:48:14Z","message":"[Rules migration][UI] Basic rule migrations UI (#10820) (#200978)\n\n## Summary\r\n\r\n[Internal link](https://github.com/elastic/security-team/issues/10820)\r\nto the feature details\r\n\r\nThis is a very first version of the SIEM rules migrations UI\r\nfunctionality. The main goal is to setup and agree on a folder structure\r\nwhere the feature gonna live. Tests covering feature will follow in a\r\nseparate PR (see [internal\r\nlink](elastic/security-team#11232) for more\r\ndetails).\r\n\r\nThe code follows the structure of prebuilt rules feature\r\nhttps://github.com/elastic/kibana/tree/main/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table\r\nand hidden behind `siemMigrationsEnabled` feature flag.\r\n\r\n### Key UI changes\r\n\r\n* New \"SIEM Rules Migrations.\" rules management sub-page\r\n* Navigation between different \"finished\" migrations\r\n* InMemory table with all the translations within the selected migration\r\n* Translation details preview flyout with `Translation` and `Overview`\r\ntabs\r\n* User cannot modify translations via UI\r\n\r\n### Testing locally\r\n\r\nEnable the flag\r\n\r\n```\r\nxpack.securitySolution.enableExperimental: ['siemMigrationsEnabled']\r\n```\r\n### Screenshot\r\n\r\n\r\nhttps://github.com/user-attachments/assets/a5a7e777-c5f8-40b4-be1d-1bd07a2729ac","sha":"a627e011a892e9eaa7ec234b7a08fc5572801bbc","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Threat Hunting","Team: SecuritySolution","backport:prev-minor"],"number":200978,"url":"https://github.com/elastic/kibana/pull/200978","mergeCommit":{"message":"[Rules migration][UI] Basic rule migrations UI (#10820) (#200978)\n\n## Summary\r\n\r\n[Internal link](https://github.com/elastic/security-team/issues/10820)\r\nto the feature details\r\n\r\nThis is a very first version of the SIEM rules migrations UI\r\nfunctionality. The main goal is to setup and agree on a folder structure\r\nwhere the feature gonna live. Tests covering feature will follow in a\r\nseparate PR (see [internal\r\nlink](elastic/security-team#11232) for more\r\ndetails).\r\n\r\nThe code follows the structure of prebuilt rules feature\r\nhttps://github.com/elastic/kibana/tree/main/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table\r\nand hidden behind `siemMigrationsEnabled` feature flag.\r\n\r\n### Key UI changes\r\n\r\n* New \"SIEM Rules Migrations.\" rules management sub-page\r\n* Navigation between different \"finished\" migrations\r\n* InMemory table with all the translations within the selected migration\r\n* Translation details preview flyout with `Translation` and `Overview`\r\ntabs\r\n* User cannot modify translations via UI\r\n\r\n### Testing locally\r\n\r\nEnable the flag\r\n\r\n```\r\nxpack.securitySolution.enableExperimental: ['siemMigrationsEnabled']\r\n```\r\n### Screenshot\r\n\r\n\r\nhttps://github.com/user-attachments/assets/a5a7e777-c5f8-40b4-be1d-1bd07a2729ac","sha":"a627e011a892e9eaa7ec234b7a08fc5572801bbc"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200978","number":200978,"mergeCommit":{"message":"[Rules migration][UI] Basic rule migrations UI (#10820) (#200978)\n\n## Summary\r\n\r\n[Internal link](https://github.com/elastic/security-team/issues/10820)\r\nto the feature details\r\n\r\nThis is a very first version of the SIEM rules migrations UI\r\nfunctionality. The main goal is to setup and agree on a folder structure\r\nwhere the feature gonna live. Tests covering feature will follow in a\r\nseparate PR (see [internal\r\nlink](elastic/security-team#11232) for more\r\ndetails).\r\n\r\nThe code follows the structure of prebuilt rules feature\r\nhttps://github.com/elastic/kibana/tree/main/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table\r\nand hidden behind `siemMigrationsEnabled` feature flag.\r\n\r\n### Key UI changes\r\n\r\n* New \"SIEM Rules Migrations.\" rules management sub-page\r\n* Navigation between different \"finished\" migrations\r\n* InMemory table with all the translations within the selected migration\r\n* Translation details preview flyout with `Translation` and `Overview`\r\ntabs\r\n* User cannot modify translations via UI\r\n\r\n### Testing locally\r\n\r\nEnable the flag\r\n\r\n```\r\nxpack.securitySolution.enableExperimental: ['siemMigrationsEnabled']\r\n```\r\n### Screenshot\r\n\r\n\r\nhttps://github.com/user-attachments/assets/a5a7e777-c5f8-40b4-be1d-1bd07a2729ac","sha":"a627e011a892e9eaa7ec234b7a08fc5572801bbc"}}]}] BACKPORT-->
- Loading branch information
Showing
41 changed files
with
1,704 additions
and
0 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
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
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/security_solution/public/siem_migrations/index.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,19 @@ | ||
/* | ||
* 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 type { SecuritySubPlugin } from '../app/types'; | ||
import { routes } from './routes'; | ||
|
||
export class SiemMigrations { | ||
public setup() {} | ||
|
||
public start(isEnabled = false): SecuritySubPlugin { | ||
return { | ||
routes: isEnabled ? routes : [], | ||
}; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/security_solution/public/siem_migrations/jest.config.js
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,19 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../../../../..', | ||
roots: ['<rootDir>/x-pack/plugins/security_solution/public/siem_migrations'], | ||
coverageDirectory: | ||
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/siem_migrations', | ||
coverageReporters: ['text', 'html'], | ||
collectCoverageFrom: [ | ||
'<rootDir>/x-pack/plugins/security_solution/public/siem_migrations/**/*.{ts,tsx}', | ||
], | ||
moduleNameMapper: require('../../server/__mocks__/module_name_map'), | ||
}; |
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/security_solution/public/siem_migrations/links.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,35 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { | ||
SecurityPageName, | ||
SERVER_APP_ID, | ||
SIEM_MIGRATIONS_RULES_PATH, | ||
} from '../../common/constants'; | ||
import { SIEM_MIGRATIONS_RULES } from '../app/translations'; | ||
import type { LinkItem } from '../common/links/types'; | ||
import { IconConsoleCloud } from '../common/icons/console_cloud'; | ||
|
||
export const siemMigrationsLinks: LinkItem = { | ||
id: SecurityPageName.siemMigrationsRules, | ||
title: SIEM_MIGRATIONS_RULES, | ||
description: i18n.translate('xpack.securitySolution.appLinks.siemMigrationsRulesDescription', { | ||
defaultMessage: 'SIEM Rules Migrations.', | ||
}), | ||
landingIcon: IconConsoleCloud, | ||
path: SIEM_MIGRATIONS_RULES_PATH, | ||
capabilities: [`${SERVER_APP_ID}.show`], | ||
skipUrlState: true, | ||
hideTimeline: true, | ||
globalSearchKeywords: [ | ||
i18n.translate('xpack.securitySolution.appLinks.siemMigrationsRules', { | ||
defaultMessage: 'SIEM Rules Migrations', | ||
}), | ||
], | ||
experimentalKey: 'siemMigrationsEnabled', | ||
}; |
31 changes: 31 additions & 0 deletions
31
x-pack/plugins/security_solution/public/siem_migrations/routes.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,31 @@ | ||
/* | ||
* 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 type { SecuritySubPluginRoutes } from '../app/types'; | ||
import { SIEM_MIGRATIONS_RULES_PATH, SecurityPageName } from '../../common/constants'; | ||
import { RulesPage } from './rules/pages'; | ||
import { PluginTemplateWrapper } from '../common/components/plugin_template_wrapper'; | ||
import { SecurityRoutePageWrapper } from '../common/components/security_route_page_wrapper'; | ||
|
||
export const RulesRoutes = () => { | ||
return ( | ||
<PluginTemplateWrapper> | ||
<SecurityRoutePageWrapper pageName={SecurityPageName.siemMigrationsRules}> | ||
<RulesPage /> | ||
</SecurityRoutePageWrapper> | ||
</PluginTemplateWrapper> | ||
); | ||
}; | ||
|
||
export const routes: SecuritySubPluginRoutes = [ | ||
{ | ||
path: SIEM_MIGRATIONS_RULES_PATH, | ||
component: RulesRoutes, | ||
}, | ||
]; |
66 changes: 66 additions & 0 deletions
66
x-pack/plugins/security_solution/public/siem_migrations/rules/api/api.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,66 @@ | ||
/* | ||
* 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 { replaceParams } from '@kbn/openapi-common/shared'; | ||
|
||
import { KibanaServices } from '../../../common/lib/kibana'; | ||
|
||
import { | ||
SIEM_RULE_MIGRATIONS_ALL_STATS_PATH, | ||
SIEM_RULE_MIGRATION_PATH, | ||
} from '../../../../common/siem_migrations/constants'; | ||
import type { | ||
GetAllStatsRuleMigrationResponse, | ||
GetRuleMigrationResponse, | ||
} from '../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; | ||
|
||
/** | ||
* Retrieves the stats for all the existing migrations, aggregated by `migration_id`. | ||
* | ||
* @param signal AbortSignal for cancelling request | ||
* | ||
* @throws An error if response is not OK | ||
*/ | ||
export const getRuleMigrationsStatsAll = async ({ | ||
signal, | ||
}: { | ||
signal: AbortSignal | undefined; | ||
}): Promise<GetAllStatsRuleMigrationResponse> => { | ||
return KibanaServices.get().http.fetch<GetAllStatsRuleMigrationResponse>( | ||
SIEM_RULE_MIGRATIONS_ALL_STATS_PATH, | ||
{ | ||
method: 'GET', | ||
version: '1', | ||
signal, | ||
} | ||
); | ||
}; | ||
|
||
/** | ||
* Retrieves all the migration rule documents of a specific migration. | ||
* | ||
* @param migrationId `id` of the migration to retrieve rule documents for | ||
* @param signal AbortSignal for cancelling request | ||
* | ||
* @throws An error if response is not OK | ||
*/ | ||
export const getRuleMigrations = async ({ | ||
migrationId, | ||
signal, | ||
}: { | ||
migrationId: string; | ||
signal: AbortSignal | undefined; | ||
}): Promise<GetRuleMigrationResponse> => { | ||
return KibanaServices.get().http.fetch<GetRuleMigrationResponse>( | ||
replaceParams(SIEM_RULE_MIGRATION_PATH, { migration_id: migrationId }), | ||
{ | ||
method: 'GET', | ||
version: '1', | ||
signal, | ||
} | ||
); | ||
}; |
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/constants.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,13 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
const ONE_MINUTE = 60000; | ||
|
||
export const DEFAULT_QUERY_OPTIONS = { | ||
refetchIntervalInBackground: false, | ||
staleTime: ONE_MINUTE * 5, | ||
}; |
33 changes: 33 additions & 0 deletions
33
...ugins/security_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations.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,33 @@ | ||
/* | ||
* 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 type { UseQueryOptions } from '@tanstack/react-query'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { replaceParams } from '@kbn/openapi-common/shared'; | ||
import { DEFAULT_QUERY_OPTIONS } from './constants'; | ||
import { getRuleMigrations } from '../api'; | ||
import type { GetRuleMigrationResponse } from '../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; | ||
import { SIEM_RULE_MIGRATION_PATH } from '../../../../../common/siem_migrations/constants'; | ||
|
||
export const useGetRuleMigrationsQuery = ( | ||
migrationId: string, | ||
options?: UseQueryOptions<GetRuleMigrationResponse> | ||
) => { | ||
const SPECIFIC_MIGRATION_PATH = replaceParams(SIEM_RULE_MIGRATION_PATH, { | ||
migration_id: migrationId, | ||
}); | ||
return useQuery<GetRuleMigrationResponse>( | ||
['GET', SPECIFIC_MIGRATION_PATH], | ||
async ({ signal }) => { | ||
return getRuleMigrations({ migrationId, signal }); | ||
}, | ||
{ | ||
...DEFAULT_QUERY_OPTIONS, | ||
...options, | ||
} | ||
); | ||
}; |
30 changes: 30 additions & 0 deletions
30
...rity_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations_stats_all.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,30 @@ | ||
/* | ||
* 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 type { UseQueryOptions } from '@tanstack/react-query'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { DEFAULT_QUERY_OPTIONS } from './constants'; | ||
import { getRuleMigrationsStatsAll } from '../api'; | ||
import type { GetAllStatsRuleMigrationResponse } from '../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; | ||
import { SIEM_RULE_MIGRATIONS_ALL_STATS_PATH } from '../../../../../common/siem_migrations/constants'; | ||
|
||
export const GET_RULE_MIGRATIONS_STATS_ALL_QUERY_KEY = ['GET', SIEM_RULE_MIGRATIONS_ALL_STATS_PATH]; | ||
|
||
export const useGetRuleMigrationsStatsAllQuery = ( | ||
options?: UseQueryOptions<GetAllStatsRuleMigrationResponse> | ||
) => { | ||
return useQuery<GetAllStatsRuleMigrationResponse>( | ||
GET_RULE_MIGRATIONS_STATS_ALL_QUERY_KEY, | ||
async ({ signal }) => { | ||
return getRuleMigrationsStatsAll({ signal }); | ||
}, | ||
{ | ||
...DEFAULT_QUERY_OPTIONS, | ||
...options, | ||
} | ||
); | ||
}; |
Oops, something went wrong.