Skip to content

Commit

Permalink
[Rules migration] Post merge feedback followups (elastic#202815)
Browse files Browse the repository at this point in the history
## Summary

These are the followup updated to address feedback from my previous PRs:

* Make sure to use descriptive names specific to the `siem_migrations`
subdomain
([comment](elastic#200978 (review))):

> Make sure you use descriptive names specific to the siem_migrations
subdomain. Names like RulesPage, RulesTable, useRulesColumns etc are way
too generic and conflict with the rule management terminology, which
would make code search more difficult.


* Export the memo component directly everywhere
([comment](elastic#201597 (comment))):

> Could we export the memo component directly everywhere? It's shorter
and it makes it easier to find the references in the IDE.


* Use one hook to access APIs instead of two
([comment](elastic#202494 (comment))):

> I see that for every API request we have to implement 2 separate
hooks. Why don't we add error handling to the same hook that does the
useQuery? so we have everything in one hook. Or is there a reason to
have them separate?
  • Loading branch information
e40pud authored and SoniaSanzV committed Dec 9, 2024
1 parent abb61c9 commit 0ed26d3
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 0ed26d3

Please sign in to comment.