Skip to content

Commit

Permalink
[8.x] [Rules migration] Post merge feedback followups (#202815) (#202975
Browse files Browse the repository at this point in the history
)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Rules migration] Post merge feedback followups
(#202815)](#202815)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Ievgen
Sorokopud","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T16:06:10Z","message":"[Rules
migration] Post merge feedback followups (#202815)\n\n##
Summary\r\n\r\nThese are the followup updated to address feedback from
my previous PRs:\r\n\r\n* Make sure to use descriptive names specific to
the
`siem_migrations`\r\nsubdomain\r\n([comment](https://github.com/elastic/kibana/pull/200978#pullrequestreview-2454582368)):\r\n\r\n>
Make sure you use descriptive names specific to the
siem_migrations\r\nsubdomain. Names like RulesPage, RulesTable,
useRulesColumns etc are way\r\ntoo generic and conflict with the rule
management terminology, which\r\nwould make code search more
difficult.\r\n\r\n\r\n* Export the memo component directly
everywhere\r\n([comment](https://github.com/elastic/kibana/pull/201597#discussion_r1858069127)):\r\n\r\n>
Could we export the memo component directly everywhere? It's
shorter\r\nand it makes it easier to find the references in the
IDE.\r\n\r\n\r\n* Use one hook to access APIs instead of
two\r\n([comment](https://github.com/elastic/kibana/pull/202494#discussion_r1867967135)):\r\n\r\n>
I see that for every API request we have to implement 2
separate\r\nhooks. Why don't we add error handling to the same hook that
does the\r\nuseQuery? so we have everything in one hook. Or is there a
reason to\r\nhave them
separate?","sha":"4d8f7111d0f8c330aab2c8347cf6d131570ff665","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"],"title":"[Rules
migration] Post merge feedback
followups","number":202815,"url":"https://github.com/elastic/kibana/pull/202815","mergeCommit":{"message":"[Rules
migration] Post merge feedback followups (#202815)\n\n##
Summary\r\n\r\nThese are the followup updated to address feedback from
my previous PRs:\r\n\r\n* Make sure to use descriptive names specific to
the
`siem_migrations`\r\nsubdomain\r\n([comment](https://github.com/elastic/kibana/pull/200978#pullrequestreview-2454582368)):\r\n\r\n>
Make sure you use descriptive names specific to the
siem_migrations\r\nsubdomain. Names like RulesPage, RulesTable,
useRulesColumns etc are way\r\ntoo generic and conflict with the rule
management terminology, which\r\nwould make code search more
difficult.\r\n\r\n\r\n* Export the memo component directly
everywhere\r\n([comment](https://github.com/elastic/kibana/pull/201597#discussion_r1858069127)):\r\n\r\n>
Could we export the memo component directly everywhere? It's
shorter\r\nand it makes it easier to find the references in the
IDE.\r\n\r\n\r\n* Use one hook to access APIs instead of
two\r\n([comment](https://github.com/elastic/kibana/pull/202494#discussion_r1867967135)):\r\n\r\n>
I see that for every API request we have to implement 2
separate\r\nhooks. Why don't we add error handling to the same hook that
does the\r\nuseQuery? so we have everything in one hook. Or is there a
reason to\r\nhave them
separate?","sha":"4d8f7111d0f8c330aab2c8347cf6d131570ff665"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202815","number":202815,"mergeCommit":{"message":"[Rules
migration] Post merge feedback followups (#202815)\n\n##
Summary\r\n\r\nThese are the followup updated to address feedback from
my previous PRs:\r\n\r\n* Make sure to use descriptive names specific to
the
`siem_migrations`\r\nsubdomain\r\n([comment](https://github.com/elastic/kibana/pull/200978#pullrequestreview-2454582368)):\r\n\r\n>
Make sure you use descriptive names specific to the
siem_migrations\r\nsubdomain. Names like RulesPage, RulesTable,
useRulesColumns etc are way\r\ntoo generic and conflict with the rule
management terminology, which\r\nwould make code search more
difficult.\r\n\r\n\r\n* Export the memo component directly
everywhere\r\n([comment](https://github.com/elastic/kibana/pull/201597#discussion_r1858069127)):\r\n\r\n>
Could we export the memo component directly everywhere? It's
shorter\r\nand it makes it easier to find the references in the
IDE.\r\n\r\n\r\n* Use one hook to access APIs instead of
two\r\n([comment](https://github.com/elastic/kibana/pull/202494#discussion_r1867967135)):\r\n\r\n>
I see that for every API request we have to implement 2
separate\r\nhooks. Why don't we add error handling to the same hook that
does the\r\nuseQuery? so we have everything in one hook. Or is there a
reason to\r\nhave them
separate?","sha":"4d8f7111d0f8c330aab2c8347cf6d131570ff665"}}]}]
BACKPORT-->

Co-authored-by: Ievgen Sorokopud <[email protected]>
  • Loading branch information
kibanamachine and e40pud authored Dec 4, 2024
1 parent a639b82 commit 4f3b63b
Show file tree
Hide file tree
Showing 35 changed files with 730 additions and 848 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ export enum SiemMigrationRuleTranslationResult {

export const DEFAULT_TRANSLATION_RISK_SCORE = 21;
export const DEFAULT_TRANSLATION_SEVERITY: Severity = 'low';

export const DEFAULT_TRANSLATION_FIELDS = {
risk_score: DEFAULT_TRANSLATION_RISK_SCORE,
severity: DEFAULT_TRANSLATION_SEVERITY,
from: 'now-360s',
to: 'now',
interval: '5m',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ import { Routes, Route } from '@kbn/shared-ux-router';

import type { SecuritySubPluginRoutes } from '../app/types';
import { SIEM_MIGRATIONS_RULES_PATH, SecurityPageName } from '../../common/constants';
import { RulesPage } from './rules/pages';
import { MigrationRulesPage } from './rules/pages';
import { PluginTemplateWrapper } from '../common/components/plugin_template_wrapper';
import { SecurityRoutePageWrapper } from '../common/components/security_route_page_wrapper';

export const RulesRoutes = () => {
export const SiemMigrationsRoutes = () => {
return (
<PluginTemplateWrapper>
<SecurityRoutePageWrapper pageName={SecurityPageName.siemMigrationsRules}>
<Routes>
<Route path={`${SIEM_MIGRATIONS_RULES_PATH}/:migrationId?`} component={RulesPage} />
<Route
path={`${SIEM_MIGRATIONS_RULES_PATH}/:migrationId?`}
component={MigrationRulesPage}
/>
</Routes>
</SecurityRoutePageWrapper>
</PluginTemplateWrapper>
Expand All @@ -29,6 +32,6 @@ export const RulesRoutes = () => {
export const routes: SecuritySubPluginRoutes = [
{
path: SIEM_MIGRATIONS_RULES_PATH,
component: RulesRoutes,
component: SiemMigrationsRoutes,
},
];

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import type {
InstallMigrationRulesResponse,
StartRuleMigrationRequestBody,
} from '../../../../common/siem_migrations/model/api/rules/rule_migration.gen';
import type { InstallTranslatedRulesProps, InstallRulesProps } from '../types';

/**
* Retrieves the stats for all the existing migrations, aggregated by `migration_id`.
Expand Down Expand Up @@ -134,7 +133,11 @@ export const installMigrationRules = async ({
migrationId,
ids,
signal,
}: InstallRulesProps): Promise<InstallMigrationRulesResponse> => {
}: {
migrationId: string;
ids: string[];
signal?: AbortSignal;
}): Promise<InstallMigrationRulesResponse> => {
return KibanaServices.get().http.fetch<InstallMigrationRulesResponse>(
replaceParams(SIEM_RULE_MIGRATION_INSTALL_PATH, { migration_id: migrationId }),
{
Expand All @@ -149,7 +152,10 @@ export const installMigrationRules = async ({
export const installTranslatedMigrationRules = async ({
migrationId,
signal,
}: InstallTranslatedRulesProps): Promise<InstallTranslatedMigrationRulesResponse> => {
}: {
migrationId: string;
signal?: AbortSignal;
}): Promise<InstallTranslatedMigrationRulesResponse> => {
return KibanaServices.get().http.fetch<InstallTranslatedMigrationRulesResponse>(
replaceParams(SIEM_RULE_MIGRATION_INSTALL_TRANSLATED_PATH, { migration_id: migrationId }),
{
Expand Down
Loading

0 comments on commit 4f3b63b

Please sign in to comment.