mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Security Solution] Auto-bundle Detections API OpenAPI specs (#186384)
**Addresses:** https://github.com/elastic/kibana/issues/184428 ## Summary This PR adds scripts for automatic bundling Detections API OpenAPI spec as a part of PR pipeline. Corresponding resulting bundles are automatically committed to `x-pack/plugins/security_solution/docs/openapi/ess/` and `x-pack/plugins/security_solution/docs/openapi/serverless` folders.
This commit is contained in:
parent
7a0065d5b6
commit
858ef15c5a
25 changed files with 11237 additions and 29 deletions
|
@ -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
|
|
@ -6,8 +6,9 @@ paths:
|
|||
/api/detection_engine/signals/assignees:
|
||||
summary: Assigns users to alerts
|
||||
post:
|
||||
operationId: SetAlertAssignees
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: SetAlertAssignees
|
||||
description: Assigns users to alerts.
|
||||
requestBody:
|
||||
required: true
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules/prepackaged/_status:
|
||||
get:
|
||||
operationId: GetPrebuiltRulesAndTimelinesStatus
|
||||
x-labels: [ess]
|
||||
x-codegen-enabled: true
|
||||
operationId: GetPrebuiltRulesAndTimelinesStatus
|
||||
summary: Get the status of Elastic prebuilt rules
|
||||
tags:
|
||||
- Prebuilt Rules API
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules/prepackaged:
|
||||
put:
|
||||
operationId: InstallPrebuiltRulesAndTimelines
|
||||
x-labels: [ess]
|
||||
x-codegen-enabled: true
|
||||
operationId: InstallPrebuiltRulesAndTimelines
|
||||
summary: Installs all Elastic prebuilt rules and timelines
|
||||
tags:
|
||||
- Prebuilt Rules API
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules/_bulk_action:
|
||||
post:
|
||||
operationId: PerformBulkAction
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: PerformBulkAction
|
||||
summary: Applies a bulk action to multiple rules
|
||||
description: The bulk action is applied to all rules that match the filter or to the list of rules by their IDs.
|
||||
tags:
|
||||
|
|
|
@ -6,8 +6,8 @@ paths:
|
|||
/api/detection_engine/rules/_bulk_create:
|
||||
post:
|
||||
x-labels: [ess]
|
||||
operationId: BulkCreateRules
|
||||
x-codegen-enabled: true
|
||||
operationId: BulkCreateRules
|
||||
deprecated: true
|
||||
description: Creates new detection rules in bulk.
|
||||
tags:
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules/_bulk_delete:
|
||||
delete:
|
||||
operationId: BulkDeleteRules
|
||||
x-labels: [ess]
|
||||
x-codegen-enabled: true
|
||||
operationId: BulkDeleteRules
|
||||
deprecated: true
|
||||
description: Deletes multiple rules.
|
||||
tags:
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules/_bulk_update:
|
||||
patch:
|
||||
operationId: BulkPatchRules
|
||||
x-labels: [ess]
|
||||
x-codegen-enabled: true
|
||||
operationId: BulkPatchRules
|
||||
deprecated: true
|
||||
description: Updates multiple rules using the `PATCH` method.
|
||||
tags:
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules/_bulk_update:
|
||||
put:
|
||||
operationId: BulkUpdateRules
|
||||
x-labels: [ess]
|
||||
x-codegen-enabled: true
|
||||
operationId: BulkUpdateRules
|
||||
deprecated: true
|
||||
description: Updates multiple rules using the `PUT` method.
|
||||
tags:
|
||||
|
|
|
@ -6,8 +6,8 @@ paths:
|
|||
/api/detection_engine/rules:
|
||||
post:
|
||||
x-labels: [ess, serverless]
|
||||
operationId: CreateRule
|
||||
x-codegen-enabled: true
|
||||
operationId: CreateRule
|
||||
description: Create a single detection rule
|
||||
tags:
|
||||
- Rules API
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules:
|
||||
delete:
|
||||
operationId: DeleteRule
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: DeleteRule
|
||||
description: Deletes a single rule using the `rule_id` or `id` field.
|
||||
tags:
|
||||
- Rules API
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules:
|
||||
patch:
|
||||
operationId: PatchRule
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: PatchRule
|
||||
description: Patch a single rule
|
||||
tags:
|
||||
- Rules API
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules:
|
||||
get:
|
||||
operationId: ReadRule
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: ReadRule
|
||||
description: Read a single rule
|
||||
tags:
|
||||
- Rules API
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules:
|
||||
put:
|
||||
operationId: UpdateRule
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: UpdateRule
|
||||
description: Update a single rule
|
||||
tags:
|
||||
- Rules API
|
||||
|
|
|
@ -6,8 +6,9 @@ paths:
|
|||
/api/detection_engine/rules/_export:
|
||||
summary: Exports rules to an `.ndjson` file
|
||||
post:
|
||||
operationId: ExportRules
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: ExportRules
|
||||
summary: Export rules
|
||||
description: Exports rules to an `.ndjson` file. The following configuration items are also included in the `.ndjson` file - Actions, Exception lists. Prebuilt rules cannot be exported.
|
||||
tags:
|
||||
|
|
|
@ -5,8 +5,9 @@ info:
|
|||
paths:
|
||||
/api/detection_engine/rules/_find:
|
||||
get:
|
||||
operationId: FindRules
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: FindRules
|
||||
description: Finds rules that match the given query.
|
||||
tags:
|
||||
- Rules API
|
||||
|
|
|
@ -6,8 +6,9 @@ paths:
|
|||
/api/detection_engine/rules/_import:
|
||||
summary: Imports rules from an `.ndjson` file
|
||||
post:
|
||||
operationId: ImportRules
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: ImportRules
|
||||
summary: Import rules
|
||||
description: Imports rules from an `.ndjson` file, including actions and exception lists.
|
||||
tags:
|
||||
|
|
|
@ -6,8 +6,9 @@ paths:
|
|||
/api/detection_engine/tags:
|
||||
summary: Aggregates and returns rule tags
|
||||
get:
|
||||
operationId: ReadTags
|
||||
x-labels: [ess, serverless]
|
||||
x-codegen-enabled: true
|
||||
operationId: ReadTags
|
||||
summary: Aggregates and returns all unique tags from all rules
|
||||
tags:
|
||||
- Tags API
|
||||
|
|
|
@ -5,8 +5,10 @@ info:
|
|||
paths:
|
||||
/internal/detection_engine/rules/{ruleId}/execution/events:
|
||||
put:
|
||||
operationId: GetRuleExecutionEvents
|
||||
x-labels: [ess, serverless]
|
||||
x-internal: true
|
||||
x-codegen-enabled: true
|
||||
operationId: GetRuleExecutionEvents
|
||||
summary: Returns execution events of a given rule (aggregated by execution UUID) from Event Log.
|
||||
tags:
|
||||
- Rule Execution Log API
|
||||
|
|
|
@ -5,8 +5,10 @@ info:
|
|||
paths:
|
||||
/internal/detection_engine/rules/{ruleId}/execution/results:
|
||||
put:
|
||||
operationId: GetRuleExecutionResults
|
||||
x-labels: [ess, serverless]
|
||||
x-internal: true
|
||||
x-codegen-enabled: true
|
||||
operationId: GetRuleExecutionResults
|
||||
summary: Returns execution results of a given rule (aggregated by execution UUID) from Event Log.
|
||||
tags:
|
||||
- Rule Execution Log API
|
||||
|
|
|
@ -6,8 +6,10 @@ paths:
|
|||
/internal/detection_engine/users/_find:
|
||||
summary: Suggests user profiles based on provided search term
|
||||
post:
|
||||
operationId: SuggestUserProfiles
|
||||
x-labels: [ess, serverless]
|
||||
x-internal: true
|
||||
x-codegen-enabled: true
|
||||
operationId: SuggestUserProfiles
|
||||
description: Suggests user profiles.
|
||||
parameters:
|
||||
- name: searchTerm
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -9,26 +9,36 @@ require('../../../../../src/setup_node_env');
|
|||
const { bundle } = require('@kbn/openapi-bundler');
|
||||
const { join, resolve } = require('path');
|
||||
|
||||
const SECURITY_SOLUTION_ROOT = resolve(__dirname, '../..');
|
||||
const ROOT = resolve(__dirname, '../..');
|
||||
|
||||
bundle({
|
||||
sourceGlob: join(SECURITY_SOLUTION_ROOT, 'common/api/**/*.schema.yaml'),
|
||||
sourceGlob: join(ROOT, 'common/api/detection_engine/**/*.schema.yaml'),
|
||||
outputFilePath: join(
|
||||
SECURITY_SOLUTION_ROOT,
|
||||
'target/openapi/serverless/security_solution-{version}.bundled.schema.yaml'
|
||||
ROOT,
|
||||
'docs/openapi/serverless/security_solution_detections_api_{version}.bundled.schema.yaml'
|
||||
),
|
||||
options: {
|
||||
includeLabels: ['serverless'],
|
||||
specInfo: {
|
||||
title: 'Security Solution Detections API (Elastic Cloud Serverless)',
|
||||
description:
|
||||
'You can create rules that automatically turn events and external alerts sent to Elastic Security into detection alerts. These alerts are displayed on the Detections page.',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
bundle({
|
||||
sourceGlob: join(SECURITY_SOLUTION_ROOT, 'common/api/**/*.schema.yaml'),
|
||||
sourceGlob: join(ROOT, 'common/api/detection_engine/**/*.schema.yaml'),
|
||||
outputFilePath: join(
|
||||
SECURITY_SOLUTION_ROOT,
|
||||
'target/openapi/ess/security_solution-{version}.bundled.schema.yaml'
|
||||
ROOT,
|
||||
'docs/openapi/ess/security_solution_detections_api_{version}.bundled.schema.yaml'
|
||||
),
|
||||
options: {
|
||||
includeLabels: ['ess'],
|
||||
specInfo: {
|
||||
title: 'Security Solution Detections API (Elastic Cloud and self-hosted)',
|
||||
description:
|
||||
'You can create rules that automatically turn events and external alerts sent to Elastic Security into detection alerts. These alerts are displayed on the Detections page.',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ const SECURITY_SOLUTION_ROOT = resolve(__dirname, '../..');
|
|||
await generate({
|
||||
title: 'API route schemas',
|
||||
rootDir: SECURITY_SOLUTION_ROOT,
|
||||
sourceGlob: './**/*.schema.yaml',
|
||||
sourceGlob: './common/**/*.schema.yaml',
|
||||
templateName: 'zod_operation_schema',
|
||||
skipLinting: true,
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ const SECURITY_SOLUTION_ROOT = resolve(__dirname, '../..');
|
|||
await generate({
|
||||
title: 'API client for tests',
|
||||
rootDir: SECURITY_SOLUTION_ROOT,
|
||||
sourceGlob: './**/*.schema.yaml',
|
||||
sourceGlob: './common/**/*.schema.yaml',
|
||||
templateName: 'api_client_supertest',
|
||||
skipLinting: true,
|
||||
bundle: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue