Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,9 @@ x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout @elastic/
/x-pack/plugins/stack_connectors/server/connector_types/sentinelone @elastic/security-defend-workflows
/x-pack/plugins/stack_connectors/common/sentinelone @elastic/security-defend-workflows

## Security Solution shared OAS schemas
/x-pack/plugins/security_solution/common/api/model @elastic/security-detection-rule-management @elastic/security-detection-engine

## Security Solution sub teams - Detection Rule Management
/x-pack/plugins/security_solution/common/api/detection_engine/fleet_integrations @elastic/security-detection-rule-management
/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema @elastic/security-detection-rule-management @elastic/security-detection-engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { z } from 'zod';
* version: 2023-10-31
*/

import { NonEmptyString } from '../model/rule_schema/common_attributes.gen';
import { AlertIds } from '../../model/alert.gen';
import { NonEmptyString } from '../../model/primitives.gen';

export type AlertAssignees = z.infer<typeof AlertAssignees>;
export const AlertAssignees = z.object({
Expand All @@ -30,12 +31,6 @@ export const AlertAssignees = z.object({
remove: z.array(NonEmptyString),
});

/**
* A list of alerts ids.
*/
export type AlertIds = z.infer<typeof AlertIds>;
export const AlertIds = z.array(NonEmptyString).min(1);

export type SetAlertAssigneesRequestBody = z.infer<typeof SetAlertAssigneesRequestBody>;
export const SetAlertAssigneesRequestBody = z.object({
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ paths:
$ref: '#/components/schemas/AlertAssignees'
description: Details about the assignees to assign and unassign.
ids:
$ref: '#/components/schemas/AlertIds'
$ref: '../../model/alert.schema.yaml#/components/schemas/AlertIds'
description: List of alerts ids to assign and unassign passed assignees.
responses:
200:
Expand All @@ -42,17 +42,10 @@ components:
add:
type: array
items:
$ref: '../model/rule_schema/common_attributes.schema.yaml#/components/schemas/NonEmptyString'
$ref: '../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
description: A list of users ids to assign.
remove:
type: array
items:
$ref: '../model/rule_schema/common_attributes.schema.yaml#/components/schemas/NonEmptyString'
$ref: '../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
description: A list of users ids to unassign.

AlertIds:
type: array
items:
$ref: '../model/rule_schema/common_attributes.schema.yaml#/components/schemas/NonEmptyString'
minItems: 1
description: A list of alerts ids.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,7 @@ import { isValidDateMath } from '@kbn/zod-helpers';
* version: not applicable
*/

/**
* A string that is not empty and does not contain only whitespace
*/
export type NonEmptyString = z.infer<typeof NonEmptyString>;
export const NonEmptyString = z
.string()
.min(1)
.regex(/^(?! *$).+$/);

/**
* A universally unique identifier
*/
export type UUID = z.infer<typeof UUID>;
export const UUID = z.string().uuid();
import { UUID, NonEmptyString } from '../../../model/primitives.gen';

export type RuleObjectId = z.infer<typeof RuleObjectId>;
export const RuleObjectId = UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ paths: {}
components:
x-codegen-enabled: true
schemas:
NonEmptyString:
type: string
pattern: ^(?! *$).+$
minLength: 1
description: A string that is not empty and does not contain only whitespace

UUID:
type: string
format: uuid
description: A universally unique identifier

RuleObjectId:
$ref: '#/components/schemas/UUID'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/UUID'

RuleSignatureId:
type: string
Expand Down Expand Up @@ -289,9 +278,9 @@ components:
type: object
properties:
name:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
type:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
ecs:
type: boolean
required:
Expand Down Expand Up @@ -332,11 +321,11 @@ components:
type: object
properties:
package:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
version:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
integration:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
required:
- package
- version
Expand All @@ -354,7 +343,7 @@ components:
field_names:
type: array
items:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
minItems: 1
required:
- field_names
Expand Down Expand Up @@ -426,7 +415,7 @@ components:
params:
$ref: '#/components/schemas/RuleActionParams'
uuid:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
alerts_filter:
$ref: '#/components/schemas/RuleActionAlertsFilter'
frequency:
Expand All @@ -453,10 +442,10 @@ components:
type: object
properties:
id:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
description: ID of the exception container
list_id:
$ref: '#/components/schemas/NonEmptyString'
$ref: '../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
description: List ID of the exception container
type:
$ref: '#/components/schemas/ExceptionListType'
Expand Down Expand Up @@ -527,4 +516,4 @@ components:
missingFieldsStrategy:
$ref: '#/components/schemas/AlertSuppressionMissingFieldsStrategy'
required:
- groupBy
- groupBy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { z } from 'zod';
* version: not applicable
*/

import { NonEmptyString } from '../common_attributes.gen';
import { NonEmptyString } from '../../../../model/primitives.gen';

export type NewTermsFields = z.infer<typeof NewTermsFields>;
export const NewTermsFields = z.array(z.string()).min(1).max(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ components:
minItems: 1
maxItems: 3
HistoryWindowStart:
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
$ref: '../../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { z } from 'zod';
* version: not applicable
*/

import { NonEmptyString } from '../common_attributes.gen';
import { NonEmptyString } from '../../../../model/primitives.gen';

/**
* Query to execute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ components:
type: object
properties:
field:
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
$ref: '../../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
type:
type: string
enum:
- mapping
value:
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
$ref: '../../../../model/primitives.schema.yaml#/components/schemas/NonEmptyString'
required:
- field
- type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { z } from 'zod';
* version: 2023-10-31
*/

import { AlertIds } from '../../../model/alert.gen';

export type Id = z.infer<typeof Id>;
export const Id = z.string();

Expand Down Expand Up @@ -115,12 +117,6 @@ export const Types = z.array(Type);
export type EndpointIds = z.infer<typeof EndpointIds>;
export const EndpointIds = z.array(z.string().min(1)).min(1);

/**
* If defined, any case associated with the given IDs will be updated (cannot contain empty strings)
*/
export type AlertIds = z.infer<typeof AlertIds>;
export const AlertIds = z.array(z.string().min(1)).min(1);

/**
* Case IDs to be updated (cannot contain empty strings)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ components:
minLength: 1
minItems: 1
description: List of endpoint IDs (cannot contain empty strings)
AlertIds:
type: array
items:
type: string
minLength: 1
minItems: 1
description: If defined, any case associated with the given IDs will be updated (cannot contain empty strings)
CaseIds:
type: array
items:
Expand All @@ -151,7 +144,7 @@ components:
endpoint_ids:
$ref: '#/components/schemas/EndpointIds'
alert_ids:
$ref: '#/components/schemas/AlertIds'
$ref: '../../../model/alert.schema.yaml#/components/schemas/AlertIds'
case_ids:
$ref: '#/components/schemas/CaseIds'
comment:
Expand Down
25 changes: 25 additions & 0 deletions x-pack/plugins/security_solution/common/api/model/alert.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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';

/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Shared Alert Primitives Schema
* version: not applicable
*/

import { NonEmptyString } from './primitives.gen';

/**
* A list of alerts ids.
*/
export type AlertIds = z.infer<typeof AlertIds>;
export const AlertIds = z.array(NonEmptyString).min(1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
openapi: 3.0.0
info:
title: Shared Alert Primitives Schema
version: 'not applicable'
paths: {}
components:
x-codegen-enabled: true
schemas:
AlertIds:
type: array
items:
$ref: './primitives.schema.yaml#/components/schemas/NonEmptyString'
minItems: 1
description: A list of alerts ids.
9 changes: 9 additions & 0 deletions x-pack/plugins/security_solution/common/api/model/index.ts
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 './primitives.gen';
export * from './alert.gen';
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.
*/

import { z } from 'zod';

/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Shared Primitives Schema
* version: not applicable
*/

/**
* A string that is not empty and does not contain only whitespace
*/
export type NonEmptyString = z.infer<typeof NonEmptyString>;
export const NonEmptyString = z
.string()
.min(1)
.regex(/^(?! *$).+$/);

/**
* A universally unique identifier
*/
export type UUID = z.infer<typeof UUID>;
export const UUID = z.string().uuid();
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
openapi: 3.0.0
info:
title: Shared Primitives Schema
version: 'not applicable'
paths: {}
components:
x-codegen-enabled: true
schemas:
NonEmptyString:
type: string
pattern: ^(?! *$).+$
minLength: 1
description: A string that is not empty and does not contain only whitespace

UUID:
type: string
format: uuid
description: A universally unique identifier
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { AlertIds } from '@kbn/security-solution-plugin/common/api/detection_engine';
import { AlertIds } from '@kbn/security-solution-plugin/common/api/model';
import { SetAlertAssigneesRequestBody } from '@kbn/security-solution-plugin/common/api/detection_engine';

export const setAlertAssignees = ({
Expand Down