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.
[Rules migration][UI] Basic rule migrations UI (elastic#10820) (elast…
…ic#200978) ## Summary [Internal link](elastic/security-team#10820) to the feature details This is a very first version of the SIEM rules migrations UI functionality. The main goal is to setup and agree on a folder structure where the feature gonna live. Tests covering feature will follow in a separate PR (see [internal link](elastic/security-team#11232) for more details). The code follows the structure of prebuilt rules feature https://github.com/elastic/kibana/tree/main/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table and hidden behind `siemMigrationsEnabled` feature flag. ### Key UI changes * New "SIEM Rules Migrations." rules management sub-page * Navigation between different "finished" migrations * InMemory table with all the translations within the selected migration * Translation details preview flyout with `Translation` and `Overview` tabs * User cannot modify translations via UI ### Testing locally Enable the flag ``` xpack.securitySolution.enableExperimental: ['siemMigrationsEnabled'] ``` ### Screenshot https://github.com/user-attachments/assets/a5a7e777-c5f8-40b4-be1d-1bd07a2729ac
- Loading branch information
Showing
42 changed files
with
1,705 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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.