Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][POC] Bundle Security Solution OAS per domain #183026

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .buildkite/scripts/steps/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export DISABLE_BOOTSTRAP_VALIDATION=false
.buildkite/scripts/steps/checks/saved_objects_definition_change.sh
.buildkite/scripts/steps/code_generation/elastic_assistant_codegen.sh
.buildkite/scripts/steps/code_generation/security_solution_codegen.sh
.buildkite/scripts/steps/openapi_bundling/security_solution_openapi_bundling.sh
.buildkite/scripts/steps/code_generation/osquery_codegen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

echo --- Security Solution OpenAPI Bundling

(cd x-pack/plugins/security_solution && yarn openapi:bundle)
check_for_changed_files "yarn openapi:bundle" true
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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 { z } from 'zod';
import { ArrayFromString, BooleanFromString } from '@kbn/zod-helpers';

/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Find Rules API endpoint
* version: 2024-05-15
*/

import { SortOrder } from '../../model/sorting.gen';
import { RuleResponse } from '../../model/rule_schema/rule_schemas.gen';

export type Pagination = z.infer<typeof Pagination>;
export const Pagination = z.object({
page: z.number().int().optional(),
per_page: z.number().int().optional(),
total: z.number().int().optional(),
});

export type FindRulesV2SortField = z.infer<typeof FindRulesV2SortField>;
export const FindRulesV2SortField = z.enum([
'created_at',
'createdAt',
'enabled',
'execution_summary.last_execution.date',
'execution_summary.last_execution.metrics.execution_gap_duration_s',
'execution_summary.last_execution.metrics.total_indexing_duration_ms',
'execution_summary.last_execution.metrics.total_search_duration_ms',
'execution_summary.last_execution.status',
'name',
'risk_score',
'riskScore',
'severity',
'updated_at',
'updatedAt',
]);
export type FindRulesV2SortFieldEnum = typeof FindRulesV2SortField.enum;
export const FindRulesV2SortFieldEnum = FindRulesV2SortField.enum;

export type FindRulesV2RequestQuery = z.infer<typeof FindRulesV2RequestQuery>;
export const FindRulesV2RequestQuery = z.object({
/**
* Filter rules
*/
filter: z.object({
/**
* Filter by tag(s), e.g. ["tag1", "tag2"]
*/
tags: ArrayFromString(z.string()).optional(),
/**
* Filter by enabled status
*/
enabled: BooleanFromString.optional(),
/**
* Filter by rule source
*/
source: z.enum(['custom', 'prebuilt', 'customized']).optional(),
}),
fields: ArrayFromString(z.string()).optional(),
/**
* Field to sort by
*/
sort_field: FindRulesV2SortField.optional(),
/**
* Sort order
*/
sort_order: SortOrder.optional(),
/**
* Page number
*/
page: z.coerce.number().int().min(1).optional().default(1),
/**
* Rules per page
*/
per_page: z.coerce.number().int().min(0).optional().default(20),
});
export type FindRulesV2RequestQueryInput = z.input<typeof FindRulesV2RequestQuery>;

export type FindRulesV2Response = z.infer<typeof FindRulesV2Response>;
export const FindRulesV2Response = z.object({
rules: z.array(RuleResponse),
pagination: Pagination,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
openapi: 3.0.0
info:
title: Find Rules API endpoint
version: '2024-05-15'
paths:
/api/detection_engine/rules/_find:
get:
operationId: FindRulesV2
x-codegen-enabled: true
description: Finds rules that match the given query.
tags:
- Rules API
parameters:
- name: 'filter'
in: query
description: Filter rules
required: false
schema:
type: object
properties:
tags:
type: array
description: Filter by tag(s), e.g. ["tag1", "tag2"]
items:
type: string
enabled:
type: boolean
description: Filter by enabled status
source:
type: string
description: Filter by rule source
enum:
- custom
- prebuilt
- customized
- name: 'fields'
in: query
required: false
schema:
type: array
items:
type: string
- name: 'sort_field'
in: query
description: Field to sort by
required: false
schema:
$ref: '#/components/schemas/FindRulesV2SortField'
- name: 'sort_order'
in: query
description: Sort order
required: false
schema:
$ref: '../../model/sorting.schema.yaml#/components/schemas/SortOrder'
- name: 'page'
in: query
description: Page number
required: false
schema:
type: integer
minimum: 1
default: 1
- name: 'per_page'
in: query
description: Rules per page
required: false
schema:
type: integer
minimum: 0
default: 20

responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
rules:
type: array
items:
$ref: '../../model/rule_schema/rule_schemas.schema.yaml#/components/schemas/RuleResponse'
pagination:
$ref: '#/components/schemas/Pagination'
required:
- rules
- pagination

components:
schemas:
Pagination:
type: object
properties:
page:
type: integer
per_page:
type: integer
total:
type: integer
required:
page:
type: integer
per_page:
type: integer
total:
type: integer

FindRulesV2SortField:
type: string
enum:
- 'created_at'
- 'createdAt' # Legacy notation, keeping for backwards compatibility
- 'enabled'
- 'execution_summary.last_execution.date'
- 'execution_summary.last_execution.metrics.execution_gap_duration_s'
- 'execution_summary.last_execution.metrics.total_indexing_duration_ms'
- 'execution_summary.last_execution.metrics.total_search_duration_ms'
- 'execution_summary.last_execution.status'
- 'name'
- 'risk_score'
- 'riskScore' # Legacy notation, keeping for backwards compatibility
- 'severity'
- 'updated_at'
- 'updatedAt' # Legacy notation, keeping for backwards compatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 { z } from 'zod';
import { BooleanFromString } from '@kbn/zod-helpers';

/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Import Rules API endpoint
* version: 2024-05-15
*/

import { RuleCreateProps } from '../../model/rule_schema/rule_schemas.gen';
import { ErrorSchema } from '../../model/error_schema.gen';

export type ImportRulesV2RequestQuery = z.infer<typeof ImportRulesV2RequestQuery>;
export const ImportRulesV2RequestQuery = z.object({
/**
* Determines whether existing rules with the same `rule_id` are overwritten.
*/
overwrite: BooleanFromString.optional().default(false),
/**
* Determines whether existing exception lists with the same `list_id` are overwritten.
*/
overwrite_exceptions: BooleanFromString.optional().default(false),
/**
* Determines whether existing actions with the same `kibana.alert.rule.actions.id` are overwritten.
*/
overwrite_action_connectors: BooleanFromString.optional().default(false),
/**
* Generates a new list ID for each imported exception list.
*/
as_new_list: BooleanFromString.optional().default(false),
});
export type ImportRulesV2RequestQueryInput = z.input<typeof ImportRulesV2RequestQuery>;

export type ImportRulesV2RequestBody = z.infer<typeof ImportRulesV2RequestBody>;
export const ImportRulesV2RequestBody = z.array(RuleCreateProps);
export type ImportRulesV2RequestBodyInput = z.input<typeof ImportRulesV2RequestBody>;

export type ImportRulesV2Response = z.infer<typeof ImportRulesV2Response>;
export const ImportRulesV2Response = z
.object({
imported_rules_count: z.number().int().min(0),
success: z.boolean(),
errors: z.array(ErrorSchema),
})
.strict();
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
openapi: 3.0.0
info:
title: Import Rules API endpoint
version: '2024-05-15'
paths:
/api/detection_engine/rules/_import:
post:
operationId: ImportRulesV2
x-codegen-enabled: true
summary: Import rules
description: Imports rules
tags:
- Import/Export API
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '../../model/rule_schema/rule_schemas.schema.yaml#/components/schemas/RuleCreateProps'
parameters:
- name: overwrite
in: query
required: false
description: Determines whether existing rules with the same `rule_id` are overwritten.
schema:
type: boolean
default: false
- name: overwrite_exceptions
in: query
required: false
description: Determines whether existing exception lists with the same `list_id` are overwritten.
schema:
type: boolean
default: false
- name: overwrite_action_connectors
in: query
required: false
description: Determines whether existing actions with the same `kibana.alert.rule.actions.id` are overwritten.
schema:
type: boolean
default: false
- name: as_new_list
in: query
required: false
description: Generates a new list ID for each imported exception list.
schema:
type: boolean
default: false
responses:
200:
description: Indicates a successful call.
content:
application/json:
schema:
type: object
additionalProperties: false
required:
- imported_rules_count
- success
- errors
properties:
imported_rules_count:
type: integer
minimum: 0
success:
type: boolean
errors:
type: array
items:
$ref: '../../model/error_schema.schema.yaml#/components/schemas/ErrorSchema'
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ export * from './crud/update_rule/update_rule_route.gen';
export * from './export_rules/export_rules_details_schema';
export * from './export_rules/export_rules_route.gen';
export * from './find_rules/find_rules_route.gen';
export * from './find_rules/find_rules_route.v2.gen';
export * from './find_rules/request_schema_validation';
export * from './get_rule_management_filters/get_rule_management_filters_route';
export * from './import_rules/import_rules_route.gen';
export * from './import_rules/import_rules_route.v2.gen';
export * from './import_rules/rule_to_import_validation';
export * from './import_rules/rule_to_import';
export * from './model/query_rule_by_ids_validation';
Expand Down
Loading