Skip to content

Commit

Permalink
[SecuritySolution][Endpoint] Open API spec updates for public Endpoin…
Browse files Browse the repository at this point in the history
…t APIs (elastic#187634)

## Summary

Updates/Adds Open API specs for existing public Endpoint APIs. The PR
includes deperated API schemas as well but we can remove them if we all
agree to it.

Note: The PR doesn't change existing kibana schemas that is used in our
server routes and most of the changes in here are file moves and
updating imports to unify duplicate naming/import. This to ensure that
we can easily maintain the open api specs going forward. The best way to
review this is by looking at commits. The major moving cleaning up
happens after commit names prefixed with **_refactor_** or
`645fbc0f1d8ecc402e81f9503c7c5d1473ef49c0` and onwards. I would also
suggest hiding whitespaces when reviewing via Github.

closes elastic/issues/183816

### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
ashokaditya and kibanamachine authored Aug 7, 2024
1 parent fe1b7b1 commit f3aeb81
Show file tree
Hide file tree
Showing 126 changed files with 1,906 additions and 1,082 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Audit Log Schema
* title: Action Log Schema
* version: 2023-10-31
*/

import { z } from 'zod';

import { Page, PageSize, StartDate, EndDate, AgentId } from '../model/schema/common.gen';
import { Page, PageSize, StartDate, EndDate } from '../../model/schema/common.gen';

export type AuditLogRequestQuery = z.infer<typeof AuditLogRequestQuery>;
export const AuditLogRequestQuery = z.object({
export type ActionLogRequestQuery = z.infer<typeof ActionLogRequestQuery>;
export const ActionLogRequestQuery = z.object({
page: Page.optional(),
page_size: PageSize.optional(),
start_date: StartDate.optional(),
end_date: EndDate.optional(),
});

export type AuditLogRequestParams = z.infer<typeof AuditLogRequestParams>;
export const AuditLogRequestParams = z.object({
agent_id: AgentId.optional(),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
openapi: 3.0.0
info:
title: Action Log Schema
version: '2023-10-31'
paths:
/api/endpoint/action_log/{agent_id}:
get:
summary: Get action requests log schema
operationId: EndpointGetActionLog
description: Get action requests log
deprecated: true
x-codegen-enabled: false
x-labels: [ess, serverless]
parameters:
- name: agent_id
in: path
required: true
schema:
$ref: '../../model/schema/common.schema.yaml#/components/schemas/AgentId'
- name: query
in: query
required: true
schema:
$ref: '#/components/schemas/ActionLogRequestQuery'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../../model/schema/common.schema.yaml#/components/schemas/SuccessResponse'

components:
schemas:
ActionLogRequestQuery:
type: object
properties:
page:
$ref: '../../model/schema/common.schema.yaml#/components/schemas/Page'
page_size:
$ref: '../../model/schema/common.schema.yaml#/components/schemas/PageSize'
start_date:
$ref: '../../model/schema/common.schema.yaml#/components/schemas/StartDate'
end_date:
$ref: '../../model/schema/common.schema.yaml#/components/schemas/EndDate'
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
* 2.0.
*/

import { NoParametersRequestSchema } from './common/base';

export const UnisolateRouteRequestSchema = NoParametersRequestSchema;
export * from './action_log';
export * from './deprecated_action_log.gen';

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@

import type { TypeOf } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';
import {
KillProcessRouteRequestSchema,
SuspendProcessRouteRequestSchema,
UploadActionRequestSchema,
} from '../..';
import { ExecuteActionRequestSchema } from '../execute_route';
import { EndpointActionGetFileSchema } from '../get_file_route';
import { ScanActionRequestSchema } from '../scan_route';
import { NoParametersRequestSchema } from './base';

import { ExecuteActionRequestSchema } from '../response_actions/execute';
import { EndpointActionGetFileSchema } from '../response_actions/get_file';
import { ScanActionRequestSchema } from '../response_actions/scan';
import { IsolateRouteRequestSchema } from '../response_actions/isolate';
import { UnisolateRouteRequestSchema } from '../response_actions/unisolate';
import { GetProcessesRouteRequestSchema } from '../response_actions/running_procs';
import { KillProcessRouteRequestSchema } from '../response_actions/kill_process';
import { SuspendProcessRouteRequestSchema } from '../response_actions/suspend_process';
import { UploadActionRequestSchema } from '../response_actions/upload';

export const ResponseActionBodySchema = schema.oneOf([
NoParametersRequestSchema.body,
IsolateRouteRequestSchema.body,
UnisolateRouteRequestSchema.body,
GetProcessesRouteRequestSchema.body,
KillProcessRouteRequestSchema.body,
SuspendProcessRouteRequestSchema.body,
EndpointActionGetFileSchema.body,
ExecuteActionRequestSchema.body,
ScanActionRequestSchema.body,
UploadActionRequestSchema.body,
ScanActionRequestSchema.body,
]);

export type ResponseActionsRequestBody = TypeOf<typeof ResponseActionBodySchema>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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: Details Schema
* version: 2023-10-31
*/

import { z } from 'zod';

import { SuccessResponse } from '../../model/schema/common.gen';

export type EndpointGetActionsDetailsRequestParams = z.infer<
typeof EndpointGetActionsDetailsRequestParams
>;
export const EndpointGetActionsDetailsRequestParams = z.object({
action_id: z.string(),
});
export type EndpointGetActionsDetailsRequestParamsInput = z.input<
typeof EndpointGetActionsDetailsRequestParams
>;

export type EndpointGetActionsDetailsResponse = z.infer<typeof EndpointGetActionsDetailsResponse>;
export const EndpointGetActionsDetailsResponse = SuccessResponse;
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,21 @@ paths:
get:
summary: Get Action details schema
operationId: EndpointGetActionsDetails
x-codegen-enabled: false
x-labels:
- ess
- serverless
description: Get action details
x-codegen-enabled: true
x-labels: [ess, serverless]
parameters:
- name: query
- name: action_id
in: path
required: true
schema:
$ref: '#/components/schemas/DetailsRequestParams'
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../model/schema/common.schema.yaml#/components/schemas/SuccessResponse'
components:
schemas:
DetailsRequestParams:
type: object
properties:
action_id:
type: string
$ref: '../../model/schema/common.schema.yaml#/components/schemas/SuccessResponse'


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './details';
export * from './details.gen';
Loading

0 comments on commit f3aeb81

Please sign in to comment.