Skip to content

Commit 18e6085

Browse files
[Security Solutions] Replaces most deprecated io-ts alerting and list types (#100234) (#100246)
## Summary Replaces most of the deprecated io-ts alerting and list types within securitysolution as part of Phase 3 of 4 phases outlined in earlier PR's such as #99260 ### Checklist - [x] [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 Co-authored-by: Frank Hassanabad <frank.hassanabad@elastic.co>
1 parent c0f4647 commit 18e6085

323 files changed

Lines changed: 719 additions & 5578 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

x-pack/plugins/security_solution/server/lib/detection_engine/index/get_index_aliases.ts renamed to packages/kbn-securitysolution-es-utils/src/get_index_aliases/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
33
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
67
*/
78

8-
import { ElasticsearchClient } from 'src/core/server';
9+
import { ElasticsearchClient } from '../elasticsearch_client';
910

1011
interface AliasesResponse {
1112
[indexName: string]: {

x-pack/plugins/security_solution/server/lib/detection_engine/index/get_index_count.ts renamed to packages/kbn-securitysolution-es-utils/src/get_index_count/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
33
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
67
*/
78

8-
import { ElasticsearchClient } from 'src/core/server';
9+
import { ElasticsearchClient } from '../elasticsearch_client';
910

1011
/**
1112
* Retrieves the count of documents in a given index

packages/kbn-securitysolution-es-utils/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ export * from './delete_all_index';
1212
export * from './delete_policy';
1313
export * from './delete_template';
1414
export * from './elasticsearch_client';
15+
export * from './get_index_aliases';
16+
export * from './get_index_count';
1517
export * from './get_index_exists';
1618
export * from './get_policy_exists';
1719
export * from './get_template_exists';
20+
export * from './read_index';
1821
export * from './read_privileges';
1922
export * from './set_policy';
2023
export * from './set_template';

x-pack/plugins/security_solution/server/lib/detection_engine/index/read_index.ts renamed to packages/kbn-securitysolution-es-utils/src/read_index/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
33
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
67
*/
78

8-
import { ElasticsearchClient } from 'kibana/server';
9+
import { ElasticsearchClient } from '../elasticsearch_client';
910

1011
export const readIndex = async (esClient: ElasticsearchClient, index: string): Promise<unknown> => {
1112
return esClient.indices.get({

packages/kbn-securitysolution-io-ts-alerting-types/src/from/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ export const from = new t.Type<string, string, unknown>(
2424
t.identity
2525
);
2626
export type From = t.TypeOf<typeof from>;
27+
28+
export const fromOrUndefined = t.union([from, t.undefined]);
29+
export type FromOrUndefined = t.TypeOf<typeof fromOrUndefined>;

packages/kbn-securitysolution-io-ts-alerting-types/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export * from './default_to_string';
2424
export * from './default_uuid';
2525
export * from './from';
2626
export * from './language';
27+
export * from './machine_learning_job_id';
2728
export * from './max_signals';
2829
export * from './normalized_ml_job_id';
2930
export * from './references_default_array';
@@ -38,3 +39,4 @@ export * from './threat_subtechnique';
3839
export * from './threat_tactic';
3940
export * from './threat_technique';
4041
export * from './throttle';
42+
export * from './type';

packages/kbn-securitysolution-io-ts-alerting-types/src/language/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ import * as t from 'io-ts';
1010

1111
export const language = t.keyof({ eql: null, kuery: null, lucene: null });
1212
export type Language = t.TypeOf<typeof language>;
13+
14+
export const languageOrUndefined = t.union([language, t.undefined]);
15+
export type LanguageOrUndefined = t.TypeOf<typeof languageOrUndefined>;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
/* eslint-disable @typescript-eslint/naming-convention */
10+
11+
import * as t from 'io-ts';
12+
13+
import { machine_learning_job_id_normalized } from '../normalized_ml_job_id';
14+
15+
export const machine_learning_job_id = t.union([t.string, machine_learning_job_id_normalized]);
16+
export type MachineLearningJobId = t.TypeOf<typeof machine_learning_job_id>;
17+
18+
export const machineLearningJobIdOrUndefined = t.union([machine_learning_job_id, t.undefined]);
19+
export type MachineLearningJobIdOrUndefined = t.TypeOf<typeof machineLearningJobIdOrUndefined>;

packages/kbn-securitysolution-io-ts-alerting-types/src/max_signals/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ import { PositiveIntegerGreaterThanZero } from '@kbn/securitysolution-io-ts-type
1313

1414
export const max_signals = PositiveIntegerGreaterThanZero;
1515
export type MaxSignals = t.TypeOf<typeof max_signals>;
16+
17+
export const maxSignalsOrUndefined = t.union([max_signals, t.undefined]);
18+
export type MaxSignalsOrUndefined = t.TypeOf<typeof maxSignalsOrUndefined>;

packages/kbn-securitysolution-io-ts-alerting-types/src/risk_score/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Side Public License, v 1.
77
*/
88

9+
/* eslint-disable @typescript-eslint/naming-convention */
10+
911
import * as t from 'io-ts';
1012
import { Either } from 'fp-ts/lib/Either';
1113

@@ -26,3 +28,9 @@ export const RiskScore = new t.Type<number, number, unknown>(
2628
);
2729

2830
export type RiskScoreC = typeof RiskScore;
31+
32+
export const risk_score = RiskScore;
33+
export type RiskScore = t.TypeOf<typeof risk_score>;
34+
35+
export const riskScoreOrUndefined = t.union([risk_score, t.undefined]);
36+
export type RiskScoreOrUndefined = t.TypeOf<typeof riskScoreOrUndefined>;

0 commit comments

Comments
 (0)