-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solutions] Re-arranges and adds more packages to remove cop…
…ied code (#100310) (#100369) ## Summary * Creates a `securitysolution-list-utils` packaged and moves the first set of utilities into there * Fixes a slight bug with `kbn-securitysolution-io-ts-list-types` where the wrong name was used * Moves _all_ of the lists schemas and types into the package `kbn-securitysolution-io-ts-list-types` * Removes copied code found in a few places ## Tech debt * Some spots I have to use an `any` in the package as Kibana kbn packages don't have the types I need * Some spots I copy constants until we can straighten out those pieces. * I keep copied mock files until we figure out how to share mocks from these packages without adding weight or we create dedicated mock packages for all of this. ### 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 <[email protected]>
- Loading branch information
1 parent
05fc567
commit 7d0deec
Showing
531 changed files
with
3,374 additions
and
2,300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
packages/kbn-securitysolution-io-ts-list-types/src/common/cursor/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import * as t from 'io-ts'; | ||
|
||
export const cursor = t.string; | ||
export type Cursor = t.TypeOf<typeof cursor>; | ||
export const cursorOrUndefined = t.union([cursor, t.undefined]); | ||
export type CursorOrUndefined = t.TypeOf<typeof cursorOrUndefined>; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
packages/kbn-securitysolution-io-ts-list-types/src/common/deserializer/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import * as t from 'io-ts'; | ||
|
||
export const deserializer = t.string; | ||
export type Deserializer = t.TypeOf<typeof deserializer>; | ||
export const deserializerOrUndefined = t.union([deserializer, t.undefined]); | ||
export type DeserializerOrUndefined = t.TypeOf<typeof deserializerOrUndefined>; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { exceptionListType, ExceptionListTypeEnum } from '.'; | ||
|
||
import { pipe } from 'fp-ts/lib/pipeable'; | ||
import { left } from 'fp-ts/lib/Either'; | ||
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; | ||
|
||
describe('exceptionListType', () => { | ||
test('it should validate for "detection"', () => { | ||
const payload = 'detection'; | ||
const decoded = exceptionListType.decode(payload); | ||
const message = pipe(decoded, foldLeftRight); | ||
|
||
expect(getPaths(left(message.errors))).toEqual([]); | ||
expect(message.schema).toEqual(payload); | ||
}); | ||
|
||
test('it should validate for "endpoint"', () => { | ||
const payload = 'endpoint'; | ||
const decoded = exceptionListType.decode(payload); | ||
const message = pipe(decoded, foldLeftRight); | ||
|
||
expect(getPaths(left(message.errors))).toEqual([]); | ||
expect(message.schema).toEqual(payload); | ||
}); | ||
|
||
test('it should contain same amount of keys as enum', () => { | ||
// Might seem like a weird test, but its meant to | ||
// ensure that if exceptionListType is updated, you | ||
// also update the ExceptionListTypeEnum, a workaround | ||
// for io-ts not yet supporting enums | ||
// https://github.com/gcanti/io-ts/issues/67 | ||
const keys = Object.keys(exceptionListType.keys).sort().join(',').toLowerCase(); | ||
const enumKeys = Object.keys(ExceptionListTypeEnum).sort().join(',').toLowerCase(); | ||
|
||
expect(keys).toEqual(enumKeys); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
packages/kbn-securitysolution-io-ts-list-types/src/common/file/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import * as t from 'io-ts'; | ||
|
||
export const file = t.object; |
14 changes: 14 additions & 0 deletions
14
packages/kbn-securitysolution-io-ts-list-types/src/common/filter/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import * as t from 'io-ts'; | ||
|
||
export const filter = t.string; | ||
export type Filter = t.TypeOf<typeof filter>; | ||
export const filterOrUndefined = t.union([filter, t.undefined]); | ||
export type FilterOrUndefined = t.TypeOf<typeof filterOrUndefined>; |
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
packages/kbn-securitysolution-io-ts-list-types/src/common/immutable/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import * as t from 'io-ts'; | ||
|
||
export const immutable = t.boolean; | ||
export type Immutable = t.TypeOf<typeof immutable>; | ||
export const immutableOrUndefined = t.union([immutable, t.undefined]); | ||
export type ImmutableOrUndefined = t.TypeOf<typeof immutableOrUndefined>; |
62 changes: 62 additions & 0 deletions
62
packages/kbn-securitysolution-io-ts-list-types/src/common/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export * from './comment'; | ||
export * from './create_comment'; | ||
export * from './created_at'; | ||
export * from './created_by'; | ||
export * from './cursor'; | ||
export * from './default_namespace'; | ||
export * from './default_namespace_array'; | ||
export * from './description'; | ||
export * from './deserializer'; | ||
export * from './endpoint'; | ||
export * from './entries'; | ||
export * from './entries_exist'; | ||
export * from './entries_list'; | ||
export * from './entry_match'; | ||
export * from './entry_match_any'; | ||
export * from './entry_match_wildcard'; | ||
export * from './entry_nested'; | ||
export * from './exception_list'; | ||
export * from './exception_list_item_type'; | ||
export * from './filter'; | ||
export * from './id'; | ||
export * from './immutable'; | ||
export * from './item_id'; | ||
export * from './list_id'; | ||
export * from './list_operator'; | ||
export * from './list_type'; | ||
export * from './lists'; | ||
export * from './lists_default_array'; | ||
export * from './meta'; | ||
export * from './name'; | ||
export * from './non_empty_entries_array'; | ||
export * from './non_empty_nested_entries_array'; | ||
export * from './os_type'; | ||
export * from './page'; | ||
export * from './per_page'; | ||
export * from './serializer'; | ||
export * from './sort_field'; | ||
export * from './sort_order'; | ||
export * from './tags'; | ||
export * from './tie_breaker_id'; | ||
export * from './total'; | ||
export * from './type'; | ||
export * from './underscore_version'; | ||
export * from './update_comment'; | ||
export * from './updated_at'; | ||
export * from './updated_by'; |
11 changes: 11 additions & 0 deletions
11
packages/kbn-securitysolution-io-ts-list-types/src/common/item/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import * as t from 'io-ts'; | ||
|
||
export const item = t.string; |
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
packages/kbn-securitysolution-io-ts-list-types/src/common/list_id/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
|
||
import * as t from 'io-ts'; | ||
import { NonEmptyString } from '@kbn/securitysolution-io-ts-types'; | ||
|
||
export const list_id = NonEmptyString; | ||
export type ListId = t.TypeOf<typeof list_id>; | ||
export const list_idOrUndefined = t.union([list_id, t.undefined]); | ||
export type ListIdOrUndefined = t.TypeOf<typeof list_idOrUndefined>; |
Oops, something went wrong.