mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Security Solution] Remove remaining usage of rule_schema_legacy types (#188079)
## Summary Leftover work from https://github.com/elastic/kibana/pull/186615 - Removes remaining usage of `rule_schema_legacy` types. In this PR, simply inlines the last io-ts types used, to be able to get rid of the legacy folder. - The remaining files that need to be migrated to using Zod schema types are: - `x-pack/plugins/security_solution/common/api/detection_engine/rule_exceptions/find_exception_references/find_exception_references_route.ts` - `x-pack/plugins/security_solution/common/api/timeline/model/api.ts` ### 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: Georgii Gorbachev <georgii.gorbachev@elastic.co>
This commit is contained in:
parent
232a16637d
commit
0c5d7b95c0
4 changed files with 35 additions and 77 deletions
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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 * as t from 'io-ts';
|
||||
import { NonEmptyString, UUID } from '@kbn/securitysolution-io-ts-types';
|
||||
|
||||
/*
|
||||
IMPORTANT NOTE ON THIS FILE:
|
||||
|
||||
This file contains the remaining rule schema types created manually via io-ts. They have been
|
||||
migrated to Zod schemas created via code generation out of OpenAPI schemas
|
||||
(found in x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts)
|
||||
|
||||
The remaining types here couldn't easily be deleted/replaced because they are dependencies in
|
||||
complex derived schemas in two files:
|
||||
|
||||
- x-pack/plugins/security_solution/common/api/detection_engine/rule_exceptions/find_exception_references/find_exception_references_route.ts
|
||||
- x-pack/plugins/security_solution/common/api/timeline/model/api.ts
|
||||
|
||||
Once those two files are migrated to Zod, the /common/api/detection_engine/model/rule_schema_legacy
|
||||
folder can be removed.
|
||||
*/
|
||||
|
||||
export type RuleObjectId = t.TypeOf<typeof RuleObjectId>;
|
||||
export const RuleObjectId = UUID;
|
||||
|
||||
/**
|
||||
* NOTE: Never make this a strict uuid, we allow the rule_id to be any string at the moment
|
||||
* in case we encounter 3rd party rule systems which might be using auto incrementing numbers
|
||||
* or other different things.
|
||||
*/
|
||||
export type RuleSignatureId = t.TypeOf<typeof RuleSignatureId>;
|
||||
export const RuleSignatureId = t.string; // should be non-empty string?
|
||||
|
||||
export type RuleName = t.TypeOf<typeof RuleName>;
|
||||
export const RuleName = NonEmptyString;
|
||||
|
||||
/**
|
||||
* Outcome is a property of the saved object resolve api
|
||||
* will tell us info about the rule after 8.0 migrations
|
||||
*/
|
||||
export type SavedObjectResolveOutcome = t.TypeOf<typeof SavedObjectResolveOutcome>;
|
||||
export const SavedObjectResolveOutcome = t.union([
|
||||
t.literal('exactMatch'),
|
||||
t.literal('aliasMatch'),
|
||||
t.literal('conflict'),
|
||||
]);
|
||||
|
||||
export type SavedObjectResolveAliasTargetId = t.TypeOf<typeof SavedObjectResolveAliasTargetId>;
|
||||
export const SavedObjectResolveAliasTargetId = t.string;
|
||||
|
||||
export type SavedObjectResolveAliasPurpose = t.TypeOf<typeof SavedObjectResolveAliasPurpose>;
|
||||
export const SavedObjectResolveAliasPurpose = t.union([
|
||||
t.literal('savedObjectConversion'),
|
||||
t.literal('savedObjectImport'),
|
||||
]);
|
|
@ -1,8 +0,0 @@
|
|||
/*
|
||||
* 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 './common_attributes';
|
|
@ -12,10 +12,17 @@ import {
|
|||
list_id,
|
||||
DefaultNamespaceArray,
|
||||
} from '@kbn/securitysolution-io-ts-list-types';
|
||||
import { NonEmptyStringArray } from '@kbn/securitysolution-io-ts-types';
|
||||
import { NonEmptyStringArray, NonEmptyString, UUID } from '@kbn/securitysolution-io-ts-types';
|
||||
|
||||
// TODO https://github.com/elastic/security-team/issues/7491
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { RuleName, RuleObjectId, RuleSignatureId } from '../../model/rule_schema_legacy';
|
||||
type RuleObjectId = t.TypeOf<typeof RuleObjectId>;
|
||||
const RuleObjectId = UUID;
|
||||
|
||||
type RuleSignatureId = t.TypeOf<typeof RuleSignatureId>;
|
||||
const RuleSignatureId = t.string;
|
||||
|
||||
type RuleName = t.TypeOf<typeof RuleName>;
|
||||
const RuleName = NonEmptyString;
|
||||
|
||||
// If ids and list_ids are undefined, route will fetch all lists matching the
|
||||
// specified namespace type
|
||||
|
|
|
@ -15,12 +15,31 @@ import { Direction } from '../../../search_strategy';
|
|||
import type { PinnedEvent } from '../pinned_events/pinned_events_route';
|
||||
import { PinnedEventRuntimeType } from '../pinned_events/pinned_events_route';
|
||||
// TODO https://github.com/elastic/security-team/issues/7491
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import {
|
||||
SavedObjectResolveAliasPurpose,
|
||||
SavedObjectResolveAliasTargetId,
|
||||
SavedObjectResolveOutcome,
|
||||
} from '../../detection_engine/model/rule_schema_legacy';
|
||||
|
||||
/**
|
||||
* Outcome is a property of the saved object resolve api
|
||||
* will tell us info about the rule after 8.0 migrations
|
||||
*/
|
||||
export type SavedObjectResolveOutcome = runtimeTypes.TypeOf<typeof SavedObjectResolveOutcome>;
|
||||
export const SavedObjectResolveOutcome = runtimeTypes.union([
|
||||
runtimeTypes.literal('exactMatch'),
|
||||
runtimeTypes.literal('aliasMatch'),
|
||||
runtimeTypes.literal('conflict'),
|
||||
]);
|
||||
|
||||
export type SavedObjectResolveAliasTargetId = runtimeTypes.TypeOf<
|
||||
typeof SavedObjectResolveAliasTargetId
|
||||
>;
|
||||
export const SavedObjectResolveAliasTargetId = runtimeTypes.string;
|
||||
|
||||
export type SavedObjectResolveAliasPurpose = runtimeTypes.TypeOf<
|
||||
typeof SavedObjectResolveAliasPurpose
|
||||
>;
|
||||
export const SavedObjectResolveAliasPurpose = runtimeTypes.union([
|
||||
runtimeTypes.literal('savedObjectConversion'),
|
||||
runtimeTypes.literal('savedObjectImport'),
|
||||
]);
|
||||
|
||||
import { ErrorSchema } from './error_schema';
|
||||
|
||||
export const BareNoteSchema = runtimeTypes.intersection([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue