[Security Solution] Align operationId and file names in OpenAPI specs (#189703)

**Relates to:** https://github.com/elastic/kibana/issues/183661 (internal)
**Relates to:** https://github.com/elastic/kibana/issues/183821 (internal)
**Relates to:** https://github.com/elastic/kibana/issues/183837 (internal)

## Summary

It addresses a discussion Rule Management team had on a tech time meeting whose outcome was usage of consistent  operationId, files and folder naming related to OpenAPI specs. For example use `Read` instead of `Get` since it gives better readability and matches with already used approach.

This PR aligns the naming and performs necessary renaming.
This commit is contained in:
Maxim Palenov 2024-08-05 18:11:54 +02:00 committed by GitHub
parent 8d550b0ad2
commit a4fc565333
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 333 additions and 333 deletions

View file

@ -16,11 +16,11 @@ export * from './delete_exception_list_item/delete_exception_list_item.gen';
export * from './delete_exception_list/delete_exception_list.gen';
export * from './duplicate_exception_list/duplicate_exception_list.gen';
export * from './export_exception_list/export_exception_list.gen';
export * from './find_exception_list_item/find_exception_list_item.gen';
export * from './find_exception_list/find_exception_list.gen';
export * from './find_exception_list_items/find_exception_list_items.gen';
export * from './find_exception_lists/find_exception_lists.gen';
export * from './import_exceptions/import_exceptions.gen';
export * from './read_exception_list_item/read_exception_list_item.gen';
export * from './read_exception_list/read_exception_list.gen';
export * from './summary_exception_list/summary_exception_list.gen';
export * from './read_exception_list_summary/read_exception_list_summary.gen';
export * from './update_exception_list_item/update_exception_list_item.gen';
export * from './update_exception_list/update_exception_list.gen';

View file

@ -11,7 +11,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get exception list API endpoint
* title: Read exception list API endpoint
* version: 2023-10-31
*/
@ -24,8 +24,8 @@ import {
ExceptionList,
} from '../model/exception_list_common.gen';
export type GetExceptionListRequestQuery = z.infer<typeof GetExceptionListRequestQuery>;
export const GetExceptionListRequestQuery = z.object({
export type ReadExceptionListRequestQuery = z.infer<typeof ReadExceptionListRequestQuery>;
export const ReadExceptionListRequestQuery = z.object({
/**
* Either `id` or `list_id` must be specified
*/
@ -36,7 +36,7 @@ export const GetExceptionListRequestQuery = z.object({
list_id: ExceptionListHumanId.optional(),
namespace_type: ExceptionNamespaceType.optional().default('single'),
});
export type GetExceptionListRequestQueryInput = z.input<typeof GetExceptionListRequestQuery>;
export type ReadExceptionListRequestQueryInput = z.input<typeof ReadExceptionListRequestQuery>;
export type GetExceptionListResponse = z.infer<typeof GetExceptionListResponse>;
export const GetExceptionListResponse = ExceptionList;
export type ReadExceptionListResponse = z.infer<typeof ReadExceptionListResponse>;
export const ReadExceptionListResponse = ExceptionList;

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get exception list API endpoint
title: Read exception list API endpoint
version: '2023-10-31'
paths:
/api/exception_lists:
get:
x-labels: [serverless, ess]
operationId: GetExceptionList
operationId: ReadExceptionList
x-codegen-enabled: true
summary: Retrieves an exception list using its `id` or `list_id` field
parameters:

View file

@ -11,7 +11,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get exception list item API endpoint
* title: Read exception list item API endpoint
* version: 2023-10-31
*/
@ -24,8 +24,8 @@ import {
ExceptionListItem,
} from '../model/exception_list_common.gen';
export type GetExceptionListItemRequestQuery = z.infer<typeof GetExceptionListItemRequestQuery>;
export const GetExceptionListItemRequestQuery = z.object({
export type ReadExceptionListItemRequestQuery = z.infer<typeof ReadExceptionListItemRequestQuery>;
export const ReadExceptionListItemRequestQuery = z.object({
/**
* Either `id` or `item_id` must be specified
*/
@ -36,9 +36,9 @@ export const GetExceptionListItemRequestQuery = z.object({
item_id: ExceptionListItemHumanId.optional(),
namespace_type: ExceptionNamespaceType.optional().default('single'),
});
export type GetExceptionListItemRequestQueryInput = z.input<
typeof GetExceptionListItemRequestQuery
export type ReadExceptionListItemRequestQueryInput = z.input<
typeof ReadExceptionListItemRequestQuery
>;
export type GetExceptionListItemResponse = z.infer<typeof GetExceptionListItemResponse>;
export const GetExceptionListItemResponse = ExceptionListItem;
export type ReadExceptionListItemResponse = z.infer<typeof ReadExceptionListItemResponse>;
export const ReadExceptionListItemResponse = ExceptionListItem;

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get exception list item API endpoint
title: Read exception list item API endpoint
version: '2023-10-31'
paths:
/api/exception_lists/items:
get:
x-labels: [serverless, ess]
operationId: GetExceptionListItem
operationId: ReadExceptionListItem
x-codegen-enabled: true
summary: Gets an exception list item
parameters:

View file

@ -11,7 +11,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get exception list summary API endpoint
* title: Read exception list summary API endpoint
* version: 2023-10-31
*/
@ -23,10 +23,10 @@ import {
ExceptionNamespaceType,
} from '../model/exception_list_common.gen';
export type GetExceptionListSummaryRequestQuery = z.infer<
typeof GetExceptionListSummaryRequestQuery
export type ReadExceptionListSummaryRequestQuery = z.infer<
typeof ReadExceptionListSummaryRequestQuery
>;
export const GetExceptionListSummaryRequestQuery = z.object({
export const ReadExceptionListSummaryRequestQuery = z.object({
/**
* Exception list's identifier generated upon creation
*/
@ -41,12 +41,12 @@ export const GetExceptionListSummaryRequestQuery = z.object({
*/
filter: z.string().optional(),
});
export type GetExceptionListSummaryRequestQueryInput = z.input<
typeof GetExceptionListSummaryRequestQuery
export type ReadExceptionListSummaryRequestQueryInput = z.input<
typeof ReadExceptionListSummaryRequestQuery
>;
export type GetExceptionListSummaryResponse = z.infer<typeof GetExceptionListSummaryResponse>;
export const GetExceptionListSummaryResponse = z.object({
export type ReadExceptionListSummaryResponse = z.infer<typeof ReadExceptionListSummaryResponse>;
export const ReadExceptionListSummaryResponse = z.object({
windows: z.number().int().min(0).optional(),
linux: z.number().int().min(0).optional(),
macos: z.number().int().min(0).optional(),

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get exception list summary API endpoint
title: Read exception list summary API endpoint
version: '2023-10-31'
paths:
/api/exception_lists/summary:
get:
x-labels: [serverless, ess]
operationId: GetExceptionListSummary
operationId: ReadExceptionListSummary
x-codegen-enabled: true
summary: Retrieves an exception list summary
parameters:

View file

@ -141,7 +141,7 @@ paths:
tags:
- Security Solution Exceptions API
get:
operationId: GetExceptionList
operationId: ReadExceptionList
parameters:
- description: Either `id` or `list_id` must be specified
in: query
@ -810,7 +810,7 @@ paths:
tags:
- Security Solution Exceptions API
get:
operationId: GetExceptionListItem
operationId: ReadExceptionListItem
parameters:
- description: Either `id` or `item_id` must be specified
in: query
@ -1188,7 +1188,7 @@ paths:
- Security Solution Exceptions API
/api/exception_lists/summary:
get:
operationId: GetExceptionListSummary
operationId: ReadExceptionListSummary
parameters:
- description: Exception list's identifier generated upon creation
in: query

View file

@ -141,7 +141,7 @@ paths:
tags:
- Security Solution Exceptions API
get:
operationId: GetExceptionList
operationId: ReadExceptionList
parameters:
- description: Either `id` or `list_id` must be specified
in: query
@ -810,7 +810,7 @@ paths:
tags:
- Security Solution Exceptions API
get:
operationId: GetExceptionListItem
operationId: ReadExceptionListItem
parameters:
- description: Either `id` or `item_id` must be specified
in: query
@ -1188,7 +1188,7 @@ paths:
- Security Solution Exceptions API
/api/exception_lists/summary:
get:
operationId: GetExceptionListSummary
operationId: ReadExceptionListSummary
parameters:
- description: Exception list's identifier generated upon creation
in: query

View file

@ -13,10 +13,10 @@ export * from './create_list/create_list.gen';
export * from './delete_list_index/delete_list_index.gen';
export * from './delete_list_item/delete_list_item.gen';
export * from './delete_list/delete_list.gen';
export * from './find_list_item/find_list_item.gen';
export * from './find_list/find_list.gen';
export * from './export_list_item/export_list_item.gen';
export * from './import_list_item/import_list_item.gen';
export * from './find_list_items/find_list_items.gen';
export * from './find_lists/find_lists.gen';
export * from './export_list_items/export_list_items.gen';
export * from './import_list_items/import_list_items.gen';
export * from './patch_list_item/patch_list_item.gen';
export * from './patch_list/patch_list.gen';
export * from './read_list_index/read_list_index.gen';

View file

@ -11,7 +11,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get list API endpoint
* title: Read list API endpoint
* version: 2023-10-31
*/
@ -20,14 +20,14 @@ import { z } from 'zod';
import { ListId } from '../model/list_common.gen';
import { List } from '../model/list_schemas.gen';
export type GetListRequestQuery = z.infer<typeof GetListRequestQuery>;
export const GetListRequestQuery = z.object({
export type ReadListRequestQuery = z.infer<typeof ReadListRequestQuery>;
export const ReadListRequestQuery = z.object({
/**
* List's `id` value
*/
id: ListId,
});
export type GetListRequestQueryInput = z.input<typeof GetListRequestQuery>;
export type ReadListRequestQueryInput = z.input<typeof ReadListRequestQuery>;
export type GetListResponse = z.infer<typeof GetListResponse>;
export const GetListResponse = List;
export type ReadListResponse = z.infer<typeof ReadListResponse>;
export const ReadListResponse = List;

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get list API endpoint
title: Read list API endpoint
version: '2023-10-31'
paths:
/api/lists:
get:
x-labels: [serverless, ess]
operationId: GetList
operationId: ReadList
x-codegen-enabled: true
summary: Retrieves a list using its id field
parameters:

View file

@ -11,14 +11,14 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get list DS existence status API endpoint
* title: Read list DS existence status API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
export type GetListIndexResponse = z.infer<typeof GetListIndexResponse>;
export const GetListIndexResponse = z.object({
export type ReadListIndexResponse = z.infer<typeof ReadListIndexResponse>;
export const ReadListIndexResponse = z.object({
list_index: z.boolean(),
list_item_index: z.boolean(),
});

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get list DS existence status API endpoint
title: Read list DS existence status API endpoint
version: '2023-10-31'
paths:
/api/lists/index:
get:
x-labels: [serverless, ess]
operationId: GetListIndex
operationId: ReadListIndex
x-codegen-enabled: true
summary: Get list data stream existence status
responses:

View file

@ -11,7 +11,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get list item API endpoint
* title: Read list item API endpoint
* version: 2023-10-31
*/
@ -20,8 +20,8 @@ import { z } from 'zod';
import { ListId } from '../model/list_common.gen';
import { ListItem } from '../model/list_schemas.gen';
export type GetListItemRequestQuery = z.infer<typeof GetListItemRequestQuery>;
export const GetListItemRequestQuery = z.object({
export type ReadListItemRequestQuery = z.infer<typeof ReadListItemRequestQuery>;
export const ReadListItemRequestQuery = z.object({
/**
* Required if `list_id` and `value` are not specified
*/
@ -35,7 +35,7 @@ export const GetListItemRequestQuery = z.object({
*/
value: z.string().optional(),
});
export type GetListItemRequestQueryInput = z.input<typeof GetListItemRequestQuery>;
export type ReadListItemRequestQueryInput = z.input<typeof ReadListItemRequestQuery>;
export type GetListItemResponse = z.infer<typeof GetListItemResponse>;
export const GetListItemResponse = z.union([ListItem, z.array(ListItem)]);
export type ReadListItemResponse = z.infer<typeof ReadListItemResponse>;
export const ReadListItemResponse = z.union([ListItem, z.array(ListItem)]);

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get list item API endpoint
title: Read list item API endpoint
version: '2023-10-31'
paths:
/api/lists/items:
get:
x-labels: [serverless, ess]
operationId: GetListItem
operationId: ReadListItem
x-codegen-enabled: true
summary: Gets a list item
parameters:

View file

@ -11,7 +11,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get list privileges API endpoint
* title: Read list privileges API endpoint
* version: 2023-10-31
*/
@ -35,8 +35,8 @@ export const ListItemPrivileges = z.object({
application: z.object({}).catchall(z.boolean()),
});
export type GetListPrivilegesResponse = z.infer<typeof GetListPrivilegesResponse>;
export const GetListPrivilegesResponse = z.object({
export type ReadListPrivilegesResponse = z.infer<typeof ReadListPrivilegesResponse>;
export const ReadListPrivilegesResponse = z.object({
lists: ListPrivileges,
listItems: ListItemPrivileges,
is_authenticated: z.boolean(),

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get list privileges API endpoint
title: Read list privileges API endpoint
version: '2023-10-31'
paths:
/api/lists/privileges:
get:
x-labels: [serverless, ess]
operationId: GetListPrivileges
operationId: ReadListPrivileges
x-codegen-enabled: true
summary: Gets list privileges
responses:

View file

@ -76,7 +76,7 @@ paths:
tags:
- Security Solution Lists API
get:
operationId: GetList
operationId: ReadList
parameters:
- description: List's `id` value
in: query
@ -500,7 +500,7 @@ paths:
tags:
- Security Solution Lists API
get:
operationId: GetListIndex
operationId: ReadListIndex
responses:
'200':
content:
@ -682,7 +682,7 @@ paths:
tags:
- Security Solution Lists API
get:
operationId: GetListItem
operationId: ReadListItem
parameters:
- description: Required if `list_id` and `value` are not specified
in: query
@ -1237,7 +1237,7 @@ paths:
- Security Solution Lists API
/api/lists/privileges:
get:
operationId: GetListPrivileges
operationId: ReadListPrivileges
responses:
'200':
content:

View file

@ -76,7 +76,7 @@ paths:
tags:
- Security Solution Lists API
get:
operationId: GetList
operationId: ReadList
parameters:
- description: List's `id` value
in: query
@ -500,7 +500,7 @@ paths:
tags:
- Security Solution Lists API
get:
operationId: GetListIndex
operationId: ReadListIndex
responses:
'200':
content:
@ -682,7 +682,7 @@ paths:
tags:
- Security Solution Lists API
get:
operationId: GetListItem
operationId: ReadListItem
parameters:
- description: Required if `list_id` and `value` are not specified
in: query
@ -1237,7 +1237,7 @@ paths:
- Security Solution Lists API
/api/lists/privileges:
get:
operationId: GetListPrivileges
operationId: ReadListPrivileges
responses:
'200':
content:

View file

@ -8,7 +8,7 @@
import { transformError } from '@kbn/securitysolution-es-utils';
import { LIST_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import { GetListRequestQuery, GetListResponse } from '@kbn/securitysolution-lists-common/api';
import { ReadListRequestQuery, ReadListResponse } from '@kbn/securitysolution-lists-common/api';
import type { ListsPluginRouter } from '../../types';
import { buildSiemResponse } from '../utils';
@ -27,7 +27,7 @@ export const readListRoute = (router: ListsPluginRouter): void => {
{
validate: {
request: {
query: buildRouteValidationWithZod(GetListRequestQuery),
query: buildRouteValidationWithZod(ReadListRequestQuery),
},
},
version: '2023-10-31',
@ -46,7 +46,7 @@ export const readListRoute = (router: ListsPluginRouter): void => {
});
}
return response.ok({ body: GetListResponse.parse(list) });
return response.ok({ body: ReadListResponse.parse(list) });
} catch (err) {
const error = transformError(err);
return siemResponse.error({

View file

@ -7,7 +7,7 @@
import { transformError } from '@kbn/securitysolution-es-utils';
import { LIST_INDEX } from '@kbn/securitysolution-list-constants';
import { GetListIndexResponse } from '@kbn/securitysolution-lists-common/api';
import { ReadListIndexResponse } from '@kbn/securitysolution-lists-common/api';
import type { ListsPluginRouter } from '../../types';
import { buildSiemResponse } from '../utils';
@ -37,7 +37,7 @@ export const readListIndexRoute = (router: ListsPluginRouter): void => {
if (listDataStreamExists && listItemDataStreamExists) {
return response.ok({
body: GetListIndexResponse.parse({
body: ReadListIndexResponse.parse({
list_index: listDataStreamExists,
list_item_index: listItemDataStreamExists,
}),

View file

@ -9,8 +9,8 @@ import { transformError } from '@kbn/securitysolution-es-utils';
import { LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
GetListItemRequestQuery,
GetListItemResponse,
ReadListItemRequestQuery,
ReadListItemResponse,
} from '@kbn/securitysolution-lists-common/api';
import type { ListsPluginRouter } from '../../types';
@ -30,7 +30,7 @@ export const readListItemRoute = (router: ListsPluginRouter): void => {
{
validate: {
request: {
query: buildRouteValidationWithZod(GetListItemRequestQuery),
query: buildRouteValidationWithZod(ReadListItemRequestQuery),
},
},
version: '2023-10-31',
@ -51,7 +51,7 @@ export const readListItemRoute = (router: ListsPluginRouter): void => {
});
}
return response.ok({ body: GetListItemResponse.parse(listItem) });
return response.ok({ body: ReadListItemResponse.parse(listItem) });
} else if (listId != null && value != null) {
const list = await lists.getList({ id: listId });
@ -75,7 +75,7 @@ export const readListItemRoute = (router: ListsPluginRouter): void => {
});
}
return response.ok({ body: GetListItemResponse.parse(listItem) });
return response.ok({ body: ReadListItemResponse.parse(listItem) });
} else {
return siemResponse.error({
body: 'Either "list_id" or "id" needs to be defined in the request',

View file

@ -9,8 +9,8 @@ import { transformError } from '@kbn/securitysolution-es-utils';
import { EXCEPTION_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
GetExceptionListItemRequestQuery,
GetExceptionListItemResponse,
ReadExceptionListItemRequestQuery,
ReadExceptionListItemResponse,
} from '@kbn/securitysolution-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
@ -34,7 +34,7 @@ export const readExceptionListItemRoute = (router: ListsPluginRouter): void => {
{
validate: {
request: {
query: buildRouteValidationWithZod(GetExceptionListItemRequestQuery),
query: buildRouteValidationWithZod(ReadExceptionListItemRequestQuery),
},
},
version: '2023-10-31',
@ -62,7 +62,7 @@ export const readExceptionListItemRoute = (router: ListsPluginRouter): void => {
});
}
return response.ok({ body: GetExceptionListItemResponse.parse(exceptionListItem) });
return response.ok({ body: ReadExceptionListItemResponse.parse(exceptionListItem) });
} catch (err) {
const error = transformError(err);
return siemResponse.error({

View file

@ -9,8 +9,8 @@ import { transformError } from '@kbn/securitysolution-es-utils';
import { EXCEPTION_LIST_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
GetExceptionListRequestQuery,
GetExceptionListResponse,
ReadExceptionListRequestQuery,
ReadExceptionListResponse,
} from '@kbn/securitysolution-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
@ -30,7 +30,7 @@ export const readExceptionListRoute = (router: ListsPluginRouter): void => {
{
validate: {
request: {
query: buildRouteValidationWithZod(GetExceptionListRequestQuery),
query: buildRouteValidationWithZod(ReadExceptionListRequestQuery),
},
},
version: '2023-10-31',
@ -57,7 +57,7 @@ export const readExceptionListRoute = (router: ListsPluginRouter): void => {
});
}
return response.ok({ body: GetExceptionListResponse.parse(exceptionList) });
return response.ok({ body: ReadExceptionListResponse.parse(exceptionList) });
} catch (err) {
const error = transformError(err);
return siemResponse.error({

View file

@ -9,8 +9,8 @@ import { transformError } from '@kbn/securitysolution-es-utils';
import { EXCEPTION_LIST_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
GetExceptionListSummaryRequestQuery,
GetExceptionListSummaryResponse,
ReadExceptionListSummaryRequestQuery,
ReadExceptionListSummaryResponse,
} from '@kbn/securitysolution-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
@ -30,7 +30,7 @@ export const summaryExceptionListRoute = (router: ListsPluginRouter): void => {
{
validate: {
request: {
query: buildRouteValidationWithZod(GetExceptionListSummaryRequestQuery),
query: buildRouteValidationWithZod(ReadExceptionListSummaryRequestQuery),
},
},
version: '2023-10-31',
@ -60,7 +60,7 @@ export const summaryExceptionListRoute = (router: ListsPluginRouter): void => {
}
return response.ok({
body: GetExceptionListSummaryResponse.parse(exceptionListSummary),
body: ReadExceptionListSummaryResponse.parse(exceptionListSummary),
});
} catch (err) {
const error = transformError(err);

View file

@ -10,7 +10,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Manage alert tags API endpoint
* title: Set alert tags API endpoint
* version: 2023-10-31
*/
@ -18,21 +18,21 @@ import { z } from 'zod';
import { AlertIds, AlertTags } from '../../../model/alert.gen';
export type ManageAlertTags = z.infer<typeof ManageAlertTags>;
export const ManageAlertTags = z.object({
export type SetAlertTags = z.infer<typeof SetAlertTags>;
export const SetAlertTags = z.object({
tags_to_add: AlertTags,
tags_to_remove: AlertTags,
});
export type ManageAlertTagsRequestBody = z.infer<typeof ManageAlertTagsRequestBody>;
export const ManageAlertTagsRequestBody = z.object({
export type SetAlertTagsRequestBody = z.infer<typeof SetAlertTagsRequestBody>;
export const SetAlertTagsRequestBody = z.object({
ids: AlertIds,
tags: ManageAlertTags,
tags: SetAlertTags,
});
export type ManageAlertTagsRequestBodyInput = z.input<typeof ManageAlertTagsRequestBody>;
export type SetAlertTagsRequestBodyInput = z.input<typeof SetAlertTagsRequestBody>;
/**
* Elasticsearch update by query response
*/
export type ManageAlertTagsResponse = z.infer<typeof ManageAlertTagsResponse>;
export const ManageAlertTagsResponse = z.object({}).catchall(z.unknown());
export type SetAlertTagsResponse = z.infer<typeof SetAlertTagsResponse>;
export const SetAlertTagsResponse = z.object({}).catchall(z.unknown());

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Manage alert tags API endpoint
title: Set alert tags API endpoint
version: '2023-10-31'
paths:
/api/detection_engine/signals/tags:
post:
x-labels: [serverless, ess]
operationId: ManageAlertTags
operationId: SetAlertTags
x-codegen-enabled: true
summary: Add and remove detection alert tags
description: |
@ -26,7 +26,7 @@ paths:
ids:
$ref: '../../../model/alert.schema.yaml#/components/schemas/AlertIds'
tags:
$ref: '#/components/schemas/ManageAlertTags'
$ref: '#/components/schemas/SetAlertTags'
required:
- ids
- tags
@ -62,7 +62,7 @@ paths:
components:
schemas:
ManageAlertTags:
SetAlertTags:
type: object
properties:
tags_to_add:

View file

@ -5,13 +5,13 @@
* 2.0.
*/
import type { ManageAlertTagsRequestBody } from './set_alert_tags.gen';
import type { SetAlertTagsRequestBody } from './set_alert_tags.gen';
export const getSetAlertTagsRequestMock = (
tagsToAdd: string[] = [],
tagsToRemove: string[] = [],
ids: string[] = []
): ManageAlertTagsRequestBody => ({
): SetAlertTagsRequestBody => ({
tags: { tags_to_add: tagsToAdd, tags_to_remove: tagsToRemove },
ids,
});

View file

@ -10,14 +10,14 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get alerts index name API endpoint
* title: Read alerts index name API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
export type GetAlertsIndexResponse = z.infer<typeof GetAlertsIndexResponse>;
export const GetAlertsIndexResponse = z.object({
export type ReadAlertsIndexResponse = z.infer<typeof ReadAlertsIndexResponse>;
export const ReadAlertsIndexResponse = z.object({
name: z.string(),
index_mapping_outdated: z.boolean().nullable(),
});

View file

@ -1,14 +1,14 @@
openapi: 3.0.0
info:
title: Get alerts index name API endpoint
title: Read alerts index name API endpoint
version: '2023-10-31'
paths:
/api/detection_engine/index:
get:
x-labels: [ess]
operationId: GetAlertsIndex
operationId: ReadAlertsIndex
x-codegen-enabled: true
summary: Gets the alert index name if it exists
summary: Reads the alert index name if it exists
tags:
- Alert index API
responses:

View file

@ -16,8 +16,8 @@
import { z } from 'zod';
export type GetPrivilegesResponse = z.infer<typeof GetPrivilegesResponse>;
export const GetPrivilegesResponse = z.object({
export type ReadPrivilegesResponse = z.infer<typeof ReadPrivilegesResponse>;
export const ReadPrivilegesResponse = z.object({
is_authenticated: z.boolean(),
has_encryption_key: z.boolean(),
});

View file

@ -6,7 +6,7 @@ paths:
/api/detection_engine/privileges:
get:
x-labels: [serverless, ess]
operationId: GetPrivileges
operationId: ReadPrivileges
x-codegen-enabled: true
summary: Returns user privileges for the Kibana space
description: |

View file

@ -5,7 +5,7 @@
* 2.0.
*/
export * from './get_prebuilt_rules_and_timelines_status/get_prebuilt_rules_and_timelines_status_route.gen';
export * from './read_prebuilt_rules_and_timelines_status/read_prebuilt_rules_and_timelines_status_route.gen';
export * from './get_prebuilt_rules_status/get_prebuilt_rules_status_route';
export * from './install_prebuilt_rules_and_timelines/install_prebuilt_rules_and_timelines_route.gen';
export * from './perform_rule_installation/perform_rule_installation_route';

View file

@ -16,10 +16,10 @@
import { z } from 'zod';
export type GetPrebuiltRulesAndTimelinesStatusResponse = z.infer<
typeof GetPrebuiltRulesAndTimelinesStatusResponse
export type ReadPrebuiltRulesAndTimelinesStatusResponse = z.infer<
typeof ReadPrebuiltRulesAndTimelinesStatusResponse
>;
export const GetPrebuiltRulesAndTimelinesStatusResponse = z
export const ReadPrebuiltRulesAndTimelinesStatusResponse = z
.object({
/**
* The total number of custom rules

View file

@ -7,7 +7,7 @@ paths:
get:
x-labels: [ess]
x-codegen-enabled: true
operationId: GetPrebuiltRulesAndTimelinesStatus
operationId: ReadPrebuiltRulesAndTimelinesStatus
summary: Retrieve the status of prebuilt detection rules and Timelines
description: Retrieve the status of all Elastic prebuilt detection rules and Timelines.
tags:

View file

@ -6,11 +6,11 @@
*/
import { expectParseError, expectParseSuccess, stringifyZodError } from '@kbn/zod-helpers';
import { GetPrebuiltRulesAndTimelinesStatusResponse } from './get_prebuilt_rules_and_timelines_status_route.gen';
import { ReadPrebuiltRulesAndTimelinesStatusResponse } from './read_prebuilt_rules_and_timelines_status_route.gen';
describe('Get prebuilt rules and timelines status response schema', () => {
test('it should validate an empty prepackaged response with defaults', () => {
const payload: GetPrebuiltRulesAndTimelinesStatusResponse = {
const payload: ReadPrebuiltRulesAndTimelinesStatusResponse = {
rules_installed: 0,
rules_not_installed: 0,
rules_not_updated: 0,
@ -19,14 +19,14 @@ describe('Get prebuilt rules and timelines status response schema', () => {
timelines_not_installed: 0,
timelines_not_updated: 0,
};
const result = GetPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
const result = ReadPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
expectParseSuccess(result);
expect(result.data).toEqual(payload);
});
test('it should not validate an extra invalid field added', () => {
const payload: GetPrebuiltRulesAndTimelinesStatusResponse & { invalid_field: string } = {
const payload: ReadPrebuiltRulesAndTimelinesStatusResponse & { invalid_field: string } = {
rules_installed: 0,
rules_not_installed: 0,
rules_not_updated: 0,
@ -36,7 +36,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
timelines_not_installed: 0,
timelines_not_updated: 0,
};
const result = GetPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
const result = ReadPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
expectParseError(result);
expect(stringifyZodError(result.error)).toEqual(
@ -45,7 +45,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
});
test('it should NOT validate an empty prepackaged response with a negative "rules_installed" number', () => {
const payload: GetPrebuiltRulesAndTimelinesStatusResponse = {
const payload: ReadPrebuiltRulesAndTimelinesStatusResponse = {
rules_installed: -1,
rules_not_installed: 0,
rules_not_updated: 0,
@ -54,7 +54,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
timelines_not_installed: 0,
timelines_not_updated: 0,
};
const result = GetPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
const result = ReadPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
expectParseError(result);
expect(stringifyZodError(result.error)).toEqual(
@ -63,7 +63,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
});
test('it should NOT validate an empty prepackaged response with a negative "rules_not_installed"', () => {
const payload: GetPrebuiltRulesAndTimelinesStatusResponse = {
const payload: ReadPrebuiltRulesAndTimelinesStatusResponse = {
rules_installed: 0,
rules_not_installed: -1,
rules_not_updated: 0,
@ -72,7 +72,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
timelines_not_installed: 0,
timelines_not_updated: 0,
};
const result = GetPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
const result = ReadPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
expectParseError(result);
expect(stringifyZodError(result.error)).toEqual(
@ -81,7 +81,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
});
test('it should NOT validate an empty prepackaged response with a negative "rules_not_updated"', () => {
const payload: GetPrebuiltRulesAndTimelinesStatusResponse = {
const payload: ReadPrebuiltRulesAndTimelinesStatusResponse = {
rules_installed: 0,
rules_not_installed: 0,
rules_not_updated: -1,
@ -90,7 +90,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
timelines_not_installed: 0,
timelines_not_updated: 0,
};
const result = GetPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
const result = ReadPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
expectParseError(result);
expect(stringifyZodError(result.error)).toEqual(
@ -99,7 +99,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
});
test('it should NOT validate an empty prepackaged response with a negative "rules_custom_installed"', () => {
const payload: GetPrebuiltRulesAndTimelinesStatusResponse = {
const payload: ReadPrebuiltRulesAndTimelinesStatusResponse = {
rules_installed: 0,
rules_not_installed: 0,
rules_not_updated: 0,
@ -108,7 +108,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
timelines_not_installed: 0,
timelines_not_updated: 0,
};
const result = GetPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
const result = ReadPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
expectParseError(result);
expect(stringifyZodError(result.error)).toEqual(
@ -117,7 +117,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
});
test('it should NOT validate an empty prepackaged response if "rules_installed" is not there', () => {
const payload: GetPrebuiltRulesAndTimelinesStatusResponse = {
const payload: ReadPrebuiltRulesAndTimelinesStatusResponse = {
rules_installed: 0,
rules_not_installed: 0,
rules_not_updated: 0,
@ -128,7 +128,7 @@ describe('Get prebuilt rules and timelines status response schema', () => {
};
// @ts-expect-error
delete payload.rules_installed;
const result = GetPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
const result = ReadPrebuiltRulesAndTimelinesStatusResponse.safeParse(payload);
expectParseError(result);
expect(stringifyZodError(result.error)).toEqual('rules_installed: Required');

View file

@ -8,4 +8,4 @@
export * from './create_signals_migration/create_signals_migration.gen';
export * from './delete_signals_migration/delete_signals_migration.gen';
export * from './finalize_signals_migration/finalize_signals_migration.gen';
export * from './get_signals_migration_status/get_signals_migration_status.gen';
export * from './read_signals_migration_status/read_signals_migration_status.gen';

View file

@ -7,4 +7,4 @@
export * from './create_signals_migration/create_signals_migration_route.mock';
export * from './finalize_signals_migration/finalize_signals_migration_route.mock';
export * from './get_signals_migration_status/get_signals_migration_status_route.mock';
export * from './read_signals_migration_status/read_signals_migration_status_route.mock';

View file

@ -10,7 +10,7 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Get alerts migration status API endpoint
* title: Read alerts migration status API endpoint
* version: 2023-10-31
*/
@ -42,20 +42,20 @@ export const IndexMigrationStatus = z.object({
is_outdated: z.boolean(),
});
export type GetAlertsMigrationStatusRequestQuery = z.infer<
typeof GetAlertsMigrationStatusRequestQuery
export type ReadAlertsMigrationStatusRequestQuery = z.infer<
typeof ReadAlertsMigrationStatusRequestQuery
>;
export const GetAlertsMigrationStatusRequestQuery = z.object({
export const ReadAlertsMigrationStatusRequestQuery = z.object({
/**
* Maximum age of qualifying detection alerts
*/
from: z.string().superRefine(isValidDateMath),
});
export type GetAlertsMigrationStatusRequestQueryInput = z.input<
typeof GetAlertsMigrationStatusRequestQuery
export type ReadAlertsMigrationStatusRequestQueryInput = z.input<
typeof ReadAlertsMigrationStatusRequestQuery
>;
export type GetAlertsMigrationStatusResponse = z.infer<typeof GetAlertsMigrationStatusResponse>;
export const GetAlertsMigrationStatusResponse = z.object({
export type ReadAlertsMigrationStatusResponse = z.infer<typeof ReadAlertsMigrationStatusResponse>;
export const ReadAlertsMigrationStatusResponse = z.object({
indices: z.array(IndexMigrationStatus),
});

View file

@ -1,12 +1,12 @@
openapi: 3.0.0
info:
title: Get alerts migration status API endpoint
title: Read alerts migration status API endpoint
version: '2023-10-31'
paths:
/api/detection_engine/signals/migration_status:
post:
x-labels: [ess]
operationId: GetAlertsMigrationStatus
operationId: ReadAlertsMigrationStatus
x-codegen-enabled: true
summary: Retrieve the status of detection alert migrations
description: Retrieve indices that contain detection alerts of a particular age, along with migration information for each of those indices.

View file

@ -5,8 +5,8 @@
* 2.0.
*/
import type { GetAlertsMigrationStatusRequestQuery } from './get_signals_migration_status.gen';
import type { ReadAlertsMigrationStatusRequestQuery } from './read_signals_migration_status.gen';
export const getSignalsMigrationStatusSchemaMock = (): GetAlertsMigrationStatusRequestQuery => ({
export const getSignalsMigrationStatusSchemaMock = (): ReadAlertsMigrationStatusRequestQuery => ({
from: 'now-30d',
});

View file

@ -58,7 +58,7 @@ paths:
- Security Solution Detections API
- Alert index API
get:
operationId: GetAlertsIndex
operationId: ReadAlertsIndex
responses:
'200':
content:
@ -99,7 +99,7 @@ paths:
schema:
$ref: '#/components/schemas/SiemErrorResponse'
description: Internal server error response
summary: Gets the alert index name if it exists
summary: Reads the alert index name if it exists
tags:
- Security Solution Detections API
- Alert index API
@ -156,7 +156,7 @@ paths:
index for the Elastic Security alerts generated by
detection engine rules.
operationId: GetPrivileges
operationId: ReadPrivileges
responses:
'200':
content:
@ -833,7 +833,7 @@ paths:
description: >-
Retrieve the status of all Elastic prebuilt detection rules and
Timelines.
operationId: GetPrebuiltRulesAndTimelinesStatus
operationId: ReadPrebuiltRulesAndTimelinesStatus
responses:
'200':
content:
@ -1197,7 +1197,7 @@ paths:
description: >-
Retrieve indices that contain detection alerts of a particular age,
along with migration information for each of those indices.
operationId: GetAlertsMigrationStatus
operationId: ReadAlertsMigrationStatus
parameters:
- description: Maximum age of qualifying detection alerts
in: query
@ -1377,7 +1377,7 @@ paths:
And tags to detection alerts, and remove them from alerts.
> info
> You cannot add and remove the same alert tag in the same request.
operationId: ManageAlertTags
operationId: SetAlertTags
requestBody:
content:
application/json:
@ -1387,7 +1387,7 @@ paths:
ids:
$ref: '#/components/schemas/AlertIds'
tags:
$ref: '#/components/schemas/ManageAlertTags'
$ref: '#/components/schemas/SetAlertTags'
required:
- ids
- tags
@ -3539,16 +3539,6 @@ components:
- risk_score
- severity
- $ref: '#/components/schemas/MachineLearningRuleCreateFields'
ManageAlertTags:
type: object
properties:
tags_to_add:
$ref: '#/components/schemas/AlertTags'
tags_to_remove:
$ref: '#/components/schemas/AlertTags'
required:
- tags_to_add
- tags_to_remove
MaxSignals:
minimum: 1
type: integer
@ -5760,6 +5750,16 @@ components:
required:
- query
- status
SetAlertTags:
type: object
properties:
tags_to_add:
$ref: '#/components/schemas/AlertTags'
tags_to_remove:
$ref: '#/components/schemas/AlertTags'
required:
- tags_to_add
- tags_to_remove
SetupGuide:
type: string
Severity:

View file

@ -25,7 +25,7 @@ paths:
index for the Elastic Security alerts generated by
detection engine rules.
operationId: GetPrivileges
operationId: ReadPrivileges
responses:
'200':
content:
@ -711,7 +711,7 @@ paths:
And tags to detection alerts, and remove them from alerts.
> info
> You cannot add and remove the same alert tag in the same request.
operationId: ManageAlertTags
operationId: SetAlertTags
requestBody:
content:
application/json:
@ -721,7 +721,7 @@ paths:
ids:
$ref: '#/components/schemas/AlertIds'
tags:
$ref: '#/components/schemas/ManageAlertTags'
$ref: '#/components/schemas/SetAlertTags'
required:
- ids
- tags
@ -2791,16 +2791,6 @@ components:
- risk_score
- severity
- $ref: '#/components/schemas/MachineLearningRuleCreateFields'
ManageAlertTags:
type: object
properties:
tags_to_add:
$ref: '#/components/schemas/AlertTags'
tags_to_remove:
$ref: '#/components/schemas/AlertTags'
required:
- tags_to_add
- tags_to_remove
MaxSignals:
minimum: 1
type: integer
@ -4914,6 +4904,16 @@ components:
required:
- query
- status
SetAlertTags:
type: object
properties:
tags_to_add:
$ref: '#/components/schemas/AlertTags'
tags_to_remove:
$ref: '#/components/schemas/AlertTags'
required:
- tags_to_add
- tags_to_remove
SetupGuide:
type: string
Severity:

View file

@ -12,7 +12,7 @@ import { buildSiemResponse } from '../../../routes/utils';
import type { SecuritySolutionPluginRouter } from '../../../../../types';
import {
GetPrebuiltRulesAndTimelinesStatusResponse,
ReadPrebuiltRulesAndTimelinesStatusResponse,
PREBUILT_RULES_STATUS_URL,
} from '../../../../../../common/api/detection_engine/prebuilt_rules';
@ -74,7 +74,7 @@ export const getPrebuiltRulesAndTimelinesStatusRoute = (router: SecuritySolution
checkTimelineStatusRt
);
const responseBody: GetPrebuiltRulesAndTimelinesStatusResponse = {
const responseBody: ReadPrebuiltRulesAndTimelinesStatusResponse = {
rules_custom_installed: customRules.total,
rules_installed: installedPrebuiltRules.size,
rules_not_installed: rulesToInstall.length,
@ -86,7 +86,7 @@ export const getPrebuiltRulesAndTimelinesStatusRoute = (router: SecuritySolution
};
return response.ok({
body: GetPrebuiltRulesAndTimelinesStatusResponse.parse(responseBody),
body: ReadPrebuiltRulesAndTimelinesStatusResponse.parse(responseBody),
});
} catch (err) {
const error = transformError(err);

View file

@ -8,7 +8,7 @@
import { transformError, getBootstrapIndexExists } from '@kbn/securitysolution-es-utils';
import type { RuleDataPluginService } from '@kbn/rule-registry-plugin/server';
import type { IKibanaResponse } from '@kbn/core/server';
import type { GetAlertsIndexResponse } from '../../../../../common/api/detection_engine/index_management';
import type { ReadAlertsIndexResponse } from '../../../../../common/api/detection_engine/index_management';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import { DETECTION_ENGINE_INDEX_URL } from '../../../../../common/constants';
@ -35,7 +35,7 @@ export const readIndexRoute = (
version: '2023-10-31',
validate: false,
},
async (context, _, response): Promise<IKibanaResponse<GetAlertsIndexResponse>> => {
async (context, _, response): Promise<IKibanaResponse<ReadAlertsIndexResponse>> => {
const siemResponse = buildSiemResponse(response);
try {

View file

@ -12,7 +12,7 @@ import type { IKibanaResponse } from '@kbn/core/server';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import { DETECTION_ENGINE_PRIVILEGES_URL } from '../../../../../common/constants';
import { buildSiemResponse } from '../utils';
import type { GetPrivilegesResponse } from '../../../../../common/api/detection_engine';
import type { ReadPrivilegesResponse } from '../../../../../common/api/detection_engine';
export const readPrivilegesRoute = (
router: SecuritySolutionPluginRouter,
@ -31,7 +31,7 @@ export const readPrivilegesRoute = (
version: '2023-10-31',
validate: false,
},
async (context, request, response): Promise<IKibanaResponse<GetPrivilegesResponse>> => {
async (context, request, response): Promise<IKibanaResponse<ReadPrivilegesResponse>> => {
const siemResponse = buildSiemResponse(response);
try {

View file

@ -7,7 +7,7 @@
import { transformError, getIndexAliases } from '@kbn/securitysolution-es-utils';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import { GetAlertsMigrationStatusRequestQuery } from '../../../../../common/api/detection_engine/signals_migration';
import { ReadAlertsMigrationStatusRequestQuery } from '../../../../../common/api/detection_engine/signals_migration';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import { DETECTION_ENGINE_SIGNALS_MIGRATION_STATUS_URL } from '../../../../../common/constants';
import { getIndexVersionsByIndex } from '../../migrations/get_index_versions_by_index';
@ -31,7 +31,7 @@ export const getSignalsMigrationStatusRoute = (router: SecuritySolutionPluginRou
{
version: '2023-10-31',
validate: {
request: { query: buildRouteValidationWithZod(GetAlertsMigrationStatusRequestQuery) },
request: { query: buildRouteValidationWithZod(ReadAlertsMigrationStatusRequestQuery) },
},
},
async (context, request, response) => {

View file

@ -8,7 +8,7 @@
import { transformError } from '@kbn/securitysolution-es-utils';
import { uniq } from 'lodash/fp';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import { ManageAlertTagsRequestBody } from '../../../../../common/api/detection_engine/alert_tags';
import { SetAlertTagsRequestBody } from '../../../../../common/api/detection_engine/alert_tags';
import type { SecuritySolutionPluginRouter } from '../../../../types';
import {
DEFAULT_ALERTS_INDEX,
@ -31,7 +31,7 @@ export const setAlertTagsRoute = (router: SecuritySolutionPluginRouter) => {
version: '2023-10-31',
validate: {
request: {
body: buildRouteValidationWithZod(ManageAlertTagsRequestBody),
body: buildRouteValidationWithZod(SetAlertTagsRequestBody),
},
},
},

View file

@ -55,7 +55,6 @@ import { FinalizeAlertsMigrationRequestBodyInput } from '@kbn/security-solution-
import { FindAssetCriticalityRecordsRequestQueryInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/asset_criticality/list_asset_criticality.gen';
import { FindRulesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/find_rules/find_rules_route.gen';
import { GetAgentPolicySummaryRequestQueryInput } from '@kbn/security-solution-plugin/common/api/endpoint/policy/policy.gen';
import { GetAlertsMigrationStatusRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals_migration/get_signals_migration_status/get_signals_migration_status.gen';
import { GetAssetCriticalityRecordRequestQueryInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/asset_criticality/get_asset_criticality.gen';
import { GetDraftTimelinesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen';
import {
@ -78,7 +77,6 @@ import { GetTimelinesRequestQueryInput } from '@kbn/security-solution-plugin/com
import { ImportRulesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/import_rules/import_rules_route.gen';
import { ImportTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/import_timelines/import_timelines_route.gen';
import { InstallPrepackedTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.gen';
import { ManageAlertTagsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/alert_tags/set_alert_tags/set_alert_tags.gen';
import { PatchRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/patch_rule/patch_rule_route.gen';
import { PatchTimelineRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/patch_timelines/patch_timeline_route.gen';
import {
@ -89,12 +87,14 @@ import { PersistFavoriteRouteRequestBodyInput } from '@kbn/security-solution-plu
import { PersistNoteRouteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_note/persist_note_route.gen';
import { PersistPinnedEventRouteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/pinned_events/pinned_events_route.gen';
import { PreviewRiskScoreRequestBodyInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/risk_engine/preview_route.gen';
import { ReadAlertsMigrationStatusRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals_migration/read_signals_migration_status/read_signals_migration_status.gen';
import { ReadRuleRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/read_rule/read_rule_route.gen';
import { ResolveTimelineRequestQueryInput } from '@kbn/security-solution-plugin/common/api/timeline/resolve_timeline/resolve_timeline_route.gen';
import { RulePreviewRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_preview/rule_preview.gen';
import { SearchAlertsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals/query_signals/query_signals_route.gen';
import { SetAlertAssigneesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/alert_assignees/set_alert_assignees_route.gen';
import { SetAlertsStatusRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals/set_signal_status/set_signals_status_route.gen';
import { SetAlertTagsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/alert_tags/set_alert_tags/set_alert_tags.gen';
import { SuggestUserProfilesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/users/suggest_user_profiles_route.gen';
import { TriggerRiskScoreCalculationRequestBodyInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/risk_engine/entity_calculation_route.gen';
import { UpdateRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/update_rule/update_rule_route.gen';
@ -414,24 +414,6 @@ finalize it.
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getAlertsIndex() {
return supertest
.get('/api/detection_engine/index')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
/**
* Retrieve indices that contain detection alerts of a particular age, along with migration information for each of those indices.
*/
getAlertsMigrationStatus(props: GetAlertsMigrationStatusProps) {
return supertest
.post('/api/detection_engine/signals/migration_status')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getAssetCriticalityRecord(props: GetAssetCriticalityRecordProps) {
return supertest
.get('/api/asset_criticality')
@ -482,30 +464,6 @@ finalize it.
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
/**
* Retrieve the status of all Elastic prebuilt detection rules and Timelines.
*/
getPrebuiltRulesAndTimelinesStatus() {
return supertest
.get('/api/detection_engine/rules/prepackaged/_status')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
/**
* Retrieves whether or not the user is authenticated, and the user's Kibana
space and index privileges, which determine if the user can create an
index for the Elastic Security alerts generated by
detection engine rules.
*/
getPrivileges() {
return supertest
.get('/api/detection_engine/privileges')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
getProtectionUpdatesNote(props: GetProtectionUpdatesNoteProps) {
return supertest
.get(
@ -618,20 +576,6 @@ detection engine rules.
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
/**
* And tags to detection alerts, and remove them from alerts.
> info
> You cannot add and remove the same alert tag in the same request.
*/
manageAlertTags(props: ManageAlertTagsProps) {
return supertest
.post('/api/detection_engine/signals/tags')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.send(props.body as object);
},
/**
* Update specific fields of an existing detection rule using the `rule_id` or `id` field.
*/
@ -701,6 +645,48 @@ detection engine rules.
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.send(props.body as object);
},
readAlertsIndex() {
return supertest
.get('/api/detection_engine/index')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
/**
* Retrieve indices that contain detection alerts of a particular age, along with migration information for each of those indices.
*/
readAlertsMigrationStatus(props: ReadAlertsMigrationStatusProps) {
return supertest
.post('/api/detection_engine/signals/migration_status')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
/**
* Retrieve the status of all Elastic prebuilt detection rules and Timelines.
*/
readPrebuiltRulesAndTimelinesStatus() {
return supertest
.get('/api/detection_engine/rules/prepackaged/_status')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
/**
* Retrieves whether or not the user is authenticated, and the user's Kibana
space and index privileges, which determine if the user can create an
index for the Elastic Security alerts generated by
detection engine rules.
*/
readPrivileges() {
return supertest
.get('/api/detection_engine/privileges')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
readRiskEngineSettings() {
return supertest
.get('/internal/risk_score/engine/settings')
@ -788,6 +774,20 @@ detection engine rules.
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.send(props.body as object);
},
/**
* And tags to detection alerts, and remove them from alerts.
> info
> You cannot add and remove the same alert tag in the same request.
*/
setAlertTags(props: SetAlertTagsProps) {
return supertest
.post('/api/detection_engine/signals/tags')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.send(props.body as object);
},
/**
* Suggests user profiles.
*/
@ -915,9 +915,6 @@ export interface FindRulesProps {
export interface GetAgentPolicySummaryProps {
query: GetAgentPolicySummaryRequestQueryInput;
}
export interface GetAlertsMigrationStatusProps {
query: GetAlertsMigrationStatusRequestQueryInput;
}
export interface GetAssetCriticalityRecordProps {
query: GetAssetCriticalityRecordRequestQueryInput;
}
@ -960,9 +957,6 @@ export interface ImportTimelinesProps {
export interface InstallPrepackedTimelinesProps {
body: InstallPrepackedTimelinesRequestBodyInput;
}
export interface ManageAlertTagsProps {
body: ManageAlertTagsRequestBodyInput;
}
export interface PatchRuleProps {
body: PatchRuleRequestBodyInput;
}
@ -985,6 +979,9 @@ export interface PersistPinnedEventRouteProps {
export interface PreviewRiskScoreProps {
body: PreviewRiskScoreRequestBodyInput;
}
export interface ReadAlertsMigrationStatusProps {
query: ReadAlertsMigrationStatusRequestQueryInput;
}
export interface ReadRuleProps {
query: ReadRuleRequestQueryInput;
}
@ -1003,6 +1000,9 @@ export interface SetAlertAssigneesProps {
export interface SetAlertsStatusProps {
body: SetAlertsStatusRequestBodyInput;
}
export interface SetAlertTagsProps {
body: SetAlertTagsRequestBodyInput;
}
export interface SuggestUserProfilesProps {
query: SuggestUserProfilesRequestQueryInput;
}

View file

@ -31,12 +31,12 @@ import { DeleteExceptionListRequestQueryInput } from '@kbn/securitysolution-exce
import { DeleteExceptionListItemRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/delete_exception_list_item/delete_exception_list_item.gen';
import { DuplicateExceptionListRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/duplicate_exception_list/duplicate_exception_list.gen';
import { ExportExceptionListRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/export_exception_list/export_exception_list.gen';
import { FindExceptionListItemsRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/find_exception_list_item/find_exception_list_item.gen';
import { FindExceptionListsRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/find_exception_list/find_exception_list.gen';
import { GetExceptionListRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/read_exception_list/read_exception_list.gen';
import { GetExceptionListItemRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/read_exception_list_item/read_exception_list_item.gen';
import { GetExceptionListSummaryRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/summary_exception_list/summary_exception_list.gen';
import { FindExceptionListItemsRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/find_exception_list_items/find_exception_list_items.gen';
import { FindExceptionListsRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/find_exception_lists/find_exception_lists.gen';
import { ImportExceptionListRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/import_exceptions/import_exceptions.gen';
import { ReadExceptionListRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/read_exception_list/read_exception_list.gen';
import { ReadExceptionListItemRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/read_exception_list_item/read_exception_list_item.gen';
import { ReadExceptionListSummaryRequestQueryInput } from '@kbn/securitysolution-exceptions-common/api/read_exception_list_summary/read_exception_list_summary.gen';
import { UpdateExceptionListRequestBodyInput } from '@kbn/securitysolution-exceptions-common/api/update_exception_list/update_exception_list.gen';
import { UpdateExceptionListItemRequestBodyInput } from '@kbn/securitysolution-exceptions-common/api/update_exception_list_item/update_exception_list_item.gen';
import { FtrProviderContext } from '../ftr_provider_context';
@ -128,7 +128,18 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getExceptionList(props: GetExceptionListProps) {
/**
* Imports an exception list and associated items
*/
importExceptionList(props: ImportExceptionListProps) {
return supertest
.post('/api/exception_lists/_import')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
readExceptionList(props: ReadExceptionListProps) {
return supertest
.get('/api/exception_lists')
.set('kbn-xsrf', 'true')
@ -136,7 +147,7 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getExceptionListItem(props: GetExceptionListItemProps) {
readExceptionListItem(props: ReadExceptionListItemProps) {
return supertest
.get('/api/exception_lists/items')
.set('kbn-xsrf', 'true')
@ -144,7 +155,7 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getExceptionListSummary(props: GetExceptionListSummaryProps) {
readExceptionListSummary(props: ReadExceptionListSummaryProps) {
return supertest
.get('/api/exception_lists/summary')
.set('kbn-xsrf', 'true')
@ -152,17 +163,6 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
/**
* Imports an exception list and associated items
*/
importExceptionList(props: ImportExceptionListProps) {
return supertest
.post('/api/exception_lists/_import')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
updateExceptionList(props: UpdateExceptionListProps) {
return supertest
.put('/api/exception_lists')
@ -213,18 +213,18 @@ export interface FindExceptionListItemsProps {
export interface FindExceptionListsProps {
query: FindExceptionListsRequestQueryInput;
}
export interface GetExceptionListProps {
query: GetExceptionListRequestQueryInput;
}
export interface GetExceptionListItemProps {
query: GetExceptionListItemRequestQueryInput;
}
export interface GetExceptionListSummaryProps {
query: GetExceptionListSummaryRequestQueryInput;
}
export interface ImportExceptionListProps {
query: ImportExceptionListRequestQueryInput;
}
export interface ReadExceptionListProps {
query: ReadExceptionListRequestQueryInput;
}
export interface ReadExceptionListItemProps {
query: ReadExceptionListItemRequestQueryInput;
}
export interface ReadExceptionListSummaryProps {
query: ReadExceptionListSummaryRequestQueryInput;
}
export interface UpdateExceptionListProps {
body: UpdateExceptionListRequestBodyInput;
}

View file

@ -23,14 +23,14 @@ import { CreateListRequestBodyInput } from '@kbn/securitysolution-lists-common/a
import { CreateListItemRequestBodyInput } from '@kbn/securitysolution-lists-common/api/create_list_item/create_list_item.gen';
import { DeleteListRequestQueryInput } from '@kbn/securitysolution-lists-common/api/delete_list/delete_list.gen';
import { DeleteListItemRequestQueryInput } from '@kbn/securitysolution-lists-common/api/delete_list_item/delete_list_item.gen';
import { ExportListItemsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/export_list_item/export_list_item.gen';
import { FindListItemsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/find_list_item/find_list_item.gen';
import { FindListsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/find_list/find_list.gen';
import { GetListRequestQueryInput } from '@kbn/securitysolution-lists-common/api/read_list/read_list.gen';
import { GetListItemRequestQueryInput } from '@kbn/securitysolution-lists-common/api/read_list_item/read_list_item.gen';
import { ImportListItemsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/import_list_item/import_list_item.gen';
import { ExportListItemsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/export_list_items/export_list_items.gen';
import { FindListItemsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/find_list_items/find_list_items.gen';
import { FindListsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/find_lists/find_lists.gen';
import { ImportListItemsRequestQueryInput } from '@kbn/securitysolution-lists-common/api/import_list_items/import_list_items.gen';
import { PatchListRequestBodyInput } from '@kbn/securitysolution-lists-common/api/patch_list/patch_list.gen';
import { PatchListItemRequestBodyInput } from '@kbn/securitysolution-lists-common/api/patch_list_item/patch_list_item.gen';
import { ReadListRequestQueryInput } from '@kbn/securitysolution-lists-common/api/read_list/read_list.gen';
import { ReadListItemRequestQueryInput } from '@kbn/securitysolution-lists-common/api/read_list_item/read_list_item.gen';
import { UpdateListRequestBodyInput } from '@kbn/securitysolution-lists-common/api/update_list/update_list.gen';
import { UpdateListItemRequestBodyInput } from '@kbn/securitysolution-lists-common/api/update_list_item/update_list_item.gen';
import { FtrProviderContext } from '../ftr_provider_context';
@ -112,36 +112,6 @@ export function SecuritySolutionApiProvider({ getService }: FtrProviderContext)
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getList(props: GetListProps) {
return supertest
.get('/api/lists')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getListIndex() {
return supertest
.get('/api/lists/index')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
getListItem(props: GetListItemProps) {
return supertest
.get('/api/lists/items')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
getListPrivileges() {
return supertest
.get('/api/lists/privileges')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
/**
* Imports a list of items from a `.txt` or `.csv` file. The maximum file size is 9 million bytes.
@ -172,6 +142,36 @@ You can import items to a new or existing list.
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.send(props.body as object);
},
readList(props: ReadListProps) {
return supertest
.get('/api/lists')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
readListIndex() {
return supertest
.get('/api/lists/index')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
readListItem(props: ReadListItemProps) {
return supertest
.get('/api/lists/items')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
readListPrivileges() {
return supertest
.get('/api/lists/privileges')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
updateList(props: UpdateListProps) {
return supertest
.put('/api/lists')
@ -212,12 +212,6 @@ export interface FindListItemsProps {
export interface FindListsProps {
query: FindListsRequestQueryInput;
}
export interface GetListProps {
query: GetListRequestQueryInput;
}
export interface GetListItemProps {
query: GetListItemRequestQueryInput;
}
export interface ImportListItemsProps {
query: ImportListItemsRequestQueryInput;
}
@ -227,6 +221,12 @@ export interface PatchListProps {
export interface PatchListItemProps {
body: PatchListItemRequestBodyInput;
}
export interface ReadListProps {
query: ReadListRequestQueryInput;
}
export interface ReadListItemProps {
query: ReadListItemRequestQueryInput;
}
export interface UpdateListProps {
body: UpdateListRequestBodyInput;
}

View file

@ -6,7 +6,7 @@
*/
import { AlertTagIds } from '@kbn/security-solution-plugin/common/api/detection_engine';
import { ManageAlertTagsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine';
import { SetAlertTagsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine';
export const setAlertTags = ({
tagsToAdd,
@ -16,7 +16,7 @@ export const setAlertTags = ({
tagsToAdd: string[];
tagsToRemove: string[];
ids: AlertTagIds;
}): ManageAlertTagsRequestBodyInput => ({
}): SetAlertTagsRequestBodyInput => ({
tags: {
tags_to_add: tagsToAdd,
tags_to_remove: tagsToRemove,

View file

@ -6,7 +6,7 @@
*/
import {
GetPrebuiltRulesAndTimelinesStatusResponse,
ReadPrebuiltRulesAndTimelinesStatusResponse,
PREBUILT_RULES_STATUS_URL,
} from '@kbn/security-solution-plugin/common/api/detection_engine/prebuilt_rules';
import type SuperTest from 'supertest';
@ -22,7 +22,7 @@ import { refreshSavedObjectIndices } from '../../refresh_index';
export const getPrebuiltRulesAndTimelinesStatus = async (
es: Client,
supertest: SuperTest.Agent
): Promise<GetPrebuiltRulesAndTimelinesStatusResponse> => {
): Promise<ReadPrebuiltRulesAndTimelinesStatusResponse> => {
await refreshSavedObjectIndices(es);
const response = await supertest