[Security Solution] Add missing Endpoint Exceptions API OpenAPI specifications (#186082)

**Resolves:** https://github.com/elastic/kibana/issues/183839

## Summary

This PR adds missing OpenAPI specifications for Endpoint exceptions API which are the following

- `POST /api/endpoint_list`
- `POST /api/endpoint_list/items`
- `GET /api/endpoint_list/items`
- `PUT /api/endpoint_list/items`
- `DELETE /api/endpoint_list/items`
- `GET /api/endpoint_list/items/_find`
This commit is contained in:
Maxim Palenov 2024-07-29 16:19:12 +02:00 committed by GitHub
parent 0c45b1169c
commit ecbe36de17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 1052 additions and 209 deletions

1
.github/CODEOWNERS vendored
View file

@ -754,6 +754,7 @@ x-pack/test/security_functional/plugins/test_endpoints @elastic/kibana-security
packages/kbn-securitysolution-autocomplete @elastic/security-detection-engine
x-pack/packages/security-solution/data_table @elastic/security-threat-hunting-investigations
packages/kbn-securitysolution-ecs @elastic/security-threat-hunting-explore
packages/kbn-securitysolution-endpoint-exceptions-common @elastic/security-detection-engine
packages/kbn-securitysolution-es-utils @elastic/security-detection-engine
packages/kbn-securitysolution-exception-list-components @elastic/security-detection-engine
packages/kbn-securitysolution-exceptions-common @elastic/security-detection-engine

View file

@ -769,6 +769,7 @@
"@kbn/securitysolution-autocomplete": "link:packages/kbn-securitysolution-autocomplete",
"@kbn/securitysolution-data-table": "link:x-pack/packages/security-solution/data_table",
"@kbn/securitysolution-ecs": "link:packages/kbn-securitysolution-ecs",
"@kbn/securitysolution-endpoint-exceptions-common": "link:packages/kbn-securitysolution-endpoint-exceptions-common",
"@kbn/securitysolution-es-utils": "link:packages/kbn-securitysolution-es-utils",
"@kbn/securitysolution-exception-list-components": "link:packages/kbn-securitysolution-exception-list-components",
"@kbn/securitysolution-exceptions-common": "link:packages/kbn-securitysolution-exceptions-common",

View file

@ -0,0 +1,20 @@
# Security Solution Endpoint Exceptions
The package contains common files for the Endpoint Exceptions feature.
`common` in the name highlights that this package is intended to combine any common entities related to Endpoint Exceptions. E.g. the other `kbn-securitysolution-endpoint-exception-list-*` packages
content should be moved here while `kbn-securitysolution-io-ts-list-types` package should be
gone eventually.
## API folder
`api` folder contains OpenAPI schemas for Security Solution Endpoint Exceptions feature. There are automatically generated Zod schemas and TS types for each schemas located in corresponding
`*.gen.ts` files.
**Please add any Endpoint Exceptions feature related schemas to this package.**
TS types and/or Zod schemas can be imported in a plugin or another package like
```ts
import { CreateEndpointExceptionRequestBody } from '@kbn/securitysolution-endpoint-exceptions-common/api';
```

View file

@ -0,0 +1,23 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Create endpoint list API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
import { EndpointList } from '../model/endpoint_list_common.gen';
export type CreateEndpointListResponse = z.infer<typeof CreateEndpointListResponse>;
export const CreateEndpointListResponse = EndpointList;

View file

@ -0,0 +1,47 @@
openapi: 3.0.0
info:
title: Create endpoint list API endpoint
version: '2023-10-31'
paths:
/api/endpoint_list:
post:
x-labels: [serverless, ess]
x-codegen-enabled: true
operationId: CreateEndpointList
summary: Creates an endpoint list
description: Creates an endpoint list or does nothing if the list already exists
tags:
- Endpoint exceptions API
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '../model/endpoint_list_common.schema.yaml#/components/schemas/EndpointList'
400:
description: Invalid input data
content:
application/json:
schema:
oneOf:
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
403:
description: Insufficient privileges
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
500:
description: Internal server error
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'

View file

@ -0,0 +1,50 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Create endpoint list item API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
import {
ExceptionListItemHumanId,
ExceptionListItemType,
ExceptionListItemName,
ExceptionListItemDescription,
ExceptionListItemOsTypeArray,
ExceptionListItemTags,
ExceptionListItemMeta,
ExceptionListItemCommentArray,
} from '@kbn/securitysolution-exceptions-common/api/model/exception_list_common.gen';
import { ExceptionListItemEntryArray } from '@kbn/securitysolution-exceptions-common/api/model/exception_list_item_entry.gen';
import { EndpointListItem } from '../model/endpoint_list_common.gen';
export type CreateEndpointListItemRequestBody = z.infer<typeof CreateEndpointListItemRequestBody>;
export const CreateEndpointListItemRequestBody = z.object({
item_id: ExceptionListItemHumanId.optional(),
type: ExceptionListItemType,
name: ExceptionListItemName,
description: ExceptionListItemDescription,
entries: ExceptionListItemEntryArray,
os_types: ExceptionListItemOsTypeArray.optional().default([]),
tags: ExceptionListItemTags.optional().default([]),
meta: ExceptionListItemMeta.optional(),
comments: ExceptionListItemCommentArray.optional().default([]),
});
export type CreateEndpointListItemRequestBodyInput = z.input<
typeof CreateEndpointListItemRequestBody
>;
export type CreateEndpointListItemResponse = z.infer<typeof CreateEndpointListItemResponse>;
export const CreateEndpointListItemResponse = EndpointListItem;

View file

@ -0,0 +1,86 @@
openapi: 3.0.0
info:
title: Create endpoint list item API endpoint
version: '2023-10-31'
paths:
/api/endpoint_list/items:
post:
x-labels: [serverless, ess]
x-codegen-enabled: true
operationId: CreateEndpointListItem
summary: Creates an endpoint list item
tags:
- Endpoint exceptions API
requestBody:
description: Exception list item's properties
required: true
content:
application/json:
schema:
type: object
properties:
item_id:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemHumanId'
type:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemType'
name:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemName'
description:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemDescription'
entries:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_item_entry.schema.yaml#/components/schemas/ExceptionListItemEntryArray'
os_types:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemOsTypeArray'
default: []
tags:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemTags'
default: []
meta:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemMeta'
comments:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemCommentArray'
default: []
required:
- type
- name
- description
- entries
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '../model/endpoint_list_common.schema.yaml#/components/schemas/EndpointListItem'
400:
description: Invalid input data
content:
application/json:
schema:
oneOf:
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
403:
description: Insufficient privileges
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
409:
description: Endpoint list item already exists
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
500:
description: Internal server error
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'

View file

@ -0,0 +1,42 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Delete endpoint list item API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
import {
ExceptionListItemId,
ExceptionListItemHumanId,
} from '@kbn/securitysolution-exceptions-common/api/model/exception_list_common.gen';
import { EndpointListItem } from '../model/endpoint_list_common.gen';
export type DeleteEndpointListItemRequestQuery = z.infer<typeof DeleteEndpointListItemRequestQuery>;
export const DeleteEndpointListItemRequestQuery = z.object({
/**
* Either `id` or `item_id` must be specified
*/
id: ExceptionListItemId.optional(),
/**
* Either `id` or `item_id` must be specified
*/
item_id: ExceptionListItemHumanId.optional(),
});
export type DeleteEndpointListItemRequestQueryInput = z.input<
typeof DeleteEndpointListItemRequestQuery
>;
export type DeleteEndpointListItemResponse = z.infer<typeof DeleteEndpointListItemResponse>;
export const DeleteEndpointListItemResponse = EndpointListItem;

View file

@ -0,0 +1,65 @@
openapi: 3.0.0
info:
title: Delete endpoint list item API endpoint
version: '2023-10-31'
paths:
/api/endpoint_list/items:
delete:
x-labels: [serverless, ess]
x-codegen-enabled: true
operationId: DeleteEndpointListItem
summary: Deletes an endpoint list item
tags:
- Endpoint exceptions API
parameters:
- name: id
in: query
required: false
description: Either `id` or `item_id` must be specified
schema:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemId'
- name: item_id
in: query
required: false
description: Either `id` or `item_id` must be specified
schema:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemHumanId'
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '../model/endpoint_list_common.schema.yaml#/components/schemas/EndpointListItem'
400:
description: Invalid input data
content:
application/json:
schema:
oneOf:
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
403:
description: Insufficient privileges
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
404:
description: Endpoint list item not found
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
500:
description: Internal server error
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'

View file

@ -0,0 +1,62 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Find endpoint list items API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
import { EndpointListItem } from '../model/endpoint_list_common.gen';
export type FindEndpointListItemsFilter = z.infer<typeof FindEndpointListItemsFilter>;
export const FindEndpointListItemsFilter = NonEmptyString;
export type FindEndpointListItemsRequestQuery = z.infer<typeof FindEndpointListItemsRequestQuery>;
export const FindEndpointListItemsRequestQuery = z.object({
/**
* Filters the returned results according to the value of the specified field,
using the `<field name>:<field value>` syntax.
*/
filter: FindEndpointListItemsFilter.optional(),
/**
* The page number to return
*/
page: z.coerce.number().int().min(0).optional(),
/**
* The number of exception list items to return per page
*/
per_page: z.coerce.number().int().min(0).optional(),
/**
* Determines which field is used to sort the results
*/
sort_field: NonEmptyString.optional(),
/**
* Determines the sort order, which can be `desc` or `asc`
*/
sort_order: z.enum(['desc', 'asc']).optional(),
});
export type FindEndpointListItemsRequestQueryInput = z.input<
typeof FindEndpointListItemsRequestQuery
>;
export type FindEndpointListItemsResponse = z.infer<typeof FindEndpointListItemsResponse>;
export const FindEndpointListItemsResponse = z.object({
data: z.array(EndpointListItem),
page: z.number().int().min(0),
per_page: z.number().int().min(0),
total: z.number().int().min(0),
pit: z.string().optional(),
});

View file

@ -0,0 +1,114 @@
openapi: 3.0.0
info:
title: Find endpoint list items API endpoint
version: '2023-10-31'
paths:
/api/endpoint_list/items/_find:
get:
x-labels: [serverless, ess]
x-codegen-enabled: true
operationId: FindEndpointListItems
summary: Finds endpoint list items
tags:
- Endpoint exceptions API
parameters:
- name: filter
in: query
required: false
description: |
Filters the returned results according to the value of the specified field,
using the `<field name>:<field value>` syntax.
schema:
$ref: '#/components/schemas/FindEndpointListItemsFilter'
- name: page
in: query
required: false
description: The page number to return
schema:
type: integer
minimum: 0
- name: per_page
in: query
required: false
description: The number of exception list items to return per page
schema:
type: integer
minimum: 0
- name: sort_field
in: query
required: false
description: Determines which field is used to sort the results
schema:
$ref: '../../../kbn-openapi-common/schemas/primitives.schema.yaml#/components/schemas/NonEmptyString'
- name: sort_order
in: query
required: false
description: Determines the sort order, which can be `desc` or `asc`
schema:
type: string
enum: [desc, asc]
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '../model/endpoint_list_common.schema.yaml#/components/schemas/EndpointListItem'
page:
type: integer
minimum: 0
per_page:
type: integer
minimum: 0
total:
type: integer
minimum: 0
pit:
type: string
required:
- data
- page
- per_page
- total
400:
description: Invalid input data
content:
application/json:
schema:
oneOf:
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
403:
description: Insufficient privileges
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
404:
description: Endpoint list not found
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
500:
description: Internal server error
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
components:
schemas:
FindEndpointListItemsFilter:
$ref: '../../../kbn-openapi-common/schemas/primitives.schema.yaml#/components/schemas/NonEmptyString'

View file

@ -0,0 +1,14 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export * from './create_endpoint_list/create_endpoint_list.gen';
export * from './create_endpoint_list_item/create_endpoint_list_item.gen';
export * from './read_endpoint_list_item/read_endpoint_list_item.gen';
export * from './update_endpoint_list_item/update_endpoint_list_item.gen';
export * from './delete_endpoint_list_item/delete_endpoint_list_item.gen';
export * from './find_endpoint_list_item/find_endpoint_list_item.gen';

View file

@ -0,0 +1,29 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Common Exception List Attributes
* version: not applicable
*/
import { z } from 'zod';
import {
ExceptionList,
ExceptionListItem,
} from '@kbn/securitysolution-exceptions-common/api/model/exception_list_common.gen';
export type EndpointList = z.infer<typeof EndpointList>;
export const EndpointList = z.union([ExceptionList, z.object({}).strict()]);
export type EndpointListItem = z.infer<typeof EndpointListItem>;
export const EndpointListItem = ExceptionListItem;

View file

@ -0,0 +1,16 @@
openapi: 3.0.0
info:
title: Common Exception List Attributes
version: 'not applicable'
paths: {}
components:
x-codegen-enabled: true
schemas:
EndpointList:
oneOf:
- $ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionList'
- type: object
additionalProperties: false
EndpointListItem:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItem'

View file

@ -0,0 +1,42 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Read endpoint list item API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
import {
ExceptionListItemId,
ExceptionListItemHumanId,
} from '@kbn/securitysolution-exceptions-common/api/model/exception_list_common.gen';
import { EndpointListItem } from '../model/endpoint_list_common.gen';
export type ReadEndpointListItemRequestQuery = z.infer<typeof ReadEndpointListItemRequestQuery>;
export const ReadEndpointListItemRequestQuery = z.object({
/**
* Either `id` or `item_id` must be specified
*/
id: ExceptionListItemId.optional(),
/**
* Either `id` or `item_id` must be specified
*/
item_id: ExceptionListItemHumanId.optional(),
});
export type ReadEndpointListItemRequestQueryInput = z.input<
typeof ReadEndpointListItemRequestQuery
>;
export type ReadEndpointListItemResponse = z.infer<typeof ReadEndpointListItemResponse>;
export const ReadEndpointListItemResponse = z.array(EndpointListItem);

View file

@ -0,0 +1,67 @@
openapi: 3.0.0
info:
title: Read endpoint list item API endpoint
version: '2023-10-31'
paths:
/api/endpoint_list/items:
get:
x-labels: [serverless, ess]
x-codegen-enabled: true
operationId: ReadEndpointListItem
summary: Reads an endpoint list item
tags:
- Endpoint exceptions API
parameters:
- name: id
in: query
required: false
description: Either `id` or `item_id` must be specified
schema:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemId'
- name: item_id
in: query
required: false
description: Either `id` or `item_id` must be specified
schema:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemHumanId'
responses:
200:
description: Successful response
content:
application/json:
schema:
type: array
items:
$ref: '../model/endpoint_list_common.schema.yaml#/components/schemas/EndpointListItem'
400:
description: Invalid input data
content:
application/json:
schema:
oneOf:
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
403:
description: Insufficient privileges
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
404:
description: Endpoint list item not found
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
500:
description: Internal server error
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'

View file

@ -0,0 +1,59 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Update endpoint list item API endpoint
* version: 2023-10-31
*/
import { z } from 'zod';
import {
ExceptionListItemId,
ExceptionListItemHumanId,
ExceptionListItemType,
ExceptionListItemName,
ExceptionListItemDescription,
ExceptionListItemOsTypeArray,
ExceptionListItemTags,
ExceptionListItemMeta,
ExceptionListItemCommentArray,
} from '@kbn/securitysolution-exceptions-common/api/model/exception_list_common.gen';
import { ExceptionListItemEntryArray } from '@kbn/securitysolution-exceptions-common/api/model/exception_list_item_entry.gen';
import { EndpointListItem } from '../model/endpoint_list_common.gen';
export type UpdateEndpointListItemRequestBody = z.infer<typeof UpdateEndpointListItemRequestBody>;
export const UpdateEndpointListItemRequestBody = z.object({
/**
* Either `id` or `item_id` must be specified
*/
id: ExceptionListItemId.optional(),
/**
* Either `id` or `item_id` must be specified
*/
item_id: ExceptionListItemHumanId.optional(),
type: ExceptionListItemType,
name: ExceptionListItemName,
description: ExceptionListItemDescription,
entries: ExceptionListItemEntryArray,
os_types: ExceptionListItemOsTypeArray.optional().default([]),
tags: ExceptionListItemTags.optional(),
meta: ExceptionListItemMeta.optional(),
comments: ExceptionListItemCommentArray.optional().default([]),
_version: z.string().optional(),
});
export type UpdateEndpointListItemRequestBodyInput = z.input<
typeof UpdateEndpointListItemRequestBody
>;
export type UpdateEndpointListItemResponse = z.infer<typeof UpdateEndpointListItemResponse>;
export const UpdateEndpointListItemResponse = EndpointListItem;

View file

@ -0,0 +1,91 @@
openapi: 3.0.0
info:
title: Update endpoint list item API endpoint
version: '2023-10-31'
paths:
/api/endpoint_list/items:
put:
x-labels: [serverless, ess]
x-codegen-enabled: true
operationId: UpdateEndpointListItem
summary: Updates an endpoint list item
tags:
- Endpoint exceptions API
requestBody:
description: Exception list item's properties
required: true
content:
application/json:
schema:
type: object
properties:
id:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemId'
description: Either `id` or `item_id` must be specified
item_id:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemHumanId'
description: Either `id` or `item_id` must be specified
type:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemType'
name:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemName'
description:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemDescription'
entries:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_item_entry.schema.yaml#/components/schemas/ExceptionListItemEntryArray'
os_types:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemOsTypeArray'
default: []
tags:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemTags'
meta:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemMeta'
comments:
$ref: '../../../kbn-securitysolution-exceptions-common/api/model/exception_list_common.schema.yaml#/components/schemas/ExceptionListItemCommentArray'
default: []
_version:
type: string
required:
- type
- name
- description
- entries
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '../model/endpoint_list_common.schema.yaml#/components/schemas/EndpointListItem'
400:
description: Invalid input data
content:
application/json:
schema:
oneOf:
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
403:
description: Insufficient privileges
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
404:
description: Endpoint list item not found
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
500:
description: Internal server error
content:
application/json:
schema:
$ref: '../../../kbn-openapi-common/schemas/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'

View file

@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/securitysolution-endpoint-exceptions-common",
"owner": "@elastic/security-detection-engine"
}

View file

@ -0,0 +1,10 @@
{
"description": "OpenAPI Endpoint Exceptions Common",
"license": "SSPL-1.0 OR Elastic License 2.0",
"name": "@kbn/securitysolution-endpoint-exceptions-common",
"private": true,
"version": "1.0.0",
"scripts": {
"openapi:generate": "node scripts/openapi_generate"
}
}

View file

@ -0,0 +1,37 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
require('../../../src/setup_node_env');
const { join, resolve } = require('path');
const { generate } = require('@kbn/openapi-generator');
const { REPO_ROOT } = require('@kbn/repo-info');
const ROOT = resolve(__dirname, '..');
(async () => {
await generate({
title: 'OpenAPI Endpoint Exceptions API Schemas',
rootDir: ROOT,
sourceGlob: './api/**/*.schema.yaml',
templateName: 'zod_operation_schema',
});
await generate({
title: 'Endpoint Exceptions API client for tests',
rootDir: ROOT,
sourceGlob: './api/**/*.schema.yaml',
templateName: 'api_client_supertest',
skipLinting: true,
bundle: {
outFile: join(
REPO_ROOT,
'x-pack/test/api_integration/services/security_solution_endpoint_exceptions_api.gen.ts'
),
},
});
})();

View file

@ -0,0 +1,10 @@
{
"compilerOptions": {
"outDir": "target/types",
"types": ["jest", "node"]
},
"exclude": ["target/**/*"],
"extends": "../../tsconfig.base.json",
"include": ["**/*.ts"],
"kbn_references": ["@kbn/securitysolution-exceptions-common", "@kbn/openapi-common"]
}

View file

@ -1502,6 +1502,8 @@
"@kbn/securitysolution-data-table/*": ["x-pack/packages/security-solution/data_table/*"],
"@kbn/securitysolution-ecs": ["packages/kbn-securitysolution-ecs"],
"@kbn/securitysolution-ecs/*": ["packages/kbn-securitysolution-ecs/*"],
"@kbn/securitysolution-endpoint-exceptions-common": ["packages/kbn-securitysolution-endpoint-exceptions-common"],
"@kbn/securitysolution-endpoint-exceptions-common/*": ["packages/kbn-securitysolution-endpoint-exceptions-common/*"],
"@kbn/securitysolution-es-utils": ["packages/kbn-securitysolution-es-utils"],
"@kbn/securitysolution-es-utils/*": ["packages/kbn-securitysolution-es-utils/*"],
"@kbn/securitysolution-exception-list-components": ["packages/kbn-securitysolution-exception-list-components"],
@ -1892,9 +1894,7 @@
"@kbn/zod-helpers/*": ["packages/kbn-zod-helpers/*"],
// END AUTOMATED PACKAGE LISTING
// Allows for importing from `kibana` package for the exported types.
"@emotion/core": [
"typings/@emotion"
]
"@emotion/core": ["typings/@emotion"]
},
// Support .tsx files and transform JSX into calls to React.createElement
"jsx": "react",

View file

@ -1,14 +0,0 @@
/*
* 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 {
CreateEndpointListSchema,
createEndpointListSchema,
} from '@kbn/securitysolution-io-ts-list-types';
export const createEndpointListResponse = createEndpointListSchema;
export type CreateEndpointListResponse = CreateEndpointListSchema;

View file

@ -1,19 +0,0 @@
/*
* 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 {
CreateEndpointListItemSchemaDecoded,
ExceptionListItemSchema,
createEndpointListItemSchema,
exceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
export { createEndpointListItemSchema as createEndpointListItemRequest };
export type { CreateEndpointListItemSchemaDecoded as CreateEndpointListItemRequestDecoded };
export const createEndpointListItemResponse = exceptionListItemSchema;
export type CreateEndpointListItemResponse = ExceptionListItemSchema;

View file

@ -1,18 +0,0 @@
/*
* 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 {
DeleteEndpointListItemSchemaDecoded,
deleteEndpointListItemSchema,
exceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
export {
deleteEndpointListItemSchema as deleteEndpointListItemRequestQuery,
exceptionListItemSchema as deleteEndpointListItemResponse,
};
export type { DeleteEndpointListItemSchemaDecoded as DeleteEndpointListItemRequestQueryDecoded };

View file

@ -1,18 +0,0 @@
/*
* 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 {
FindEndpointListItemSchemaDecoded,
findEndpointListItemSchema,
foundExceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
export {
findEndpointListItemSchema as findEndpointListItemRequestQuery,
foundExceptionListItemSchema as findEndpointListItemResponse,
};
export type { FindEndpointListItemSchemaDecoded as FindEndpointListItemRequestQueryDecoded };

View file

@ -1,18 +0,0 @@
/*
* 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 {
ReadEndpointListItemSchemaDecoded,
exceptionListItemSchema,
readEndpointListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
export {
readEndpointListItemSchema as readEndpointListItemRequestQuery,
exceptionListItemSchema as readEndpointListItemResponse,
};
export type { ReadEndpointListItemSchemaDecoded as ReadEndpointListItemRequestQueryDecoded };

View file

@ -1,18 +0,0 @@
/*
* 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 {
UpdateEndpointListItemSchemaDecoded,
exceptionListItemSchema,
updateEndpointListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
export {
updateEndpointListItemSchema as updateEndpointListItemRequest,
exceptionListItemSchema as updateEndpointListItemResponse,
};
export type { UpdateEndpointListItemSchemaDecoded as UpdateEndpointListItemRequestDecoded };

View file

@ -5,12 +5,6 @@
* 2.0.
*/
export * from './exceptions/create_endpoint_list_item/create_endpoint_list_item_route';
export * from './exceptions/create_endpoint_list/create_endpoint_list_route';
export * from './exceptions/create_exception_list/create_exception_list_route';
export * from './exceptions/delete_endpoint_list_item/delete_endpoint_list_item_route';
export * from './exceptions/find_endpoint_list_item/find_endpoint_list_item_route';
export * from './exceptions/get_exception_filter/get_exception_filter_route';
export * from './exceptions/read_endpoint_list_item/read_endpoint_list_item_route';
export * from './exceptions/update_endpoint_list_item/update_endpoint_list_item_route';
export * from './values/find_lists_by_size/find_lists_by_size_route';

View file

@ -5,18 +5,18 @@
* 2.0.
*/
import { validate } from '@kbn/securitysolution-io-ts-utils';
import { v4 as uuidv4 } from 'uuid';
import { transformError } from '@kbn/securitysolution-es-utils';
import { ENDPOINT_LIST_ID, ENDPOINT_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod, stringifyZodError } from '@kbn/zod-helpers';
import {
CreateEndpointListItemRequestDecoded,
createEndpointListItemRequest,
createEndpointListItemResponse,
} from '../../common/api';
CreateEndpointListItemRequestBody,
CreateEndpointListItemResponse,
} from '@kbn/securitysolution-endpoint-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
import { buildRouteValidation, buildSiemResponse, getExceptionListClient } from './utils';
import { buildSiemResponse, getExceptionListClient } from './utils';
import { validateExceptionListSize } from './validate';
export const createEndpointListItemRoute = (router: ListsPluginRouter): void => {
@ -32,10 +32,7 @@ export const createEndpointListItemRoute = (router: ListsPluginRouter): void =>
{
validate: {
request: {
body: buildRouteValidation<
typeof createEndpointListItemRequest,
CreateEndpointListItemRequestDecoded
>(createEndpointListItemRequest),
body: buildRouteValidationWithZod(CreateEndpointListItemRequestBody),
},
},
version: '2023-10-31',
@ -50,7 +47,7 @@ export const createEndpointListItemRoute = (router: ListsPluginRouter): void =>
comments,
description,
entries,
item_id: itemId,
item_id: itemId = uuidv4(),
os_types: osTypes,
type,
} = request.body;
@ -76,9 +73,10 @@ export const createEndpointListItemRoute = (router: ListsPluginRouter): void =>
tags,
type,
});
const [validated, errors] = validate(createdList, createEndpointListItemResponse);
if (errors != null) {
return siemResponse.error({ body: errors, statusCode: 500 });
const { success, data, error } = CreateEndpointListItemResponse.safeParse(createdList);
if (success === false) {
return siemResponse.error({ body: stringifyZodError(error), statusCode: 500 });
} else {
const listSizeError = await validateExceptionListSize(
exceptionLists,
@ -92,7 +90,7 @@ export const createEndpointListItemRoute = (router: ListsPluginRouter): void =>
});
return siemResponse.error(listSizeError);
}
return response.ok({ body: validated ?? {} });
return response.ok({ body: data ?? {} });
}
}
} catch (err) {

View file

@ -5,12 +5,11 @@
* 2.0.
*/
import { validate } from '@kbn/securitysolution-io-ts-utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import { ENDPOINT_LIST_URL } from '@kbn/securitysolution-list-constants';
import { CreateEndpointListResponse } from '@kbn/securitysolution-endpoint-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
import { createEndpointListResponse } from '../../common/api';
import { buildSiemResponse } from './utils';
import { getExceptionListClient } from './utils/get_exception_list_client';
@ -43,18 +42,15 @@ export const createEndpointListRoute = (router: ListsPluginRouter): void => {
try {
const exceptionLists = await getExceptionListClient(context);
const createdList = await exceptionLists.createEndpointList();
// We always return ok on a create endpoint list route but with an empty body as
// an additional fetch of the full list would be slower and the UI has everything hard coded
// within it to get the list if it needs details about it. Our goal is to be as fast as possible
// and block the least amount of time with this route since it could end up in various parts of the
// stack at some point such as repeatedly being called by endpoint agents.
const body = createdList ?? {};
const [validated, errors] = validate(body, createEndpointListResponse);
if (errors != null) {
return siemResponse.error({ body: errors, statusCode: 500 });
} else {
return response.ok({ body: validated ?? {} });
}
return response.ok({
body: CreateEndpointListResponse.parse(createdList ?? {}),
});
} catch (err) {
const error = transformError(err);
return siemResponse.error({

View file

@ -5,19 +5,17 @@
* 2.0.
*/
import { validate } from '@kbn/securitysolution-io-ts-utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import { ENDPOINT_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
DeleteEndpointListItemRequestQuery,
DeleteEndpointListItemResponse,
} from '@kbn/securitysolution-endpoint-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
import {
DeleteEndpointListItemRequestQueryDecoded,
deleteEndpointListItemRequestQuery,
deleteEndpointListItemResponse,
} from '../../common/api';
import {
buildRouteValidation,
buildSiemResponse,
getErrorMessageExceptionListItem,
getExceptionListClient,
@ -36,10 +34,7 @@ export const deleteEndpointListItemRoute = (router: ListsPluginRouter): void =>
{
validate: {
request: {
query: buildRouteValidation<
typeof deleteEndpointListItemRequestQuery,
DeleteEndpointListItemRequestQueryDecoded
>(deleteEndpointListItemRequestQuery),
query: buildRouteValidationWithZod(DeleteEndpointListItemRequestQuery),
},
},
version: '2023-10-31',
@ -65,12 +60,7 @@ export const deleteEndpointListItemRoute = (router: ListsPluginRouter): void =>
statusCode: 404,
});
} else {
const [validated, errors] = validate(deleted, deleteEndpointListItemResponse);
if (errors != null) {
return siemResponse.error({ body: errors, statusCode: 500 });
} else {
return response.ok({ body: validated ?? {} });
}
return response.ok({ body: DeleteEndpointListItemResponse.parse(deleted) });
}
}
} catch (err) {

View file

@ -5,18 +5,17 @@
* 2.0.
*/
import { validate } from '@kbn/securitysolution-io-ts-utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import { ENDPOINT_LIST_ID, ENDPOINT_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
FindEndpointListItemsRequestQuery,
FindEndpointListItemsResponse,
} from '@kbn/securitysolution-endpoint-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
import {
FindEndpointListItemRequestQueryDecoded,
findEndpointListItemRequestQuery,
findEndpointListItemResponse,
} from '../../common/api';
import { buildRouteValidation, buildSiemResponse, getExceptionListClient } from './utils';
import { buildSiemResponse, getExceptionListClient } from './utils';
export const findEndpointListItemRoute = (router: ListsPluginRouter): void => {
router.versioned
@ -31,10 +30,7 @@ export const findEndpointListItemRoute = (router: ListsPluginRouter): void => {
{
validate: {
request: {
query: buildRouteValidation<
typeof findEndpointListItemRequestQuery,
FindEndpointListItemRequestQueryDecoded
>(findEndpointListItemRequestQuery),
query: buildRouteValidationWithZod(FindEndpointListItemsRequestQuery),
},
},
version: '2023-10-31',
@ -69,12 +65,8 @@ export const findEndpointListItemRoute = (router: ListsPluginRouter): void => {
statusCode: 404,
});
}
const [validated, errors] = validate(exceptionListItems, findEndpointListItemResponse);
if (errors != null) {
return siemResponse.error({ body: errors, statusCode: 500 });
} else {
return response.ok({ body: validated ?? {} });
}
return response.ok({ body: FindEndpointListItemsResponse.parse(exceptionListItems) });
} catch (err) {
const error = transformError(err);
return siemResponse.error({

View file

@ -5,19 +5,17 @@
* 2.0.
*/
import { validate } from '@kbn/securitysolution-io-ts-utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import { ENDPOINT_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
ReadEndpointListItemRequestQuery,
ReadEndpointListItemResponse,
} from '@kbn/securitysolution-endpoint-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
import {
ReadEndpointListItemRequestQueryDecoded,
readEndpointListItemRequestQuery,
readEndpointListItemResponse,
} from '../../common/api';
import {
buildRouteValidation,
buildSiemResponse,
getErrorMessageExceptionListItem,
getExceptionListClient,
@ -36,10 +34,7 @@ export const readEndpointListItemRoute = (router: ListsPluginRouter): void => {
{
validate: {
request: {
query: buildRouteValidation<
typeof readEndpointListItemRequestQuery,
ReadEndpointListItemRequestQueryDecoded
>(readEndpointListItemRequestQuery),
query: buildRouteValidationWithZod(ReadEndpointListItemRequestQuery),
},
},
version: '2023-10-31',
@ -60,12 +55,7 @@ export const readEndpointListItemRoute = (router: ListsPluginRouter): void => {
statusCode: 404,
});
} else {
const [validated, errors] = validate(exceptionListItem, readEndpointListItemResponse);
if (errors != null) {
return siemResponse.error({ body: errors, statusCode: 500 });
} else {
return response.ok({ body: validated ?? {} });
}
return response.ok({ body: ReadEndpointListItemResponse.parse(exceptionListItem) });
}
} else {
return siemResponse.error({ body: 'id or item_id required', statusCode: 400 });

View file

@ -5,18 +5,17 @@
* 2.0.
*/
import { validate } from '@kbn/securitysolution-io-ts-utils';
import { transformError } from '@kbn/securitysolution-es-utils';
import { ENDPOINT_LIST_ITEM_URL } from '@kbn/securitysolution-list-constants';
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
import {
UpdateEndpointListItemRequestBody,
UpdateEndpointListItemResponse,
} from '@kbn/securitysolution-endpoint-exceptions-common/api';
import type { ListsPluginRouter } from '../types';
import {
UpdateEndpointListItemRequestDecoded,
updateEndpointListItemRequest,
updateEndpointListItemResponse,
} from '../../common/api';
import { buildRouteValidation, buildSiemResponse } from './utils';
import { buildSiemResponse } from './utils';
import { getExceptionListClient } from '.';
@ -33,10 +32,7 @@ export const updateEndpointListItemRoute = (router: ListsPluginRouter): void =>
{
validate: {
request: {
body: buildRouteValidation<
typeof updateEndpointListItemRequest,
UpdateEndpointListItemRequestDecoded
>(updateEndpointListItemRequest),
body: buildRouteValidationWithZod(UpdateEndpointListItemRequestBody),
},
},
version: '2023-10-31',
@ -84,12 +80,7 @@ export const updateEndpointListItemRoute = (router: ListsPluginRouter): void =>
});
}
} else {
const [validated, errors] = validate(exceptionListItem, updateEndpointListItemResponse);
if (errors != null) {
return siemResponse.error({ body: errors, statusCode: 500 });
} else {
return response.ok({ body: validated ?? {} });
}
return response.ok({ body: UpdateEndpointListItemResponse.parse(exceptionListItem) });
}
} catch (err) {
const error = transformError(err);

View file

@ -21,6 +21,7 @@
"@kbn/securitysolution-list-api",
"@kbn/securitysolution-lists-common",
"@kbn/securitysolution-exceptions-common",
"@kbn/securitysolution-endpoint-exceptions-common",
"@kbn/kibana-react-plugin",
"@kbn/i18n",
"@kbn/data-plugin",

View file

@ -0,0 +1,100 @@
/*
* 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.
*/
/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Endpoint Exceptions API client for tests
* version: Bundle (no version)
*/
import {
ELASTIC_HTTP_VERSION_HEADER,
X_ELASTIC_INTERNAL_ORIGIN_REQUEST,
} from '@kbn/core-http-common';
import { CreateEndpointListItemRequestBodyInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/create_endpoint_list_item/create_endpoint_list_item.gen';
import { DeleteEndpointListItemRequestQueryInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/delete_endpoint_list_item/delete_endpoint_list_item.gen';
import { FindEndpointListItemsRequestQueryInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/find_endpoint_list_item/find_endpoint_list_item.gen';
import { ReadEndpointListItemRequestQueryInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/read_endpoint_list_item/read_endpoint_list_item.gen';
import { UpdateEndpointListItemRequestBodyInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/update_endpoint_list_item/update_endpoint_list_item.gen';
import { FtrProviderContext } from '../ftr_provider_context';
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
return {
/**
* Creates an endpoint list or does nothing if the list already exists
*/
createEndpointList() {
return supertest
.post('/api/endpoint_list')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana');
},
createEndpointListItem(props: CreateEndpointListItemProps) {
return supertest
.post('/api/endpoint_list/items')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.send(props.body as object);
},
deleteEndpointListItem(props: DeleteEndpointListItemProps) {
return supertest
.delete('/api/endpoint_list/items')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
findEndpointListItems(props: FindEndpointListItemsProps) {
return supertest
.get('/api/endpoint_list/items/_find')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
readEndpointListItem(props: ReadEndpointListItemProps) {
return supertest
.get('/api/endpoint_list/items')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.query(props.query);
},
updateEndpointListItem(props: UpdateEndpointListItemProps) {
return supertest
.put('/api/endpoint_list/items')
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31')
.set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana')
.send(props.body as object);
},
};
}
export interface CreateEndpointListItemProps {
body: CreateEndpointListItemRequestBodyInput;
}
export interface DeleteEndpointListItemProps {
query: DeleteEndpointListItemRequestQueryInput;
}
export interface FindEndpointListItemsProps {
query: FindEndpointListItemsRequestQueryInput;
}
export interface ReadEndpointListItemProps {
query: ReadEndpointListItemRequestQueryInput;
}
export interface UpdateEndpointListItemProps {
body: UpdateEndpointListItemRequestBodyInput;
}

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { CreateEndpointListItemResponse } from '@kbn/lists-plugin/common/api';
import { CreateEndpointListItemResponse } from '@kbn/securitysolution-endpoint-exceptions-common/api';
import type {
ExceptionListSchema,
ExceptionListItemSchema,

View file

@ -33,7 +33,6 @@
"@kbn/security-solution-plugin",
"@kbn/dev-utils",
"@kbn/config-schema",
"@kbn/lists-plugin",
"@kbn/securitysolution-list-constants",
"@kbn/security-plugin",
"@kbn/management-settings-ids",
@ -42,5 +41,6 @@
"@kbn/license-management-plugin",
"@kbn/actions-plugin",
"@kbn/alerts-ui-shared",
"@kbn/securitysolution-endpoint-exceptions-common",
]
}

View file

@ -174,6 +174,7 @@
"@kbn/openapi-common",
"@kbn/securitysolution-lists-common",
"@kbn/securitysolution-exceptions-common",
"@kbn/securitysolution-endpoint-exceptions-common",
"@kbn/entityManager-plugin",
"@kbn/osquery-plugin",
"@kbn/entities-schema"

View file

@ -6269,6 +6269,10 @@
version "0.0.0"
uid ""
"@kbn/securitysolution-endpoint-exceptions-common@link:packages/kbn-securitysolution-endpoint-exceptions-common":
version "0.0.0"
uid ""
"@kbn/securitysolution-es-utils@link:packages/kbn-securitysolution-es-utils":
version "0.0.0"
uid ""