Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43357,7 +43357,6 @@
"xpack.securitySolution.siemMigrations.rules.panel.expand": "Développer la migration de règles",
"xpack.securitySolution.siemMigrations.rules.panel.help.readDocs": "Lire les documents d'IA",
"xpack.securitySolution.siemMigrations.rules.panel.help.readMore": "Pour en savoir plus sur nos traductions assistées par IA et les autres fonctionnalités. {readMore}",
"xpack.securitySolution.siemMigrations.rules.panel.migrationTitle": "Migration de règles SIEM #{number}",
"xpack.securitySolution.siemMigrations.rules.panel.progress.badge": "Traduction en cours",
"xpack.securitySolution.siemMigrations.rules.panel.progress.description": "Traitement de la migration de {totalRules} règles.",
"xpack.securitySolution.siemMigrations.rules.panel.progress.preparing": "Préparation de l'environnement pour la traduction alimentée par l'IA.",
Expand All @@ -43375,7 +43374,6 @@
"xpack.securitySolution.siemMigrations.rules.panel.uploadMissingResources": "Chargez les macros et les consultations manquantes.",
"xpack.securitySolution.siemMigrations.rules.retryFailedRulesFailDescription": "Échec du re-traitement des règles de migration",
"xpack.securitySolution.siemMigrations.rules.selectionOption.arealLabel": "Sélectionnez une migration",
"xpack.securitySolution.siemMigrations.rules.selectionOption.title": "Migration de règle SIEM {optionIndex}",
"xpack.securitySolution.siemMigrations.rules.service.createRuleError": "Échec du chargement du fichier de règles",
"xpack.securitySolution.siemMigrations.rules.service.createRuleSuccess.description": "{rules} règles téléchargées",
"xpack.securitySolution.siemMigrations.rules.service.createRuleSuccess.title": "Migration de règle créée avec succès",
Expand Down Expand Up @@ -43489,7 +43487,6 @@
"xpack.securitySolution.siemMigrations.rulesService.noConnector.text": "Aucun connecteur par IA configuré. Sélectionnez un connecteur par IA pour lancer les traductions de règles.",
"xpack.securitySolution.siemMigrations.rulesService.noConnector.title": "Aucun connecteur configuré.",
"xpack.securitySolution.siemMigrations.rulesService.polling.successLinkText": "Rendez-vous aux règles traduites",
"xpack.securitySolution.siemMigrations.rulesService.polling.successText": "La traduction de la migration de règles SIEM #{number} est terminée. Les résultats ont été ajoutés à une page dédiée.",
"xpack.securitySolution.siemMigrations.rulesService.polling.successTitle": "Traduction de règles terminée.",
"xpack.securitySolution.siemMigrations.rulesService.pollingError": "Erreur lors de la récupération des migrations de règles",
"xpack.securitySolution.siemMigrations.service.capabilities.connectorsRead": "Gestion > Actions & connecteurs : Lire",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43328,7 +43328,6 @@
"xpack.securitySolution.siemMigrations.rules.panel.expand": "ルール移行を展開",
"xpack.securitySolution.siemMigrations.rules.panel.help.readDocs": "AIドキュメントを読む",
"xpack.securitySolution.siemMigrations.rules.panel.help.readMore": "AIを活用した翻訳やその他の機能の詳細についてお読みください。{readMore}",
"xpack.securitySolution.siemMigrations.rules.panel.migrationTitle": "SIEMルール移行#{number}",
"xpack.securitySolution.siemMigrations.rules.panel.progress.badge": "変換中",
"xpack.securitySolution.siemMigrations.rules.panel.progress.description": "{totalRules}ルールの移行を処理しています。",
"xpack.securitySolution.siemMigrations.rules.panel.progress.preparing": "AIを活用した変換の環境を準備しています。",
Expand All @@ -43346,7 +43345,6 @@
"xpack.securitySolution.siemMigrations.rules.panel.uploadMissingResources": "欠落しているマクロとルックアップをアップロード",
"xpack.securitySolution.siemMigrations.rules.retryFailedRulesFailDescription": "移行ルールを再処理できませんでした",
"xpack.securitySolution.siemMigrations.rules.selectionOption.arealLabel": "移行を選択",
"xpack.securitySolution.siemMigrations.rules.selectionOption.title": "SIEMルール移行{optionIndex}",
"xpack.securitySolution.siemMigrations.rules.service.createRuleError": "ルールファイルをアップロードできませんでした",
"xpack.securitySolution.siemMigrations.rules.service.createRuleSuccess.description": "{rules}ルールがアップロードされました",
"xpack.securitySolution.siemMigrations.rules.service.createRuleSuccess.title": "ルール移行が正常に作成されました",
Expand Down Expand Up @@ -43460,7 +43458,6 @@
"xpack.securitySolution.siemMigrations.rulesService.noConnector.text": "AIコネクターが構成されていませんルール変換を開始するには、AIコネクターを選択してください。",
"xpack.securitySolution.siemMigrations.rulesService.noConnector.title": "コネクターが構成されていません。",
"xpack.securitySolution.siemMigrations.rulesService.polling.successLinkText": "変換されたルールに移動",
"xpack.securitySolution.siemMigrations.rulesService.polling.successText": "SIEMルール移行#{number}の変換が完了しました。結果が専用ページに追加されました。",
"xpack.securitySolution.siemMigrations.rulesService.polling.successTitle": "ルール変換が完了しました。",
"xpack.securitySolution.siemMigrations.rulesService.pollingError": "ルール移行の取得エラー",
"xpack.securitySolution.siemMigrations.service.capabilities.connectorsRead": "管理 > アクションとコネクター:読み取り",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43399,7 +43399,6 @@
"xpack.securitySolution.siemMigrations.rules.panel.expand": "展开规则迁移",
"xpack.securitySolution.siemMigrations.rules.panel.help.readDocs": "阅读 AI 文档",
"xpack.securitySolution.siemMigrations.rules.panel.help.readMore": "阅读有关我们的 AI 驱动式转换和其他功能的更多信息。{readMore}",
"xpack.securitySolution.siemMigrations.rules.panel.migrationTitle": "SIEM 规则迁移 #{number}",
"xpack.securitySolution.siemMigrations.rules.panel.progress.badge": "正在进行转换",
"xpack.securitySolution.siemMigrations.rules.panel.progress.description": "正在处理 {totalRules} 个规则的迁移。",
"xpack.securitySolution.siemMigrations.rules.panel.progress.preparing": "正在准备环境以进行 AI 驱动式转换。",
Expand All @@ -43417,7 +43416,6 @@
"xpack.securitySolution.siemMigrations.rules.panel.uploadMissingResources": "上传缺失的宏和查找。",
"xpack.securitySolution.siemMigrations.rules.retryFailedRulesFailDescription": "无法重新处理迁移规则",
"xpack.securitySolution.siemMigrations.rules.selectionOption.arealLabel": "选择迁移",
"xpack.securitySolution.siemMigrations.rules.selectionOption.title": "SIEM 规则迁移 {optionIndex}",
"xpack.securitySolution.siemMigrations.rules.service.createRuleError": "无法上传规则文件",
"xpack.securitySolution.siemMigrations.rules.service.createRuleSuccess.description": "{rules} 个规则已上传",
"xpack.securitySolution.siemMigrations.rules.service.createRuleSuccess.title": "已成功创建规则迁移",
Expand Down Expand Up @@ -43531,7 +43529,6 @@
"xpack.securitySolution.siemMigrations.rulesService.noConnector.text": "未配置 AI 连接器。选择 AI 连接器以开始规则转换。",
"xpack.securitySolution.siemMigrations.rulesService.noConnector.title": "未配置连接器。",
"xpack.securitySolution.siemMigrations.rulesService.polling.successLinkText": "前往已转换规则",
"xpack.securitySolution.siemMigrations.rulesService.polling.successText": "SIEM 规则迁移 #{number} 已完成转换。结果已添加到专用页面。",
"xpack.securitySolution.siemMigrations.rulesService.polling.successTitle": "规则转换完成。",
"xpack.securitySolution.siemMigrations.rulesService.pollingError": "获取规则迁移时出错",
"xpack.securitySolution.siemMigrations.service.capabilities.connectorsRead": "管理 > 操作和连接器:读取",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ import type {
ResolveTimelineResponse,
} from './timeline/resolve_timeline/resolve_timeline_route.gen';
import type {
CreateRuleMigrationRequestBodyInput,
CreateRuleMigrationResponse,
CreateRuleMigrationRulesRequestParamsInput,
CreateRuleMigrationRulesRequestBodyInput,
Expand Down Expand Up @@ -413,7 +414,7 @@ import type {
StopRuleMigrationRequestParamsInput,
StopRuleMigrationResponse,
UpdateRuleMigrationRequestParamsInput,
UpdateRuleMigrationResponse,
UpdateRuleMigrationRequestBodyInput,
UpdateRuleMigrationRulesRequestParamsInput,
UpdateRuleMigrationRulesRequestBodyInput,
UpdateRuleMigrationRulesResponse,
Expand Down Expand Up @@ -815,7 +816,7 @@ For detailed information on Kibana actions and alerting, and additional API call
/**
* Creates a new rule migration and returns the corresponding migration_id
*/
async createRuleMigration() {
async createRuleMigration(props: CreateRuleMigrationProps) {
this.log.info(`${new Date().toISOString()} Calling API CreateRuleMigration`);
return this.kbnClient
.request<CreateRuleMigrationResponse>({
Expand All @@ -824,6 +825,7 @@ For detailed information on Kibana actions and alerting, and additional API call
[ELASTIC_HTTP_VERSION_HEADER]: '1',
},
method: 'PUT',
body: props.body,
})
.catch(catchAxiosErrorFormatAndThrow);
}
Expand Down Expand Up @@ -2560,12 +2562,13 @@ The difference between the `id` and `rule_id` is that the `id` is a unique rule
async updateRuleMigration(props: UpdateRuleMigrationProps) {
this.log.info(`${new Date().toISOString()} Calling API UpdateRuleMigration`);
return this.kbnClient
.request<UpdateRuleMigrationResponse>({
.request({
path: replaceParams('/internal/siem_migrations/rules/{migration_id}', props.params),
headers: {
[ELASTIC_HTTP_VERSION_HEADER]: '1',
},
method: 'PATCH',
body: props.body,
})
.catch(catchAxiosErrorFormatAndThrow);
}
Expand Down Expand Up @@ -2671,6 +2674,9 @@ export interface CreateAssetCriticalityRecordProps {
export interface CreateRuleProps {
body: CreateRuleRequestBodyInput;
}
export interface CreateRuleMigrationProps {
body: CreateRuleMigrationRequestBodyInput;
}
export interface CreateRuleMigrationRulesProps {
params: CreateRuleMigrationRulesRequestParamsInput;
body: CreateRuleMigrationRulesRequestBodyInput;
Expand Down Expand Up @@ -2941,6 +2947,7 @@ export interface UpdateRuleProps {
}
export interface UpdateRuleMigrationProps {
params: UpdateRuleMigrationRequestParamsInput;
body: UpdateRuleMigrationRequestBodyInput;
}
export interface UpdateRuleMigrationRulesProps {
params: UpdateRuleMigrationRulesRequestParamsInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ import { RelatedIntegration } from '../../../../api/detection_engine/model/rule_
import { NonEmptyString } from '../../../../api/model/primitives.gen';
import { LangSmithOptions } from '../../common.gen';

export type CreateRuleMigrationRequestBody = z.infer<typeof CreateRuleMigrationRequestBody>;
export const CreateRuleMigrationRequestBody = z.object({
/**
* The rule migration name
*/
name: NonEmptyString,
});
export type CreateRuleMigrationRequestBodyInput = z.input<typeof CreateRuleMigrationRequestBody>;

export type CreateRuleMigrationResponse = z.infer<typeof CreateRuleMigrationResponse>;
export const CreateRuleMigrationResponse = z.object({
/**
Expand Down Expand Up @@ -313,8 +322,14 @@ export type UpdateRuleMigrationRequestParamsInput = z.input<
typeof UpdateRuleMigrationRequestParams
>;

export type UpdateRuleMigrationResponse = z.infer<typeof UpdateRuleMigrationResponse>;
export const UpdateRuleMigrationResponse = RuleMigration;
export type UpdateRuleMigrationRequestBody = z.infer<typeof UpdateRuleMigrationRequestBody>;
export const UpdateRuleMigrationRequestBody = z.object({
/**
* The rule migration name
*/
name: NonEmptyString,
});
export type UpdateRuleMigrationRequestBodyInput = z.input<typeof UpdateRuleMigrationRequestBody>;

export type UpdateRuleMigrationRulesRequestParams = z.infer<
typeof UpdateRuleMigrationRulesRequestParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,37 @@ paths:
/internal/siem_migrations/rules:
put:
summary: Creates a new rule migration
operationId: "CreateRuleMigration"
operationId: 'CreateRuleMigration'
x-codegen-enabled: true
x-internal: true
description: Creates a new rule migration and returns the corresponding migration_id
tags:
- SIEM Rule Migrations
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- name
properties:
name:
description: The rule migration name
$ref: '../../../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
responses:
200:
description: The migration was created successfully and migrationId is returned
description: The migration was created successfully and migrationId, name is returned
content:
application/json:
schema:
type: object
required:
- migration_id
properties:
migration_id:
description: The migration id created.
$ref: '../../../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
migration_id:
description: The migration id created.
$ref: '../../../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'

## Specific rule migration APIs
/internal/siem_migrations/rules/{migration_id}:
Expand All @@ -101,13 +113,21 @@ paths:
schema:
description: The migration id to start
$ref: '../../../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- name
properties:
name:
description: The rule migration name
$ref: '../../../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
responses:
200:
description: Indicates rules migrations have been updated correctly.
content:
application/json:
schema:
$ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigration'
404:
description: Indicates the migration id was not found.
get:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ export const RuleMigration = z
* The rule migration id
*/
id: NonEmptyString,
/**
* The rule migration name
*/
name: NonEmptyString,
})
.merge(RuleMigrationData);

Expand Down Expand Up @@ -328,6 +332,10 @@ export const RuleMigrationTaskStats = z.object({
* The migration id
*/
id: NonEmptyString,
/**
* The migration name
*/
name: NonEmptyString,
/**
* Indicates if the migration task status.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ components:
- type: object
required:
- id
- name
properties:
id:
description: The rule migration id
$ref: '../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
name:
description: The rule migration name
$ref: '../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
- $ref: '#/components/schemas/RuleMigrationData'

RuleMigrationData:
Expand Down Expand Up @@ -207,6 +211,7 @@ components:
description: The rule migration task stats object.
required:
- id
- name
- status
- rules
- created_at
Expand All @@ -215,6 +220,9 @@ components:
id:
description: The migration id
$ref: '../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
name:
description: The migration name
$ref: '../../../common/api/model/primitives.schema.yaml#/components/schemas/NonEmptyString'
status:
description: Indicates if the migration task status.
$ref: '#/components/schemas/RuleMigrationTaskStatus'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export * from './use_is_open_state';
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 { renderHook, act } from '@testing-library/react';
import { useIsOpenState } from './use_is_open_state';

describe('useIsOpenState', () => {
let initialState: boolean;
let onOpen: jest.Mock;
let onClose: jest.Mock;
let onToggle: jest.Mock;

beforeEach(() => {
initialState = false;
onOpen = jest.fn();
onClose = jest.fn();
onToggle = jest.fn();
});

it('should initialize with the correct state', () => {
const { result } = renderHook(() => useIsOpenState(initialState));
expect(result.current.isOpen).toBe(initialState);
});

it('should call onOpen when opening', () => {
const { result } = renderHook(() => useIsOpenState(initialState, { onOpen }));
act(() => {
result.current.open();
});
expect(result.current.isOpen).toBe(true);
expect(onOpen).toHaveBeenCalled();
});

it('should call onClose when closing', () => {
const { result } = renderHook(() => useIsOpenState(true, { onClose }));
act(() => {
result.current.close();
});
expect(result.current.isOpen).toBe(false);
expect(onClose).toHaveBeenCalled();
});

it('should call onToggle when toggling', () => {
const { result } = renderHook(() => useIsOpenState(true, { onToggle }));
act(() => {
result.current.toggle();
});
expect(result.current.isOpen).toBe(false);
expect(onToggle).toHaveBeenCalledTimes(1);

act(() => {
result.current.toggle();
});
expect(result.current.isOpen).toBe(true);
expect(onToggle).toHaveBeenCalledTimes(2);
});
});
Loading