Skip to content

Commit

Permalink
[Security Solution] Add missing Endpoint Exceptions API OpenAPI speci…
Browse files Browse the repository at this point in the history
…fications (elastic#186082)

**Resolves:** elastic#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`
  • Loading branch information
maximpn authored Jul 29, 2024
1 parent 0c45b11 commit ecbe36d
Show file tree
Hide file tree
Showing 42 changed files with 1,052 additions and 209 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions packages/kbn-securitysolution-endpoint-exceptions-common/README.md
Original file line number Diff line number Diff line change
@@ -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';
```
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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'
Loading

0 comments on commit ecbe36d

Please sign in to comment.