Skip to content

Commit

Permalink
[SIEM migrations][Onboarding] Add support for topics in the onboardin…
Browse files Browse the repository at this point in the history
…g page (#201411)

## Summary

part of elastic/security-team#10667

Added support for multiple topics to the onboarding hub. Including:

- Added group buttons to the header to select the Topic. It appears only
if more than one topic is available.
- Topics are configurable and can have required license, and
capabilities, just like cards.
- Added required experimental flags property to topic and card
configurations.
- Implemented selected topic persistence in the URL and localStorage,
extending the existing feature for the selected card.
- Siem migrations topic implemented with only connectors card (more
cards will come later)
- Connectors card shared components extracted to _common/connectors_

> [!NOTE]
> This feature needs `siemMigrationsEnabled` experimental flag enabled
to work. Otherwise only the default topic will be available and the
topic selector won't be displayed.

https://github.com/user-attachments/assets/1ec54911-71b9-4001-aeb4-a30564a83ca7

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit 02e9ee4)
  • Loading branch information
semd committed Nov 30, 2024
1 parent a3a5a73 commit a78b801
Show file tree
Hide file tree
Showing 88 changed files with 1,599 additions and 663 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export const SIEM_RULE_MIGRATION_STOP_PATH = `${SIEM_RULE_MIGRATION_PATH}/stop`

export const SIEM_RULE_MIGRATION_RESOURCES_PATH = `${SIEM_RULE_MIGRATION_PATH}/resources` as const;

export enum SiemMigrationTaskStatus {
READY = 'ready',
RUNNING = 'running',
STOPPED = 'stopped',
FINISHED = 'finished',
}

export enum SiemMigrationStatus {
PENDING = 'pending',
PROCESSING = 'processing',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,7 @@ export type UpsertRuleMigrationResourcesRequestParamsInput = z.input<
export type UpsertRuleMigrationResourcesRequestBody = z.infer<
typeof UpsertRuleMigrationResourcesRequestBody
>;
export const UpsertRuleMigrationResourcesRequestBody = z.array(
RuleMigrationResourceData.merge(
z.object({
/**
* The rule resource migration id
*/
id: NonEmptyString,
})
)
);
export const UpsertRuleMigrationResourcesRequestBody = z.array(RuleMigrationResourceData);
export type UpsertRuleMigrationResourcesRequestBodyInput = z.input<
typeof UpsertRuleMigrationResourcesRequestBody
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ paths:
summary: Creates a new rule migration
operationId: CreateRuleMigration
x-codegen-enabled: true
x-internal: true
description: Creates a new SIEM rules migration using the original vendor rules provided
tags:
- SIEM Rule Migrations
Expand Down Expand Up @@ -39,6 +40,7 @@ paths:
summary: Updates rules migrations
operationId: UpdateRuleMigration
x-codegen-enabled: true
x-internal: true
description: Updates rules migrations attributes
tags:
- SIEM Rule Migrations
Expand Down Expand Up @@ -84,6 +86,7 @@ paths:
summary: Retrieves the stats for all rule migrations
operationId: GetAllStatsRuleMigration
x-codegen-enabled: true
x-internal: true
description: Retrieves the rule migrations stats for all migrations stored in the system
tags:
- SIEM Rule Migrations
Expand All @@ -104,6 +107,7 @@ paths:
summary: Retrieves all the rules of a migration
operationId: GetRuleMigration
x-codegen-enabled: true
x-internal: true
description: Retrieves the rule documents stored in the system given the rule migration id
tags:
- SIEM Rule Migrations
Expand Down Expand Up @@ -131,6 +135,7 @@ paths:
summary: Starts a rule migration
operationId: StartRuleMigration
x-codegen-enabled: true
x-internal: true
description: Starts a SIEM rules migration using the migration id provided
tags:
- SIEM Rule Migrations
Expand Down Expand Up @@ -175,6 +180,7 @@ paths:
summary: Gets a rule migration task stats
operationId: GetRuleMigrationStats
x-codegen-enabled: true
x-internal: true
description: Retrieves the stats of a SIEM rules migration using the migration id provided
tags:
- SIEM Rule Migrations
Expand All @@ -200,6 +206,7 @@ paths:
summary: Stops an existing rule migration
operationId: StopRuleMigration
x-codegen-enabled: true
x-internal: true
description: Stops a running SIEM rules migration using the migration id provided
tags:
- SIEM Rule Migrations
Expand Down Expand Up @@ -233,6 +240,7 @@ paths:
summary: Creates or updates rule migration resources for a migration
operationId: UpsertRuleMigrationResources
x-codegen-enabled: true
x-internal: true
description: Creates or updates resources for an existing SIEM rules migration
tags:
- SIEM Rule Migrations
Expand All @@ -251,15 +259,7 @@ paths:
schema:
type: array
items:
allOf:
- $ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigrationResourceData'
- type: object
required:
- id
properties:
id:
description: The rule resource migration id
$ref: '../../common.schema.yaml#/components/schemas/NonEmptyString'
$ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigrationResourceData'
responses:
200:
description: Indicates migration resources have been created or updated correctly.
Expand All @@ -278,6 +278,7 @@ paths:
summary: Gets rule migration resources for a migration
operationId: GetRuleMigrationResources
x-codegen-enabled: true
x-internal: true
description: Retrieves resources for an existing SIEM rules migration
tags:
- SIEM Rule Migrations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export type RuleMigrationTranslationResultEnum = typeof RuleMigrationTranslation
export const RuleMigrationTranslationResultEnum = RuleMigrationTranslationResult.enum;

/**
* The status of the rule migration process.
* The status of each rule migration.
*/
export type RuleMigrationStatus = z.infer<typeof RuleMigrationStatus>;
export const RuleMigrationStatus = z.enum(['pending', 'processing', 'completed', 'failed']);
Expand Down Expand Up @@ -182,6 +182,14 @@ export const RuleMigration = z
})
.merge(RuleMigrationData);

/**
* The status of the migration task.
*/
export type RuleMigrationTaskStatus = z.infer<typeof RuleMigrationTaskStatus>;
export const RuleMigrationTaskStatus = z.enum(['ready', 'running', 'stopped', 'finished']);
export type RuleMigrationTaskStatusEnum = typeof RuleMigrationTaskStatus.enum;
export const RuleMigrationTaskStatusEnum = RuleMigrationTaskStatus.enum;

/**
* The rule migration task stats object.
*/
Expand All @@ -194,7 +202,7 @@ export const RuleMigrationTaskStats = z.object({
/**
* Indicates if the migration task status.
*/
status: z.enum(['ready', 'running', 'stopped', 'finished']),
status: RuleMigrationTaskStatus,
/**
* The rules migration stats.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,8 @@ components:
description: The migration id
$ref: './common.schema.yaml#/components/schemas/NonEmptyString'
status:
type: string
description: Indicates if the migration task status.
enum:
- ready
- running
- stopped
- finished
$ref: '#/components/schemas/RuleMigrationTaskStatus'
rules:
type: object
description: The rules migration stats.
Expand Down Expand Up @@ -189,6 +184,15 @@ components:
type: string
description: The moment of the last update.

RuleMigrationTaskStatus:
type: string
description: The status of the migration task.
enum: # should match SiemMigrationTaskStatus enum at ../constants.ts
- ready
- running
- stopped
- finished

RuleMigrationTranslationResult:
type: string
description: The rule translation result.
Expand All @@ -199,7 +203,7 @@ components:

RuleMigrationStatus:
type: string
description: The status of the rule migration process.
description: The status of each rule migration.
enum: # should match SiemMigrationsStatus enum at ../constants.ts
- pending
- processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,17 @@
export const mockReportCardOpen = jest.fn();
export const mockReportCardComplete = jest.fn();
export const mockReportCardLinkClicked = jest.fn();

export const telemetry = {
reportCardOpen: mockReportCardOpen,
reportCardComplete: mockReportCardComplete,
reportCardLinkClicked: mockReportCardLinkClicked,
};
export const mockTelemetry = jest.fn(() => telemetry);

export const onboardingContext = {
spaceId: 'default',
telemetry: mockTelemetry(),
config: new Map(),
};
export const mockOnboardingContext = jest.fn(() => onboardingContext);
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,8 @@
*/

import type { OnboardingContextValue } from '../onboarding_context';
import {
mockReportCardOpen,
mockReportCardComplete,
mockReportCardLinkClicked,
} from './onboarding_context_mocks';
import { mockOnboardingContext } from './mocks';

export const useOnboardingContext = (): OnboardingContextValue => {
return {
spaceId: 'default',
reportCardOpen: mockReportCardOpen,
reportCardComplete: mockReportCardComplete,
reportCardLinkClicked: mockReportCardLinkClicked,
};
return mockOnboardingContext();
};
Loading

0 comments on commit a78b801

Please sign in to comment.