Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0fb249c
create resources data stream
semd Nov 6, 2024
e670f22
add migration resources data client
semd Nov 7, 2024
52df6cf
Merge remote-tracking branch 'upstream/main' into 10653/siem_migratio…
semd Nov 8, 2024
78f80a3
resource retrieval implemented
semd Nov 9, 2024
b37628d
new index-adaper package
semd Nov 9, 2024
da18c38
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Nov 9, 2024
45a358b
fix packages configs
semd Nov 9, 2024
98c1aa3
Merge remote-tracking branch 'refs/remotes/origin/index_adapter_base_…
semd Nov 9, 2024
8453062
rollback ds adapter changes
semd Nov 9, 2024
df7061e
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Nov 9, 2024
76f8f5b
Merge branch 'index_adapter_base_package' into 10653/siem_migrations/…
semd Nov 9, 2024
9ceac8f
Merge remote-tracking branch 'upstream/main' into 10653/siem_migratio…
semd Nov 9, 2024
78053f8
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Nov 9, 2024
d57c791
improve createIndex
semd Nov 9, 2024
3fe56b7
Merge branch 'index_adapter_base_package' into 10653/siem_migrations/…
semd Nov 9, 2024
71bcd58
use index insted of ds
semd Nov 9, 2024
3bae810
fix type
semd Nov 9, 2024
6aa4beb
Merge branch 'index_adapter_base_package' into 10653/siem_migrations/…
semd Nov 9, 2024
47c6321
SRP for createIndex function
semd Nov 10, 2024
af817a8
Merge branch 'index_adapter_base_package' into 10653/siem_migrations/…
semd Nov 10, 2024
92cc378
adapt createIndex
semd Nov 10, 2024
9816c28
fix tests
semd Nov 10, 2024
6db7180
solve conflicts
semd Nov 11, 2024
b1d9499
rollback dependency
semd Nov 11, 2024
51d2318
conflict solved
semd Nov 11, 2024
81dbabe
Merge branch 'index_adapter_base_package' into 10653/siem_migrations/…
semd Nov 11, 2024
3e1d973
improve query translation by inlining macros
semd Nov 11, 2024
ebe2f99
import from package entry file
semd Nov 11, 2024
57409f1
Merge branch 'index_adapter_base_package' into 10653/siem_migrations/…
semd Nov 11, 2024
af521d2
simplify data clients
semd Nov 13, 2024
d50a05c
merge main
semd Nov 13, 2024
b5aba7e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 13, 2024
b96ab2c
[CI] Auto-commit changed files from 'yarn openapi:generate'
kibanamachine Nov 13, 2024
a777870
add mocks and tests
semd Nov 13, 2024
d12b4da
Merge remote-tracking branch 'upstream/main' into 10653/siem_migratio…
semd Nov 13, 2024
553ffa3
Merge remote-tracking branch 'refs/remotes/origin/10653/siem_migratio…
semd Nov 13, 2024
bcf4968
update mocks
semd Nov 13, 2024
654b377
fix tests
semd Nov 13, 2024
dd1f7a1
add missing mocks
semd Nov 13, 2024
4c0dcb6
installation error handling moved up
semd Nov 14, 2024
232be91
Merge remote-tracking branch 'upstream/main' into 10653/siem_migratio…
semd Nov 14, 2024
cb37dfc
Merge branch 'main' into 10653/siem_migrations/add_macros_support
elasticmachine Nov 14, 2024
faa38c7
address comments
semd Nov 18, 2024
08bd32f
Merge remote-tracking branch 'upstream/main' into 10653/siem_migratio…
semd Nov 18, 2024
186699b
Merge remote-tracking branch 'refs/remotes/origin/10653/siem_migratio…
semd Nov 18, 2024
61aae02
Merge branch 'main' into 10653/siem_migrations/add_macros_support
michaelolo24 Nov 18, 2024
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 @@ -356,14 +356,20 @@ import type {
GetAllStatsRuleMigrationResponse,
GetRuleMigrationRequestParamsInput,
GetRuleMigrationResponse,
GetRuleMigrationResourcesRequestQueryInput,
GetRuleMigrationResourcesRequestParamsInput,
GetRuleMigrationResourcesResponse,
GetRuleMigrationStatsRequestParamsInput,
GetRuleMigrationStatsResponse,
StartRuleMigrationRequestParamsInput,
StartRuleMigrationRequestBodyInput,
StartRuleMigrationResponse,
StopRuleMigrationRequestParamsInput,
StopRuleMigrationResponse,
} from '../siem_migrations/model/api/rules/rules_migration.gen';
UpsertRuleMigrationResourcesRequestParamsInput,
UpsertRuleMigrationResourcesRequestBodyInput,
UpsertRuleMigrationResourcesResponse,
} from '../siem_migrations/model/api/rules/rule_migration.gen';

export interface ClientOptions {
kbnClient: KbnClient;
Expand Down Expand Up @@ -1405,6 +1411,26 @@ finalize it.
})
.catch(catchAxiosErrorFormatAndThrow);
}
/**
* Retrieves resources for an existing SIEM rules migration
*/
async getRuleMigrationResources(props: GetRuleMigrationResourcesProps) {
this.log.info(`${new Date().toISOString()} Calling API GetRuleMigrationResources`);
return this.kbnClient
.request<GetRuleMigrationResourcesResponse>({
path: replaceParams(
'/internal/siem_migrations/rules/{migration_id}/resources',
props.params
),
headers: {
[ELASTIC_HTTP_VERSION_HEADER]: '1',
},
method: 'GET',

query: props.query,
})
.catch(catchAxiosErrorFormatAndThrow);
}
/**
* Retrieves the stats of a SIEM rules migration using the migration id provided
*/
Expand Down Expand Up @@ -2056,6 +2082,25 @@ detection engine rules.
})
.catch(catchAxiosErrorFormatAndThrow);
}
/**
* Creates or updates resources for an existing SIEM rules migration
*/
async upsertRuleMigrationResources(props: UpsertRuleMigrationResourcesProps) {
this.log.info(`${new Date().toISOString()} Calling API UpsertRuleMigrationResources`);
return this.kbnClient
.request<UpsertRuleMigrationResourcesResponse>({
path: replaceParams(
'/internal/siem_migrations/rules/{migration_id}/resources',
props.params
),
headers: {
[ELASTIC_HTTP_VERSION_HEADER]: '1',
},
method: 'POST',
body: props.body,
})
.catch(catchAxiosErrorFormatAndThrow);
}
}

export interface AlertsMigrationCleanupProps {
Expand Down Expand Up @@ -2221,6 +2266,10 @@ export interface GetRuleExecutionResultsProps {
export interface GetRuleMigrationProps {
params: GetRuleMigrationRequestParamsInput;
}
export interface GetRuleMigrationResourcesProps {
query: GetRuleMigrationResourcesRequestQueryInput;
params: GetRuleMigrationResourcesRequestParamsInput;
}
export interface GetRuleMigrationStatsProps {
params: GetRuleMigrationStatsRequestParamsInput;
}
Expand Down Expand Up @@ -2322,3 +2371,7 @@ export interface UpdateRuleProps {
export interface UploadAssetCriticalityRecordsProps {
attachment: FormData;
}
export interface UpsertRuleMigrationResourcesProps {
params: UpsertRuleMigrationResourcesRequestParamsInput;
body: UpsertRuleMigrationResourcesRequestBodyInput;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export const SIEM_MIGRATIONS_PATH = '/internal/siem_migrations' as const;
export const SIEM_RULE_MIGRATIONS_PATH = `${SIEM_MIGRATIONS_PATH}/rules` as const;

export const SIEM_RULE_MIGRATIONS_ALL_STATS_PATH = `${SIEM_RULE_MIGRATIONS_PATH}/stats` as const;
export const SIEM_RULE_MIGRATIONS_GET_PATH = `${SIEM_RULE_MIGRATIONS_PATH}/{migration_id}` as const;
export const SIEM_RULE_MIGRATIONS_START_PATH =
`${SIEM_RULE_MIGRATIONS_PATH}/{migration_id}/start` as const;
export const SIEM_RULE_MIGRATIONS_STATS_PATH =
`${SIEM_RULE_MIGRATIONS_PATH}/{migration_id}/stats` as const;
export const SIEM_RULE_MIGRATIONS_STOP_PATH =
`${SIEM_RULE_MIGRATIONS_PATH}/{migration_id}/stop` as const;
export const SIEM_RULE_MIGRATION_PATH = `${SIEM_RULE_MIGRATIONS_PATH}/{migration_id}` as const;
export const SIEM_RULE_MIGRATION_START_PATH = `${SIEM_RULE_MIGRATION_PATH}/start` as const;
export const SIEM_RULE_MIGRATION_RETRY_PATH = `${SIEM_RULE_MIGRATION_PATH}/retry` as const;
export const SIEM_RULE_MIGRATION_STATS_PATH = `${SIEM_RULE_MIGRATION_PATH}/stats` as const;
export const SIEM_RULE_MIGRATION_STOP_PATH = `${SIEM_RULE_MIGRATION_PATH}/stop` as const;

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

export enum SiemMigrationStatus {
PENDING = 'pending',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Common SIEM Migrations Attributes
* title: SIEM Rule Migrations API common components
* version: not applicable
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Common SIEM Migrations Attributes
title: SIEM Rule Migrations API common components
version: 'not applicable'
paths: {}
components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: SIEM Rules Migration API endpoint
* title: SIEM Rules Migration API
* version: 1
*/

import { z } from '@kbn/zod';
import { ArrayFromString } from '@kbn/zod-helpers';

import {
OriginalRule,
RuleMigrationAllTaskStats,
RuleMigration,
RuleMigrationTaskStats,
RuleMigrationResourceData,
RuleMigrationResourceType,
RuleMigrationResource,
} from '../../rule_migration.gen';
import { ConnectorId, LangSmithOptions } from '../common.gen';

Expand All @@ -47,6 +51,29 @@ export type GetRuleMigrationRequestParamsInput = z.input<typeof GetRuleMigration

export type GetRuleMigrationResponse = z.infer<typeof GetRuleMigrationResponse>;
export const GetRuleMigrationResponse = z.array(RuleMigration);
export type GetRuleMigrationResourcesRequestQuery = z.infer<
typeof GetRuleMigrationResourcesRequestQuery
>;
export const GetRuleMigrationResourcesRequestQuery = z.object({
type: RuleMigrationResourceType.optional(),
names: ArrayFromString(z.string()).optional(),
});
export type GetRuleMigrationResourcesRequestQueryInput = z.input<
typeof GetRuleMigrationResourcesRequestQuery
>;

export type GetRuleMigrationResourcesRequestParams = z.infer<
typeof GetRuleMigrationResourcesRequestParams
>;
export const GetRuleMigrationResourcesRequestParams = z.object({
migration_id: z.string(),
});
export type GetRuleMigrationResourcesRequestParamsInput = z.input<
typeof GetRuleMigrationResourcesRequestParams
>;

export type GetRuleMigrationResourcesResponse = z.infer<typeof GetRuleMigrationResourcesResponse>;
export const GetRuleMigrationResourcesResponse = z.array(RuleMigrationResource);

export type GetRuleMigrationStatsRequestParams = z.infer<typeof GetRuleMigrationStatsRequestParams>;
export const GetRuleMigrationStatsRequestParams = z.object({
Expand Down Expand Up @@ -93,3 +120,31 @@ export const StopRuleMigrationResponse = z.object({
*/
stopped: z.boolean(),
});

export type UpsertRuleMigrationResourcesRequestParams = z.infer<
typeof UpsertRuleMigrationResourcesRequestParams
>;
export const UpsertRuleMigrationResourcesRequestParams = z.object({
migration_id: z.string(),
});
export type UpsertRuleMigrationResourcesRequestParamsInput = z.input<
typeof UpsertRuleMigrationResourcesRequestParams
>;

export type UpsertRuleMigrationResourcesRequestBody = z.infer<
typeof UpsertRuleMigrationResourcesRequestBody
>;
export const UpsertRuleMigrationResourcesRequestBody = z.array(RuleMigrationResourceData);
export type UpsertRuleMigrationResourcesRequestBodyInput = z.input<
typeof UpsertRuleMigrationResourcesRequestBody
>;

export type UpsertRuleMigrationResourcesResponse = z.infer<
typeof UpsertRuleMigrationResourcesResponse
>;
export const UpsertRuleMigrationResourcesResponse = z.object({
/**
* The request has been processed correctly.
*/
acknowledged: z.boolean(),
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
openapi: 3.0.3
info:
title: SIEM Rules Migration API endpoint
title: SIEM Rules Migration API
version: '1'
paths:

# Rule migrations APIs

/internal/siem_migrations/rules:
post:
summary: Creates a new rule migration
Expand Down Expand Up @@ -49,6 +52,8 @@ paths:
schema:
$ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigrationAllTaskStats'

## Specific rule migration APIs

/internal/siem_migrations/rules/{migration_id}:
get:
summary: Retrieves all the rules of a migration
Expand Down Expand Up @@ -175,3 +180,81 @@ paths:
description: Indicates the migration has been stopped.
204:
description: Indicates the migration id was not found running.

# Rule migration resources APIs

/internal/siem_migrations/rules/{migration_id}/resources:
post:
summary: Creates or updates rule migration resources for a migration
operationId: UpsertRuleMigrationResources
x-codegen-enabled: true
description: Creates or updates resources for an existing SIEM rules migration
tags:
- SIEM Rule Migrations
- Resources
parameters:
- name: migration_id
in: path
required: true
schema:
type: string
description: The migration id to attach the resources
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigrationResourceData'
responses:
200:
description: Indicates migration resources have been created or updated correctly.
content:
application/json:
schema:
type: object
required:
- acknowledged
properties:
acknowledged:
type: boolean
description: The request has been processed correctly.

get:
summary: Gets rule migration resources for a migration
operationId: GetRuleMigrationResources
x-codegen-enabled: true
description: Retrieves resources for an existing SIEM rules migration
tags:
- SIEM Rule Migrations
- Resources
parameters:
- name: migration_id
in: path
required: true
schema:
type: string
description: The migration id to attach the resources
- name: type
in: query
required: false
schema:
$ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigrationResourceType'
- name: names
in: query
required: false
schema:
type: array
description: The names of the resource to retrieve
items:
type: string
responses:
200:
description: Indicates migration resources have been retrieved correctly
content:
application/json:
schema:
type: array
items:
$ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigrationResource'
Loading