Adds two more packages and moves files into the packages (#100375) (#100418)

## Summary

* Adds package `kbn-securitysolution-list-api`
* Adds package `kbn-securitysolution-list-hooks`
* Moves files into the packages
* Moves a few additional types into the other packages such as the `kbn-securitysolution-io-ts-types` package to remove more things from the shard_export/shared_import between lists and security solution
* Removes more duplicated code

### 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>
This commit is contained in:
Kibana Machine 2021-05-20 16:33:34 -04:00 committed by GitHub
parent 8ee9c3abc4
commit 533d32f7fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
128 changed files with 1669 additions and 517 deletions

View file

@ -88,6 +88,8 @@ yarn kbn watch-bazel
- kbn/securitysolution-io-ts-list-types
- kbn/securitysolution-io-ts-types
- @kbn/securitysolution-io-ts-utils
- @kbn/securitysolution-list-api
- @kbn/securitysolution-list-hooks
- @kbn/securitysolution-list-utils
- @kbn/securitysolution-utils
- @kbn/server-http-tools

View file

@ -139,6 +139,8 @@
"@kbn/securitysolution-io-ts-alerting-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-alerting-types/npm_module",
"@kbn/securitysolution-io-ts-list-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-list-types/npm_module",
"@kbn/securitysolution-io-ts-utils": "link:bazel-bin/packages/kbn-securitysolution-io-ts-utils/npm_module",
"@kbn/securitysolution-list-api": "link:bazel-bin/packages/kbn-securitysolution-list-api/npm_module",
"@kbn/securitysolution-list-hooks": "link:bazel-bin/packages/kbn-securitysolution-list-hooks/npm_module",
"@kbn/securitysolution-list-utils": "link:bazel-bin/packages/kbn-securitysolution-list-utils/npm_module",
"@kbn/securitysolution-utils": "link:bazel-bin/packages/kbn-securitysolution-utils/npm_module",
"@kbn/server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools/npm_module",

View file

@ -26,11 +26,13 @@ filegroup(
"//packages/kbn-logging:build",
"//packages/kbn-plugin-generator:build",
"//packages/kbn-securitysolution-constants:build",
"//packages/kbn-securitysolution-list-utils:build",
"//packages/kbn-securitysolution-io-ts-types:build",
"//packages/kbn-securitysolution-io-ts-alerting-types:build",
"//packages/kbn-securitysolution-io-ts-list-types:build",
"//packages/kbn-securitysolution-io-ts-utils:build",
"//packages/kbn-securitysolution-list-api:build",
"//packages/kbn-securitysolution-list-hooks:build",
"//packages/kbn-securitysolution-list-utils:build",
"//packages/kbn-securitysolution-utils:build",
"//packages/kbn-securitysolution-es-utils:build",
"//packages/kbn-server-http-tools:build",

View file

@ -10,3 +10,4 @@ export * from './common';
export * from './constants';
export * from './request';
export * from './response';
export * from './typescript_types';

View file

@ -1,51 +1,47 @@
/*
* 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.
* 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 type {
CreateExceptionListItemSchema,
CreateExceptionListSchema,
ExceptionListItemSchema,
ExceptionListSchema,
ExceptionListType,
NamespaceType,
Page,
PerPage,
TotalOrUndefined,
UpdateExceptionListItemSchema,
UpdateExceptionListSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { NamespaceType } from '../common/default_namespace';
import { ExceptionListType } from '../common/exception_list';
import { Page } from '../common/page';
import { PerPage } from '../common/per_page';
import { TotalOrUndefined } from '../common/total';
import { CreateExceptionListItemSchema } from '../request/create_exception_list_item_schema';
import { CreateExceptionListSchema } from '../request/create_exception_list_schema';
import { UpdateExceptionListItemSchema } from '../request/update_exception_list_item_schema';
import { UpdateExceptionListSchema } from '../request/update_exception_list_schema';
import { ExceptionListItemSchema } from '../response/exception_list_item_schema';
import { ExceptionListSchema } from '../response/exception_list_schema';
import { HttpStart, NotificationsStart } from '../../../../../src/core/public';
// TODO: Replace these with kbn packaged versions once we have those available to us
// These originally came from this location below before moving them to this hacked "any" types:
// import { HttpStart, NotificationsStart } from '../../../../../src/core/public';
interface HttpStart {
fetch: <T>(...args: any) => any;
}
type NotificationsStart = any;
export interface FilterExceptionsOptions {
filter: string;
tags: string[];
export interface ExceptionListFilter {
name?: string | null;
list_id?: string | null;
created_by?: string | null;
type?: string | null;
tags?: string | null;
}
export interface Pagination {
page: Page;
perPage: PerPage;
total: TotalOrUndefined;
}
export type AddExceptionList = UpdateExceptionListSchema | CreateExceptionListSchema;
export interface PersistHookProps {
export interface UseExceptionListsProps {
errorMessage: string;
filterOptions?: ExceptionListFilter;
http: HttpStart;
onError: (arg: Error) => void;
}
export interface ExceptionList extends ExceptionListSchema {
totalItems: number;
}
export interface UseExceptionListItemsSuccess {
exceptions: ExceptionListItemSchema[];
pagination: Pagination;
namespaceTypes: NamespaceType[];
notifications: NotificationsStart;
pagination?: Pagination;
showTrustedApps: boolean;
}
export interface UseExceptionListProps {
@ -60,27 +56,9 @@ export interface UseExceptionListProps {
onSuccess?: (arg: UseExceptionListItemsSuccess) => void;
}
export interface ExceptionListIdentifiers {
id: string;
listId: string;
namespaceType: NamespaceType;
type: ExceptionListType;
}
export interface ApiCallByListIdProps {
http: HttpStart;
listIds: string[];
namespaceTypes: NamespaceType[];
filterOptions: FilterExceptionsOptions[];
pagination: Partial<Pagination>;
signal: AbortSignal;
}
export interface ApiCallByIdProps {
http: HttpStart;
id: string;
namespaceType: NamespaceType;
signal: AbortSignal;
export interface FilterExceptionsOptions {
filter: string;
tags: string[];
}
export interface ApiCallMemoProps {
@ -101,6 +79,24 @@ export interface ApiListExportProps {
onSuccess: (blob: Blob) => void;
}
export interface Pagination {
page: Page;
perPage: PerPage;
total: TotalOrUndefined;
}
export interface UseExceptionListItemsSuccess {
exceptions: ExceptionListItemSchema[];
pagination: Pagination;
}
export interface ExceptionListIdentifiers {
id: string;
listId: string;
namespaceType: NamespaceType;
type: ExceptionListType;
}
export interface ApiCallFindListsItemsMemoProps {
lists: ExceptionListIdentifiers[];
filterOptions: FilterExceptionsOptions[];
@ -110,52 +106,17 @@ export interface ApiCallFindListsItemsMemoProps {
onError: (arg: string[]) => void;
onSuccess: (arg: UseExceptionListItemsSuccess) => void;
}
export interface ApiCallFetchExceptionListsProps {
export interface ExportExceptionListProps {
http: HttpStart;
namespaceTypes: string;
pagination: Partial<Pagination>;
filters: string;
id: string;
listId: string;
namespaceType: NamespaceType;
signal: AbortSignal;
}
export interface UseExceptionListsSuccess {
exceptions: ExceptionListSchema[];
pagination: Pagination;
}
export interface ExceptionListFilter {
name?: string | null;
list_id?: string | null;
created_by?: string | null;
type?: string | null;
tags?: string | null;
}
export interface UseExceptionListsProps {
errorMessage: string;
filterOptions?: ExceptionListFilter;
export interface AddEndpointExceptionListProps {
http: HttpStart;
namespaceTypes: NamespaceType[];
notifications: NotificationsStart;
pagination?: Pagination;
showTrustedApps: boolean;
}
export interface AddExceptionListProps {
http: HttpStart;
list: CreateExceptionListSchema;
signal: AbortSignal;
}
export interface AddExceptionListItemProps {
http: HttpStart;
listItem: CreateExceptionListItemSchema;
signal: AbortSignal;
}
export interface UpdateExceptionListProps {
http: HttpStart;
list: UpdateExceptionListSchema;
signal: AbortSignal;
}
@ -165,15 +126,60 @@ export interface UpdateExceptionListItemProps {
signal: AbortSignal;
}
export interface AddEndpointExceptionListProps {
export interface UpdateExceptionListProps {
http: HttpStart;
list: UpdateExceptionListSchema;
signal: AbortSignal;
}
export interface ExportExceptionListProps {
export interface AddExceptionListItemProps {
http: HttpStart;
listItem: CreateExceptionListItemSchema;
signal: AbortSignal;
}
export interface AddExceptionListProps {
http: HttpStart;
list: CreateExceptionListSchema;
signal: AbortSignal;
}
export interface UseExceptionListsSuccess {
exceptions: ExceptionListSchema[];
pagination: Pagination;
}
export interface ApiCallFetchExceptionListsProps {
http: HttpStart;
namespaceTypes: string;
pagination: Partial<Pagination>;
filters: string;
signal: AbortSignal;
}
export interface ApiCallByIdProps {
http: HttpStart;
id: string;
listId: string;
namespaceType: NamespaceType;
signal: AbortSignal;
}
export interface ApiCallByListIdProps {
http: HttpStart;
listIds: string[];
namespaceTypes: NamespaceType[];
filterOptions: FilterExceptionsOptions[];
pagination: Partial<Pagination>;
signal: AbortSignal;
}
export type AddExceptionList = UpdateExceptionListSchema | CreateExceptionListSchema;
export interface PersistHookProps {
http: HttpStart;
onError: (arg: Error) => void;
}
export interface ExceptionList extends ExceptionListSchema {
totalItems: number;
}

View file

@ -0,0 +1,88 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
PKG_BASE_NAME = "kbn-securitysolution-list-api"
PKG_REQUIRE_NAME = "@kbn/securitysolution-list-api"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*",
"**/*.mock.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]
SRC_DEPS = [
"//packages/kbn-securitysolution-io-ts-utils",
"//packages/kbn-securitysolution-io-ts-list-types",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//tslib",
]
TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/node",
]
DEPS = SRC_DEPS + TYPES_DEPS
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)
ts_project(
name = "tsc",
srcs = SRCS,
args = ["--pretty"],
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
root_dir = "src",
source_map = True,
tsconfig = ":tsconfig",
deps = DEPS,
)
js_library(
name = PKG_BASE_NAME,
package_name = PKG_REQUIRE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
visibility = ["//visibility:public"],
deps = [":tsc"] + DEPS,
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
],
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,4 @@
# kbn-securitysolution-list-api
This is where the REST API for the list plugin lives

View file

@ -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.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-securitysolution-list-api'],
};

View file

@ -0,0 +1,9 @@
{
"name": "@kbn/securitysolution-list-api",
"version": "1.0.0",
"description": "security solution list REST API",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"private": true
}

View file

@ -0,0 +1,15 @@
/*
* 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.
*/
describe('Exceptions Lists API', () => {
test('we should port these tests', () => {
// See the file outside of this at: x-pack/plugins/lists/public/exceptions/api.test.ts
// for the tests. We cannot port the tests over until we move the mocks into their own package
// and possibly core mocks end up within packages.
expect(true).toBe(true);
});
});

View file

@ -1,8 +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.
* 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 { chain, fromEither, tryCatch } from 'fp-ts/lib/TaskEither';
@ -19,18 +20,6 @@ import {
exceptionListSchema,
foundExceptionListItemSchema,
foundExceptionListSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { toError, toPromise } from '../common/fp_utils';
import {
ENDPOINT_LIST_URL,
EXCEPTION_LIST_ITEM_URL,
EXCEPTION_LIST_NAMESPACE,
EXCEPTION_LIST_NAMESPACE_AGNOSTIC,
EXCEPTION_LIST_URL,
} from '../../common/constants';
import {
AddEndpointExceptionListProps,
AddExceptionListItemProps,
AddExceptionListProps,
@ -40,7 +29,16 @@ import {
ExportExceptionListProps,
UpdateExceptionListItemProps,
UpdateExceptionListProps,
} from './types';
} from '@kbn/securitysolution-io-ts-list-types';
import { toError, toPromise } from '../fp_utils';
import {
ENDPOINT_LIST_URL,
EXCEPTION_LIST_ITEM_URL,
EXCEPTION_LIST_NAMESPACE,
EXCEPTION_LIST_NAMESPACE_AGNOSTIC,
EXCEPTION_LIST_URL,
} from '../constants';
/**
* Add new ExceptionList

View file

@ -0,0 +1,39 @@
/*
* 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.
*/
// TODO: These should be all replaced with constants from a shared kbn constants package
export const LIST_URL = '/api/lists';
export const LIST_INDEX = `${LIST_URL}/index`;
export const LIST_ITEM_URL = `${LIST_URL}/items`;
export const LIST_PRIVILEGES_URL = `${LIST_URL}/privileges`;
/**
* Exception list routes
*/
export const EXCEPTION_LIST_URL = '/api/exception_lists';
export const EXCEPTION_LIST_ITEM_URL = '/api/exception_lists/items';
/**
* Exception list spaces
*/
export const EXCEPTION_LIST_NAMESPACE_AGNOSTIC = 'exception-list-agnostic';
export const EXCEPTION_LIST_NAMESPACE = 'exception-list';
/**
* Specific routes for the single global space agnostic endpoint list
*/
export const ENDPOINT_LIST_URL = '/api/endpoint_list';
/**
* Specific routes for the single global space agnostic endpoint list. These are convenience
* routes where they are going to try and create the global space agnostic endpoint list if it
* does not exist yet or if it was deleted at some point and re-create it before adding items to
* the list
*/
export const ENDPOINT_LIST_ITEM_URL = '/api/endpoint_list/items';

View file

@ -1,13 +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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 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 { tryCatch } from 'fp-ts/lib/TaskEither';
import { toPromise } from './fp_utils';
import { toPromise } from '.';
describe('toPromise', () => {
it('rejects with left if TaskEither is left', async () => {

View file

@ -1,14 +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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 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 { pipe } from 'fp-ts/lib/pipeable';
import { TaskEither } from 'fp-ts/lib/TaskEither';
import { fold } from 'fp-ts/lib/Either';
// TODO: This is copied in a few other spots and probably should live within its own kbn package
// rather than living here. A package such as kbn-security-solution-fp-utils
export const toPromise = async <E, A>(taskEither: TaskEither<E, A>): Promise<A> =>
pipe(
await taskEither(),

View file

@ -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.
*/
export * from './api';
export * from './fp_utils';
export * from './list_api';

View file

@ -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.
*/
describe('Value Lists API', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/lists/api.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,8 +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.
* 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 { chain, fromEither, map, tryCatch } from 'fp-ts/lib/TaskEither';
@ -29,9 +30,9 @@ import {
listItemIndexExistSchema,
listSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { toError, toPromise } from '../fp_utils';
import { LIST_INDEX, LIST_ITEM_URL, LIST_PRIVILEGES_URL, LIST_URL } from '../../common/constants';
import { toError, toPromise } from '../common/fp_utils';
import { LIST_INDEX, LIST_ITEM_URL, LIST_PRIVILEGES_URL, LIST_URL } from '../constants';
import {
ApiParams,
@ -69,9 +70,9 @@ const findListsWithValidation = async ({
}: FindListsParams): Promise<FoundListSchema> =>
pipe(
{
cursor: cursor?.toString(),
page: pageIndex?.toString(),
per_page: pageSize?.toString(),
cursor: cursor != null ? cursor.toString() : undefined,
page: pageIndex != null ? pageIndex.toString() : undefined,
per_page: pageSize != null ? pageSize.toString() : undefined,
},
(payload) => fromEither(validateEither(findListSchema, payload)),
chain((payload) => tryCatch(() => findLists({ http, signal, ...payload }), toError)),

View file

@ -0,0 +1,44 @@
/*
* 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 type { Type } from '@kbn/securitysolution-io-ts-list-types';
// TODO: Replace these with kbn packaged versions once we have those available to us
// These originally came from this location below before moving them to this hacked "any" types:
// import { HttpStart, NotificationsStart } from '../../../../../src/core/public';
interface HttpStart {
fetch: <T>(...args: any) => any;
}
export interface ApiParams {
http: HttpStart;
signal: AbortSignal;
}
export type ApiPayload<T extends ApiParams> = Omit<T, 'http' | 'signal'>;
export interface FindListsParams extends ApiParams {
cursor?: string | undefined;
pageSize: number | undefined;
pageIndex: number | undefined;
}
export interface ImportListParams extends ApiParams {
file: File;
listId: string | undefined;
type: Type | undefined;
}
export interface DeleteListParams extends ApiParams {
deleteReferences?: boolean;
id: string;
ignoreReferences?: boolean;
}
export interface ExportListParams extends ApiParams {
listId: string;
}

View file

@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"incremental": true,
"outDir": "target",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-securitysolution-list-api/src",
"types": [
"jest",
"node"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,93 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
PKG_BASE_NAME = "kbn-securitysolution-list-hooks"
PKG_REQUIRE_NAME = "@kbn/securitysolution-list-hooks"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*",
"**/*.mock.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]
SRC_DEPS = [
"//packages/kbn-securitysolution-io-ts-list-types",
"//packages/kbn-securitysolution-list-api",
"//packages/kbn-securitysolution-utils",
"@npm//lodash",
"@npm//tslib",
"@npm//react",
"@npm//react-intl",
]
TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
"@npm//@types/react",
"@npm//@types/react-intl",
]
DEPS = SRC_DEPS + TYPES_DEPS
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)
ts_project(
name = "tsc",
srcs = SRCS,
args = ["--pretty"],
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
root_dir = "src",
source_map = True,
tsconfig = ":tsconfig",
deps = DEPS,
)
js_library(
name = PKG_BASE_NAME,
package_name = PKG_REQUIRE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
visibility = ["//visibility:public"],
deps = [":tsc"] + DEPS,
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
],
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,6 @@
# kbn-securitysolution-list-hooks
This is where shared constants for security solution should go that are going to be shared among plugins.
This was originally created to remove the dependencies between security_solution and other projects such as lists.

View file

@ -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.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-securitysolution-list-hooks'],
};

View file

@ -0,0 +1,9 @@
{
"name": "@kbn/securitysolution-list-hooks",
"version": "1.0.0",
"description": "Security solution list ReactJS hooks",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"private": true
}

View file

@ -0,0 +1,34 @@
/*
* 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.
*/
/**
* This ID is used for _both_ the Saved Object ID and for the list_id
* for the single global space agnostic endpoint list.
*
* TODO: Create a kbn-securitysolution-constants and add this to it.
* @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants.
*/
export const ENDPOINT_LIST_ID = 'endpoint_list';
/**
* Description of trusted apps agnostic list
* @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants.
*/
export const ENDPOINT_TRUSTED_APPS_LIST_DESCRIPTION = 'Endpoint Security Trusted Apps List';
/**
* ID of trusted apps agnostic list
* @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants.
*/
export const ENDPOINT_TRUSTED_APPS_LIST_ID = 'endpoint_trusted_apps';
/**
* Name of trusted apps agnostic list
* @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants.
*/
export const ENDPOINT_TRUSTED_APPS_LIST_NAME = 'Endpoint Security Trusted Apps List';

View file

@ -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 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 './transforms';
export * from './use_api';
export * from './use_async';
export * from './use_create_list_index';
export * from './use_cursor';
export * from './use_delete_list';
export * from './use_exception_list_items';
export * from './use_exception_lists';
export * from './use_export_list';
export * from './use_find_lists';
export * from './use_import_list';
export * from './use_is_mounted';
export * from './use_persist_exception_item';
export * from './use_persist_exception_list';
export * from './use_read_list_index';
export * from './use_read_list_privileges';
export * from './utils';
export * from './with_optional_signal';

View file

@ -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.
*/
describe('Exceptions transforms', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/exceptions/transforms.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,8 +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.
* 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 { flow } from 'fp-ts/lib/function';

View file

@ -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.
*/
describe('useApi', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/exceptions/hooks/use_api.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,8 +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.
* 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 { useMemo } from 'react';
@ -11,11 +12,19 @@ import type {
ExceptionListItemSchema,
ExceptionListSchema,
UpdateExceptionListItemSchema,
ApiCallFindListsItemsMemoProps,
ApiCallMemoProps,
ApiListExportProps,
} from '@kbn/securitysolution-io-ts-list-types';
import * as Api from '@kbn/securitysolution-list-api';
// TODO: Replace these with kbn packaged versions once we have those available to us
// These originally came from this location below before moving them to this hacked "any" types:
// import { HttpStart, NotificationsStart } from '../../../../../src/core/public';
interface HttpStart {
fetch: <T>(...args: any) => any;
}
import * as Api from '../api';
import { HttpStart } from '../../../../../../src/core/public';
import { ApiCallFindListsItemsMemoProps, ApiCallMemoProps, ApiListExportProps } from '../types';
import { getIdsAndNamespaces } from '../utils';
import { transformInput, transformNewItemOutput, transformOutput } from '../transforms';
@ -206,7 +215,7 @@ export const useApi = (http: HttpStart): ExceptionsApi => {
exceptions: [],
pagination: {
page: 0,
perPage: pagination.perPage ?? 0,
perPage: pagination.perPage != null ? pagination.perPage : 0,
total: 0,
},
});

View file

@ -0,0 +1,7 @@
/*
* 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.
*/

View file

@ -1,13 +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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 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 { act, renderHook } from '@testing-library/react-hooks';
import { useAsync } from './use_async';
import { useAsync } from '.';
interface TestArgs {
n: number;

View file

@ -1,13 +1,16 @@
/*
* 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.
* 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 { useCallback, useState } from 'react';
import { useIsMounted } from './use_is_mounted';
import { useIsMounted } from '../use_is_mounted';
// TODO: This is probably better off in another package such as kbn-securitysolution-hook-utils
export interface Async<Args extends unknown[], Result> {
loading: boolean;

View file

@ -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.
*/
describe('useCreateListIndex', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/lists/hooks/use_create_list_index.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -0,0 +1,15 @@
/*
* 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 { createListIndex } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
const createListIndexWithOptionalSignal = withOptionalSignal(createListIndex);
export const useCreateListIndex = () => useAsync(createListIndexWithOptionalSignal);

View file

@ -1,13 +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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 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 { act, renderHook } from '@testing-library/react-hooks';
import { UseCursorProps, useCursor } from './use_cursor';
import { UseCursorProps, useCursor } from '.';
describe('useCursor', () => {
it('returns undefined cursor if no values have been set', () => {

View file

@ -1,8 +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.
* 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 { useCallback, useState } from 'react';

View file

@ -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.
*/
describe('useDeleteList', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/lists/hooks/use_delete_list.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -0,0 +1,15 @@
/*
* 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 { deleteList } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
const deleteListWithOptionalSignal = withOptionalSignal(deleteList);
export const useDeleteList = () => useAsync(deleteListWithOptionalSignal);

View file

@ -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.
*/
describe('useExceptionListItems', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,15 +1,20 @@
/*
* 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.
* 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 { useEffect, useRef, useState } from 'react';
import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
import type {
ExceptionListItemSchema,
Pagination,
UseExceptionListProps,
FilterExceptionsOptions,
} from '@kbn/securitysolution-io-ts-list-types';
import { fetchExceptionListsItemsByListIds } from '@kbn/securitysolution-list-api';
import { fetchExceptionListsItemsByListIds } from '../api';
import { FilterExceptionsOptions, Pagination, UseExceptionListProps } from '../types';
import { getIdsAndNamespaces } from '../utils';
import { transformInput } from '../transforms';

View file

@ -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.
*/
describe('useExceptionLists', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,15 +1,19 @@
/*
* 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.
* 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 { useEffect, useMemo, useRef, useState } from 'react';
import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types';
import type {
ExceptionListSchema,
UseExceptionListsProps,
Pagination,
} from '@kbn/securitysolution-io-ts-list-types';
import { fetchExceptionLists } from '@kbn/securitysolution-list-api';
import { fetchExceptionLists } from '../api';
import { Pagination, UseExceptionListsProps } from '../types';
import { getFilters } from '../utils';
export type Func = () => void;

View file

@ -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.
*/
describe('useExceptionLists', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/lists/hooks/use_export_list.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -0,0 +1,15 @@
/*
* 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 { exportList } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
const exportListWithOptionalSignal = withOptionalSignal(exportList);
export const useExportList = () => useAsync(exportListWithOptionalSignal);

View file

@ -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.
*/
describe('useFindLists', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/lists/hooks/use_find_lists.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -0,0 +1,15 @@
/*
* 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 { findLists } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
const findListsWithOptionalSignal = withOptionalSignal(findLists);
export const useFindLists = () => useAsync(findListsWithOptionalSignal);

View file

@ -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.
*/
describe('useImportList', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/lists/hooks/use_import_list.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -0,0 +1,15 @@
/*
* 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 { importList } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
const importListWithOptionalSignal = withOptionalSignal(importList);
export const useImportList = () => useAsync(importListWithOptionalSignal);

View file

@ -1,13 +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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 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 { renderHook } from '@testing-library/react-hooks';
import { useIsMounted } from './use_is_mounted';
import { useIsMounted } from '.';
describe('useIsMounted', () => {
it('evaluates to true when mounted', () => {

View file

@ -1,14 +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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 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 { useCallback, useEffect, useRef } from 'react';
type GetIsMounted = () => boolean;
// TODO: This is probably better off in another package such as kbn-securitysolution-hook-utils
/**
*
* @returns A {@link GetIsMounted} getter function returning whether the component is currently mounted

View file

@ -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.
*/
describe('usePersistExceptionItem', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/exceptions/hooks/persist_exception_item.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,19 +1,20 @@
/*
* 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.
* 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 { Dispatch, useEffect, useState } from 'react';
import type {
CreateExceptionListItemSchema,
PersistHookProps,
UpdateExceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { addExceptionListItem, updateExceptionListItem } from '@kbn/securitysolution-list-api';
import { addExceptionListItem, updateExceptionListItem } from '../api';
import { transformNewItemOutput, transformOutput } from '../transforms';
import { PersistHookProps } from '../types';
interface PersistReturnExceptionItem {
isLoading: boolean;
@ -25,6 +26,8 @@ export type ReturnPersistExceptionItem = [
Dispatch<CreateExceptionListItemSchema | UpdateExceptionListItemSchema | null>
];
// TODO: Add this to @kbn/securitysolution-list-hooks
/**
* Hook for creating or updating ExceptionListItem
*

View file

@ -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.
*/
describe('usePersistExceptionList', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/exceptions/hooks/persist_exception_list.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,15 +1,18 @@
/*
* 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.
* 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 { Dispatch, useEffect, useState } from 'react';
import type { UpdateExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types';
import { addExceptionList, updateExceptionList } from '../api';
import { AddExceptionList, PersistHookProps } from '../types';
import type {
AddExceptionList,
PersistHookProps,
UpdateExceptionListSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { addExceptionList, updateExceptionList } from '@kbn/securitysolution-list-api';
interface PersistReturnExceptionList {
isLoading: boolean;

View file

@ -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.
*/
describe('useReadListIndex', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/public/lists/hooks/use_read_list_index.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -0,0 +1,15 @@
/*
* 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 { readListIndex } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
const readListIndexWithOptionalSignal = withOptionalSignal(readListIndex);
export const useReadListIndex = () => useAsync(readListIndexWithOptionalSignal);

View file

@ -0,0 +1,15 @@
/*
* 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 { readListPrivileges } from '@kbn/securitysolution-list-api';
import { withOptionalSignal } from '../with_optional_signal';
import { useAsync } from '../use_async';
const readListPrivilegesWithOptionalSignal = withOptionalSignal(readListPrivileges);
export const useReadListPrivileges = () => useAsync(readListPrivilegesWithOptionalSignal);

View file

@ -0,0 +1,272 @@
/*
* 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 { getFilters, getGeneralFilters, getIdsAndNamespaces, getTrustedAppsFilter } from '.';
describe('Exceptions utils', () => {
describe('#getIdsAndNamespaces', () => {
test('it returns empty arrays if no lists found', async () => {
const output = getIdsAndNamespaces({
lists: [],
showDetection: false,
showEndpoint: false,
});
expect(output).toEqual({ ids: [], namespaces: [] });
});
test('it returns all lists if "showDetection" and "showEndpoint" are "false"', async () => {
const output = getIdsAndNamespaces({
lists: [
{ id: 'myListId', listId: 'list_id', namespaceType: 'single', type: 'detection' },
{
id: 'myListIdEndpoint',
listId: 'list_id_endpoint',
namespaceType: 'agnostic',
type: 'endpoint',
},
],
showDetection: false,
showEndpoint: false,
});
expect(output).toEqual({
ids: ['list_id', 'list_id_endpoint'],
namespaces: ['single', 'agnostic'],
});
});
test('it returns only detections lists if "showDetection" is "true"', async () => {
const output = getIdsAndNamespaces({
lists: [
{ id: 'myListId', listId: 'list_id', namespaceType: 'single', type: 'detection' },
{
id: 'myListIdEndpoint',
listId: 'list_id_endpoint',
namespaceType: 'agnostic',
type: 'endpoint',
},
],
showDetection: true,
showEndpoint: false,
});
expect(output).toEqual({
ids: ['list_id'],
namespaces: ['single'],
});
});
test('it returns only endpoint lists if "showEndpoint" is "true"', async () => {
const output = getIdsAndNamespaces({
lists: [
{ id: 'myListId', listId: 'list_id', namespaceType: 'single', type: 'detection' },
{
id: 'myListIdEndpoint',
listId: 'list_id_endpoint',
namespaceType: 'agnostic',
type: 'endpoint',
},
],
showDetection: false,
showEndpoint: true,
});
expect(output).toEqual({
ids: ['list_id_endpoint'],
namespaces: ['agnostic'],
});
});
test('it returns only detection lists if both "showEndpoint" and "showDetection" are "true"', async () => {
const output = getIdsAndNamespaces({
lists: [
{ id: 'myListId', listId: 'list_id', namespaceType: 'single', type: 'detection' },
{
id: 'myListIdEndpoint',
listId: 'list_id_endpoint',
namespaceType: 'agnostic',
type: 'endpoint',
},
],
showDetection: true,
showEndpoint: true,
});
expect(output).toEqual({
ids: ['list_id'],
namespaces: ['single'],
});
});
});
describe('getGeneralFilters', () => {
test('it returns empty string if no filters', () => {
const filters = getGeneralFilters({}, ['exception-list']);
expect(filters).toEqual('');
});
test('it properly formats filters when one namespace type passed in', () => {
const filters = getGeneralFilters({ created_by: 'moi', name: 'Sample' }, ['exception-list']);
expect(filters).toEqual(
'(exception-list.attributes.created_by:moi) AND (exception-list.attributes.name.text:Sample)'
);
});
test('it properly formats filters when two namespace types passed in', () => {
const filters = getGeneralFilters({ created_by: 'moi', name: 'Sample' }, [
'exception-list',
'exception-list-agnostic',
]);
expect(filters).toEqual(
'(exception-list.attributes.created_by:moi OR exception-list-agnostic.attributes.created_by:moi) AND (exception-list.attributes.name.text:Sample OR exception-list-agnostic.attributes.name.text:Sample)'
);
});
});
describe('getTrustedAppsFilter', () => {
test('it returns filter to search for "exception-list" namespace trusted apps', () => {
const filter = getTrustedAppsFilter(true, ['exception-list']);
expect(filter).toEqual('(exception-list.attributes.list_id: endpoint_trusted_apps*)');
});
test('it returns filter to search for "exception-list" and "agnostic" namespace trusted apps', () => {
const filter = getTrustedAppsFilter(true, ['exception-list', 'exception-list-agnostic']);
expect(filter).toEqual(
'(exception-list.attributes.list_id: endpoint_trusted_apps* OR exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it returns filter to exclude "exception-list" namespace trusted apps', () => {
const filter = getTrustedAppsFilter(false, ['exception-list']);
expect(filter).toEqual('(not exception-list.attributes.list_id: endpoint_trusted_apps*)');
});
test('it returns filter to exclude "exception-list" and "agnostic" namespace trusted apps', () => {
const filter = getTrustedAppsFilter(false, ['exception-list', 'exception-list-agnostic']);
expect(filter).toEqual(
'(not exception-list.attributes.list_id: endpoint_trusted_apps* AND not exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
});
describe('getFilters', () => {
describe('single', () => {
test('it properly formats when no filters passed and "showTrustedApps" is false', () => {
const filter = getFilters({}, ['single'], false);
expect(filter).toEqual('(not exception-list.attributes.list_id: endpoint_trusted_apps*)');
});
test('it properly formats when no filters passed and "showTrustedApps" is true', () => {
const filter = getFilters({}, ['single'], true);
expect(filter).toEqual('(exception-list.attributes.list_id: endpoint_trusted_apps*)');
});
test('it properly formats when filters passed and "showTrustedApps" is false', () => {
const filter = getFilters({ created_by: 'moi', name: 'Sample' }, ['single'], false);
expect(filter).toEqual(
'(exception-list.attributes.created_by:moi) AND (exception-list.attributes.name.text:Sample) AND (not exception-list.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it if filters passed and "showTrustedApps" is true', () => {
const filter = getFilters({ created_by: 'moi', name: 'Sample' }, ['single'], true);
expect(filter).toEqual(
'(exception-list.attributes.created_by:moi) AND (exception-list.attributes.name.text:Sample) AND (exception-list.attributes.list_id: endpoint_trusted_apps*)'
);
});
});
describe('agnostic', () => {
test('it properly formats when no filters passed and "showTrustedApps" is false', () => {
const filter = getFilters({}, ['agnostic'], false);
expect(filter).toEqual(
'(not exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it properly formats when no filters passed and "showTrustedApps" is true', () => {
const filter = getFilters({}, ['agnostic'], true);
expect(filter).toEqual(
'(exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it properly formats when filters passed and "showTrustedApps" is false', () => {
const filter = getFilters({ created_by: 'moi', name: 'Sample' }, ['agnostic'], false);
expect(filter).toEqual(
'(exception-list-agnostic.attributes.created_by:moi) AND (exception-list-agnostic.attributes.name.text:Sample) AND (not exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it if filters passed and "showTrustedApps" is true', () => {
const filter = getFilters({ created_by: 'moi', name: 'Sample' }, ['agnostic'], true);
expect(filter).toEqual(
'(exception-list-agnostic.attributes.created_by:moi) AND (exception-list-agnostic.attributes.name.text:Sample) AND (exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
});
describe('single, agnostic', () => {
test('it properly formats when no filters passed and "showTrustedApps" is false', () => {
const filter = getFilters({}, ['single', 'agnostic'], false);
expect(filter).toEqual(
'(not exception-list.attributes.list_id: endpoint_trusted_apps* AND not exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it properly formats when no filters passed and "showTrustedApps" is true', () => {
const filter = getFilters({}, ['single', 'agnostic'], true);
expect(filter).toEqual(
'(exception-list.attributes.list_id: endpoint_trusted_apps* OR exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it properly formats when filters passed and "showTrustedApps" is false', () => {
const filter = getFilters(
{ created_by: 'moi', name: 'Sample' },
['single', 'agnostic'],
false
);
expect(filter).toEqual(
'(exception-list.attributes.created_by:moi OR exception-list-agnostic.attributes.created_by:moi) AND (exception-list.attributes.name.text:Sample OR exception-list-agnostic.attributes.name.text:Sample) AND (not exception-list.attributes.list_id: endpoint_trusted_apps* AND not exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
test('it properly formats when filters passed and "showTrustedApps" is true', () => {
const filter = getFilters(
{ created_by: 'moi', name: 'Sample' },
['single', 'agnostic'],
true
);
expect(filter).toEqual(
'(exception-list.attributes.created_by:moi OR exception-list-agnostic.attributes.created_by:moi) AND (exception-list.attributes.name.text:Sample OR exception-list-agnostic.attributes.name.text:Sample) AND (exception-list.attributes.list_id: endpoint_trusted_apps* OR exception-list-agnostic.attributes.list_id: endpoint_trusted_apps*)'
);
});
});
});
});

View file

@ -0,0 +1,118 @@
/*
* 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 type {
NamespaceType,
NamespaceTypeArray,
ExceptionListFilter,
ExceptionListIdentifiers,
} from '@kbn/securitysolution-io-ts-list-types';
import { get } from 'lodash/fp';
import { ENDPOINT_TRUSTED_APPS_LIST_ID } from '../constants';
export const exceptionListSavedObjectType = 'exception-list';
export const exceptionListAgnosticSavedObjectType = 'exception-list-agnostic';
export type SavedObjectType = 'exception-list' | 'exception-list-agnostic';
export const getSavedObjectType = ({
namespaceType,
}: {
namespaceType: NamespaceType;
}): SavedObjectType => {
if (namespaceType === 'agnostic') {
return exceptionListAgnosticSavedObjectType;
} else {
return exceptionListSavedObjectType;
}
};
export const getSavedObjectTypes = ({
namespaceType,
}: {
namespaceType: NamespaceTypeArray;
}): SavedObjectType[] => {
return namespaceType.map((singleNamespaceType) =>
getSavedObjectType({ namespaceType: singleNamespaceType })
);
};
export const getIdsAndNamespaces = ({
lists,
showDetection,
showEndpoint,
}: {
lists: ExceptionListIdentifiers[];
showDetection: boolean;
showEndpoint: boolean;
}): { ids: string[]; namespaces: NamespaceType[] } =>
lists
.filter((list) => {
if (showDetection) {
return list.type === 'detection';
} else if (showEndpoint) {
return list.type === 'endpoint';
} else {
return true;
}
})
.reduce<{ ids: string[]; namespaces: NamespaceType[] }>(
(acc, { listId, namespaceType }) => ({
ids: [...acc.ids, listId],
namespaces: [...acc.namespaces, namespaceType],
}),
{ ids: [], namespaces: [] }
);
export const getGeneralFilters = (
filters: ExceptionListFilter,
namespaceTypes: SavedObjectType[]
): string => {
return Object.keys(filters)
.map((filterKey) => {
const value = get(filterKey, filters);
if (value != null && value.trim() !== '') {
const filtersByNamespace = namespaceTypes
.map((namespace) => {
const fieldToSearch = filterKey === 'name' ? 'name.text' : filterKey;
return `${namespace}.attributes.${fieldToSearch}:${value}`;
})
.join(' OR ');
return `(${filtersByNamespace})`;
} else return null;
})
.filter((item) => item != null)
.join(' AND ');
};
export const getTrustedAppsFilter = (
showTrustedApps: boolean,
namespaceTypes: SavedObjectType[]
): string => {
if (showTrustedApps) {
const filters = namespaceTypes.map((namespace) => {
return `${namespace}.attributes.list_id: ${ENDPOINT_TRUSTED_APPS_LIST_ID}*`;
});
return `(${filters.join(' OR ')})`;
} else {
const filters = namespaceTypes.map((namespace) => {
return `not ${namespace}.attributes.list_id: ${ENDPOINT_TRUSTED_APPS_LIST_ID}*`;
});
return `(${filters.join(' AND ')})`;
}
};
export const getFilters = (
filters: ExceptionListFilter,
namespaceTypes: NamespaceType[],
showTrustedApps: boolean
): string => {
const namespaces = getSavedObjectTypes({ namespaceType: namespaceTypes });
const generalFilters = getGeneralFilters(filters, namespaces);
const trustedAppsFilter = getTrustedAppsFilter(showTrustedApps, namespaces);
return [generalFilters, trustedAppsFilter].filter((filter) => filter.trim() !== '').join(' AND ');
};

View file

@ -0,0 +1,31 @@
/*
* 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 { withOptionalSignal } from '.';
type TestFn = ({ number, signal }: { number: number; signal: AbortSignal }) => boolean;
describe('withOptionalSignal', () => {
it('does not require a signal on the returned function', () => {
const fn = jest.fn().mockReturnValue('hello') as TestFn;
const wrappedFn = withOptionalSignal(fn);
expect(wrappedFn({ number: 1 })).toEqual('hello');
});
it('will pass a given signal to the wrapped function', () => {
const fn = jest.fn().mockReturnValue('hello') as TestFn;
const { signal } = new AbortController();
const wrappedFn = withOptionalSignal(fn);
wrappedFn({ number: 1, signal });
expect(fn).toHaveBeenCalledWith({ number: 1, signal });
});
});

View file

@ -0,0 +1,28 @@
/*
* 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.
*/
interface SignalArgs {
signal: AbortSignal;
}
export type OptionalSignalArgs<Args> = Omit<Args, 'signal'> & Partial<SignalArgs>;
// TODO: This is probably better off in another package such as kbn-securitysolution-hook-utils
/**
*
* @param fn an async function receiving an AbortSignal argument
*
* @returns An async function where the AbortSignal argument is optional
*/
export const withOptionalSignal = <Args extends SignalArgs, Result>(fn: (args: Args) => Result) => (
args: OptionalSignalArgs<Args>
): Result => {
const signal = args.signal != null ? args.signal : new AbortController().signal;
return fn({ ...args, signal } as Args);
};

View file

@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"incremental": true,
"outDir": "target",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-securitysolution-list-hooks/src",
"types": [
"jest",
"node"
]
},
"include": [
"src/**/*"
]
}

View file

@ -31,11 +31,13 @@ SRC_DEPS = [
"//packages/kbn-i18n",
"//packages/kbn-securitysolution-io-ts-list-types",
"//packages/kbn-securitysolution-utils",
"@npm//lodash",
"@npm//tslib",
]
TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
]

View file

@ -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.
*/
describe('build_exceptions_filter', () => {
test('Tests should be ported', () => {
// TODO: Port all the tests from: x-pack/plugins/lists/common/exceptions/build_exceptions_filter.test.ts here once mocks are figured out and kbn package mocks are figured out
expect(true).toBe(true);
});
});

View file

@ -1,11 +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; you may not use this file except in compliance with the Elastic License
* 2.0.
* 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 { chunk } from 'lodash/fp';
import {
CreateExceptionListItemSchema,
EntryExists,
@ -19,10 +21,15 @@ import {
entriesNested,
} from '@kbn/securitysolution-io-ts-list-types';
import type { Filter } from '../../../../../src/plugins/data/common';
import { hasLargeValueList } from '../has_large_value_list';
import type { BooleanFilter, NestedFilter } from './types';
import { hasLargeValueList } from './utils';
/**
* Originally this was an import type of:
* import type { Filter } from '../../../../../src/plugins/data/common';
* TODO: Once we have the type for this within kbn packages, replace this with that one
* @deprecated
*/
type Filter = any;
type NonListEntry = EntryMatch | EntryMatchAny | EntryNested | EntryExists;
interface ExceptionListItemNonLargeList extends ExceptionListItemSchema {
@ -37,6 +44,24 @@ export type ExceptionItemSansLargeValueLists =
| ExceptionListItemNonLargeList
| CreateExceptionListItemNonLargeList;
export interface BooleanFilter {
bool: {
must?: unknown | unknown[];
must_not?: unknown | unknown[];
should?: unknown[];
filter?: unknown | unknown[];
minimum_should_match?: number;
};
}
export interface NestedFilter {
nested: {
path: string;
query: unknown | unknown[];
score_mode: string;
};
}
export const chunkExceptions = (
exceptions: ExceptionItemSansLargeValueLists[],
chunkSize: number

View file

@ -1,8 +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.
* 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 type { EntriesArray } from '@kbn/securitysolution-io-ts-list-types';

View file

@ -6,5 +6,7 @@
* Side Public License, v 1.
*/
export * from './autocomplete_operators';
export * from './build_exception_filter';
export * from './has_large_value_list';
export * from './helpers';
export * from './types';

View file

@ -9,6 +9,16 @@ import type {
EntryMatchAny,
ExceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import {
buildExceptionFilter,
buildExceptionItemFilter,
buildExclusionClause,
buildExistsClause,
buildMatchAnyClause,
buildMatchClause,
buildNestedClause,
createOrClauses,
} from '@kbn/securitysolution-list-utils';
import { getEntryMatchExcludeMock, getEntryMatchMock } from '../schemas/types/entry_match.mock';
import {
@ -23,16 +33,7 @@ import {
} from '../schemas/types/entry_nested.mock';
import { getExceptionListItemSchemaMock } from '../schemas/response/exception_list_item_schema.mock';
import {
buildExceptionFilter,
buildExceptionItemFilter,
buildExclusionClause,
buildExistsClause,
buildMatchAnyClause,
buildMatchClause,
buildNestedClause,
createOrClauses,
} from './build_exceptions_filter';
// TODO: Port the test over to packages/kbn-securitysolution-list-utils/src/build_exception_filter/index.test.ts once the mocks are ported to kbn
const modifiedGetEntryMatchAnyMock = (): EntryMatchAny => ({
...getEntryMatchAnyMock(),

View file

@ -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 './build_exceptions_filter';

View file

@ -1,24 +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 interface BooleanFilter {
bool: {
must?: unknown | unknown[];
must_not?: unknown | unknown[];
should?: unknown[];
filter?: unknown | unknown[];
minimum_should_match?: number;
};
}
export interface NestedFilter {
nested: {
path: string;
query: unknown | unknown[];
score_mode: string;
};
}

View file

@ -5,8 +5,9 @@
* 2.0.
*/
export { buildExceptionFilter } from './exceptions';
/** DEPRECATED, TRY NOT NOT TO ADD ANYTHING HERE. INSTEAD TRY TO USE/CREATE kibana packages @kbn/... */
// TODO: Move this into one of the kibana packages and remove it from here
export {
ENDPOINT_LIST_ID,
ENDPOINT_TRUSTED_APPS_LIST_ID,

View file

@ -5,16 +5,6 @@
* 2.0.
*/
import { coreMock } from '../../../../../src/core/public/mocks';
import { getExceptionListSchemaMock } from '../../common/schemas/response/exception_list_schema.mock';
import { getExceptionListItemSchemaMock } from '../../common/schemas/response/exception_list_item_schema.mock';
import { getCreateExceptionListSchemaMock } from '../../common/schemas/request/create_exception_list_schema.mock';
import { getCreateExceptionListItemSchemaMock } from '../../common/schemas/request/create_exception_list_item_schema.mock';
import { getFoundExceptionListItemSchemaMock } from '../../common/schemas/response/found_exception_list_item_schema.mock';
import { getUpdateExceptionListItemSchemaMock } from '../../common/schemas/request/update_exception_list_item_schema.mock';
import { getUpdateExceptionListSchemaMock } from '../../common/schemas/request/update_exception_list_schema.mock';
import { getFoundExceptionListSchemaMock } from '../../common/schemas/response/found_exception_list_schema.mock';
import {
addEndpointExceptionList,
addExceptionList,
@ -28,7 +18,20 @@ import {
fetchExceptionListsItemsByListIds,
updateExceptionList,
updateExceptionListItem,
} from './api';
} from '@kbn/securitysolution-list-api';
import { coreMock } from '../../../../../src/core/public/mocks';
import { getExceptionListSchemaMock } from '../../common/schemas/response/exception_list_schema.mock';
import { getExceptionListItemSchemaMock } from '../../common/schemas/response/exception_list_item_schema.mock';
import { getCreateExceptionListSchemaMock } from '../../common/schemas/request/create_exception_list_schema.mock';
import { getCreateExceptionListItemSchemaMock } from '../../common/schemas/request/create_exception_list_item_schema.mock';
import { getFoundExceptionListItemSchemaMock } from '../../common/schemas/response/found_exception_list_item_schema.mock';
import { getUpdateExceptionListItemSchemaMock } from '../../common/schemas/request/update_exception_list_item_schema.mock';
import { getUpdateExceptionListSchemaMock } from '../../common/schemas/request/update_exception_list_schema.mock';
import { getFoundExceptionListSchemaMock } from '../../common/schemas/response/found_exception_list_schema.mock';
// TODO: These tests are left here until we move the mocks including the coreMock above into a location where we can consume them in a kbn package
// TODO: This really belongs as: kbn-securitysolution-list-api/src/api/index.test.ts as soon as we can.
const abortCtrl = new AbortController();

View file

@ -30,8 +30,8 @@ const mockKeywordList: ListSchema = {
};
const mockResult = { ...getFoundListSchemaMock() };
mockResult.data = [...mockResult.data, mockKeywordList];
jest.mock('../../..', () => {
const originalModule = jest.requireActual('../../..');
jest.mock('@kbn/securitysolution-list-hooks', () => {
const originalModule = jest.requireActual('@kbn/securitysolution-list-hooks');
return {
...originalModule,

View file

@ -9,9 +9,9 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui';
import { HttpStart } from 'kibana/public';
import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types';
import { useFindLists } from '@kbn/securitysolution-list-hooks';
import { IFieldType } from '../../../../../../../src/plugins/data/common';
import { useFindLists } from '../../..';
import { filterFieldToList, getGenericComboBoxProps } from './helpers';
import * as i18n from './translations';

View file

@ -19,6 +19,7 @@ import {
isOneOfOperator,
isOperator,
} from '@kbn/securitysolution-list-utils';
import { useFindLists } from '@kbn/securitysolution-list-hooks';
import {
fields,
@ -27,11 +28,10 @@ import {
import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks';
import { coreMock } from '../../../../../../../src/core/public/mocks';
import { getFoundListSchemaMock } from '../../../../common/schemas/response/found_list_schema.mock';
import { useFindLists } from '../../../lists/hooks/use_find_lists';
import { BuilderEntryItem } from './entry_renderer';
jest.mock('../../../lists/hooks/use_find_lists');
jest.mock('@kbn/securitysolution-list-hooks');
const mockKibanaHttpService = coreMock.createStart().http;
const { autocomplete: autocompleteStartMock } = dataPluginMock.createStartContract();

View file

@ -6,18 +6,23 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import * as api from '@kbn/securitysolution-list-api';
import { PersistHookProps } from '@kbn/securitysolution-io-ts-list-types';
import {
ReturnPersistExceptionItem,
usePersistExceptionItem,
} from '@kbn/securitysolution-list-hooks';
import { ENTRIES_WITH_IDS } from '../../../common/constants.mock';
import { coreMock } from '../../../../../../src/core/public/mocks';
import * as api from '../api';
import { getCreateExceptionListItemSchemaMock } from '../../../common/schemas/request/create_exception_list_item_schema.mock';
import { getUpdateExceptionListItemSchemaMock } from '../../../common/schemas/request/update_exception_list_item_schema.mock';
import { getExceptionListItemSchemaMock } from '../../../common/schemas/response/exception_list_item_schema.mock';
import { PersistHookProps } from '../types';
import { ReturnPersistExceptionItem, usePersistExceptionItem } from './persist_exception_item';
const mockKibanaHttpService = coreMock.createStart().http;
jest.mock('@kbn/securitysolution-list-api');
// TODO: Port this test over to packages/kbn-securitysolution-list-hooks/src/use_persist_exception_item/index.test.ts once the other mocks are added to the kbn package system
describe('usePersistExceptionItem', () => {
const onError = jest.fn();

View file

@ -6,18 +6,24 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import * as api from '@kbn/securitysolution-list-api';
import { PersistHookProps } from '@kbn/securitysolution-io-ts-list-types';
import {
ReturnPersistExceptionList,
usePersistExceptionList,
} from '@kbn/securitysolution-list-hooks';
import { coreMock } from '../../../../../../src/core/public/mocks';
import * as api from '../api';
import { getCreateExceptionListSchemaMock } from '../../../common/schemas/request/create_exception_list_schema.mock';
import { getUpdateExceptionListSchemaMock } from '../../../common/schemas/request/update_exception_list_schema.mock';
import { getExceptionListSchemaMock } from '../../../common/schemas/response/exception_list_schema.mock';
import { PersistHookProps } from '../types';
import { ReturnPersistExceptionList, usePersistExceptionList } from './persist_exception_list';
const mockKibanaHttpService = coreMock.createStart().http;
jest.mock('@kbn/securitysolution-list-api');
// TODO: Port this to the kbn package of: packages/kbn-securitysolution-list-hooks/src/use_persist_exception_list/index.test.ts once the kibana mocks are ported
describe('usePersistExceptionList', () => {
const onError = jest.fn();

View file

@ -6,24 +6,25 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import * as api from '@kbn/securitysolution-list-api';
import { ExceptionsApi, useApi } from '@kbn/securitysolution-list-hooks';
import type {
AddExceptionListItemProps,
ApiCallByIdProps,
ApiCallByListIdProps,
UpdateExceptionListItemProps,
} from '@kbn/securitysolution-io-ts-list-types';
import { ENTRIES_WITH_IDS } from '../../../common/constants.mock';
import { getUpdateExceptionListItemSchemaMock } from '../../../common/schemas/request/update_exception_list_item_schema.mock';
import { coreMock } from '../../../../../../src/core/public/mocks';
import * as api from '../api';
import { getExceptionListSchemaMock } from '../../../common/schemas/response/exception_list_schema.mock';
import { getFoundExceptionListItemSchemaMock } from '../../../common/schemas/response/found_exception_list_item_schema.mock';
import { getExceptionListItemSchemaMock } from '../../../common/schemas/response/exception_list_item_schema.mock';
import { getCreateExceptionListItemSchemaMock } from '../../../common/schemas/request/create_exception_list_item_schema.mock';
import { HttpStart } from '../../../../../../src/core/public';
import {
AddExceptionListItemProps,
ApiCallByIdProps,
ApiCallByListIdProps,
UpdateExceptionListItemProps,
} from '../types';
import { ExceptionsApi, useApi } from './use_api';
jest.mock('@kbn/securitysolution-list-api');
jest.mock('uuid', () => ({
v4: jest.fn().mockReturnValue('123'),
@ -31,6 +32,8 @@ jest.mock('uuid', () => ({
const mockKibanaHttpService = coreMock.createStart().http;
// TODO: Once the mocks are figured out and the types are moved into kbn core this test should be moved next to the file: packages/kbn-securitysolution-list-hooks/src/use_api/index.test.ts
describe('useApi', () => {
const onErrorMock = jest.fn();

View file

@ -6,22 +6,30 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
import type {
ExceptionListItemSchema,
UseExceptionListItemsSuccess,
UseExceptionListProps,
} from '@kbn/securitysolution-io-ts-list-types';
import * as api from '@kbn/securitysolution-list-api';
import {
ReturnExceptionListAndItems,
transformInput,
useExceptionListItems,
} from '@kbn/securitysolution-list-hooks';
import { coreMock } from '../../../../../../src/core/public/mocks';
import * as api from '../api';
import { getFoundExceptionListItemSchemaMock } from '../../../common/schemas/response/found_exception_list_item_schema.mock';
import { UseExceptionListItemsSuccess, UseExceptionListProps } from '../types';
import { transformInput } from '../transforms';
import { ReturnExceptionListAndItems, useExceptionListItems } from './use_exception_list_items';
jest.mock('uuid', () => ({
v4: jest.fn().mockReturnValue('123'),
}));
jest.mock('@kbn/securitysolution-list-api');
const mockKibanaHttpService = coreMock.createStart().http;
// TODO: Port all of this test code over to the package of: packages/kbn-securitysolution-list-hooks/src/use_exception_list_items/index.test.ts once the mocks and kibana core mocks are figured out
describe('useExceptionListItems', () => {
const onErrorMock = jest.fn();

View file

@ -6,17 +6,21 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types';
import type {
ExceptionListSchema,
UseExceptionListsProps,
} from '@kbn/securitysolution-io-ts-list-types';
import * as api from '@kbn/securitysolution-list-api';
import { ReturnExceptionLists, useExceptionLists } from '@kbn/securitysolution-list-hooks';
import { coreMock } from '../../../../../../src/core/public/mocks';
import * as api from '../api';
import { getFoundExceptionListSchemaMock } from '../../../common/schemas/response/found_exception_list_schema.mock';
import { UseExceptionListsProps } from '../types';
import { ReturnExceptionLists, useExceptionLists } from './use_exception_lists';
const mockKibanaHttpService = coreMock.createStart().http;
const mockKibanaNotificationsService = coreMock.createStart().notifications;
jest.mock('@kbn/securitysolution-list-api');
// TODO: Move this test to the kbn package: packages/kbn-securitysolution-list-hooks/src/use_exception_lists/index.test.ts once mocks are ported over
describe('useExceptionLists', () => {
beforeEach(() => {

View file

@ -13,23 +13,24 @@ import type {
ExceptionListItemSchema,
UpdateExceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import {
addIdToExceptionItemEntries,
removeIdFromExceptionItemsEntries,
transformInput,
transformOutput,
} from '@kbn/securitysolution-list-hooks';
import { getCreateExceptionListItemSchemaMock } from '../../common/schemas/request/create_exception_list_item_schema.mock';
import { getUpdateExceptionListItemSchemaMock } from '../../common/schemas/request/update_exception_list_item_schema.mock';
import { getExceptionListItemSchemaMock } from '../../common/schemas/response/exception_list_item_schema.mock';
import { ENTRIES_WITH_IDS } from '../../common/constants.mock';
import {
addIdToExceptionItemEntries,
removeIdFromExceptionItemsEntries,
transformInput,
transformOutput,
} from './transforms';
jest.mock('uuid', () => ({
v4: jest.fn().mockReturnValue('123'),
}));
// TODO: Once mocks are figured out, move this test to the kbn package of: kbn-securitysolution-list-hooks/src/transforms/index.test.ts
describe('Exceptions transforms', () => {
describe('transformOutput', () => {
it('returns same output as input with stripped ids per entry - CreateExceptionListItemSchema', () => {

View file

@ -6,7 +6,12 @@
*/
import { get } from 'lodash/fp';
import type { NamespaceType, NamespaceTypeArray } from '@kbn/securitysolution-io-ts-list-types';
import type {
ExceptionListFilter,
ExceptionListIdentifiers,
NamespaceType,
NamespaceTypeArray,
} from '@kbn/securitysolution-io-ts-list-types';
import { ENDPOINT_TRUSTED_APPS_LIST_ID } from '../../common/constants';
import {
@ -15,8 +20,6 @@ import {
exceptionListSavedObjectType,
} from '../../common/types';
import { ExceptionListFilter, ExceptionListIdentifiers } from './types';
export const getSavedObjectType = ({
namespaceType,
}: {

View file

@ -5,6 +5,15 @@
* 2.0.
*/
import {
createListIndex,
deleteList,
exportList,
findLists,
importList,
readListIndex,
} from '@kbn/securitysolution-list-api';
import { HttpFetchOptions } from '../../../../../src/core/public';
import { httpServiceMock } from '../../../../../src/core/public/mocks';
import { getAcknowledgeSchemaResponseMock } from '../../common/schemas/response/acknowledge_schema.mock';
@ -12,14 +21,6 @@ import { getListResponseMock } from '../../common/schemas/response/list_schema.m
import { getListItemIndexExistSchemaResponseMock } from '../../common/schemas/response/list_item_index_exist_schema.mock';
import { getFoundListSchemaMock } from '../../common/schemas/response/found_list_schema.mock';
import {
createListIndex,
deleteList,
exportList,
findLists,
importList,
readListIndex,
} from './api';
import {
ApiPayload,
DeleteListParams,
@ -28,6 +29,8 @@ import {
ImportListParams,
} from './types';
// TODO: This test should be ported to: packages/kbn-securitysolution-list-api/src/list_api/index.test.ts once the mocks are ported from Kibana core
describe('Value Lists API', () => {
let httpMock: ReturnType<typeof httpServiceMock.createStartContract>;

View file

@ -6,14 +6,15 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import { useCreateListIndex } from '@kbn/securitysolution-list-hooks';
import * as Api from '@kbn/securitysolution-list-api';
import * as Api from '../api';
import { httpServiceMock } from '../../../../../../src/core/public/mocks';
import { getAcknowledgeSchemaResponseMock } from '../../../common/schemas/response/acknowledge_schema.mock';
import { useCreateListIndex } from './use_create_list_index';
jest.mock('@kbn/securitysolution-list-api');
jest.mock('../api');
// TODO: This test should be ported to the package: packages/kbn-securitysolution-list-hooks/src/use_create_list_index/index.test.ts once we have mocks in kbn packages
describe('useCreateListIndex', () => {
let httpMock: ReturnType<typeof httpServiceMock.createStartContract>;

View file

@ -1,15 +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 { withOptionalSignal } from '../../common/with_optional_signal';
import { useAsync } from '../../common/hooks/use_async';
import { createListIndex } from '../api';
const createListIndexWithOptionalSignal = withOptionalSignal(createListIndex);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useCreateListIndex = () => useAsync(createListIndexWithOptionalSignal);

View file

@ -6,14 +6,15 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import { useDeleteList } from '@kbn/securitysolution-list-hooks';
import * as Api from '@kbn/securitysolution-list-api';
import * as Api from '../api';
import { httpServiceMock } from '../../../../../../src/core/public/mocks';
import { getListResponseMock } from '../../../common/schemas/response/list_schema.mock';
import { useDeleteList } from './use_delete_list';
jest.mock('@kbn/securitysolution-list-api');
jest.mock('../api');
// TODO: This test should be ported to the package: packages/kbn-securitysolution-list-hooks/src/use_delete_list/index.test.ts once we have mocks in kbn packages
describe('useDeleteList', () => {
let httpMock: ReturnType<typeof httpServiceMock.createStartContract>;

View file

@ -1,15 +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 { withOptionalSignal } from '../../common/with_optional_signal';
import { useAsync } from '../../common/hooks/use_async';
import { deleteList } from '../api';
const deleteListWithOptionalSignal = withOptionalSignal(deleteList);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useDeleteList = () => useAsync(deleteListWithOptionalSignal);

View file

@ -6,13 +6,14 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import { useExportList } from '@kbn/securitysolution-list-hooks';
import * as Api from '@kbn/securitysolution-list-api';
import * as Api from '../api';
import { httpServiceMock } from '../../../../../../src/core/public/mocks';
import { useExportList } from './use_export_list';
jest.mock('@kbn/securitysolution-list-api');
jest.mock('../api');
// TODO: Move this test to the kbn package: packages/kbn-securitysolution-list-hooks/src/use_export_list/index.ts once Mocks are ported from Kibana
describe('useExportList', () => {
let httpMock: ReturnType<typeof httpServiceMock.createStartContract>;

View file

@ -1,15 +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 { withOptionalSignal } from '../../common/with_optional_signal';
import { useAsync } from '../../common/hooks/use_async';
import { exportList } from '../api';
const exportListWithOptionalSignal = withOptionalSignal(exportList);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useExportList = () => useAsync(exportListWithOptionalSignal);

View file

@ -6,15 +6,15 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import { useFindLists } from '@kbn/securitysolution-list-hooks';
import * as Api from '@kbn/securitysolution-list-api';
import * as Api from '../api';
import { httpServiceMock } from '../../../../../../src/core/public/mocks';
import { getFoundListSchemaMock } from '../../../common/schemas/response/found_list_schema.mock';
import { useFindLists } from './use_find_lists';
jest.mock('../api');
jest.mock('@kbn/securitysolution-list-api');
// TODO: Move this test to the package of: kbn-securitysolution-list-hooks/src/use_find_lists/index.test.ts once kbn mocks such as httpServiceMock are figured out
describe('useFindLists', () => {
let httpMock: ReturnType<typeof httpServiceMock.createStartContract>;

View file

@ -1,15 +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 { withOptionalSignal } from '../../common/with_optional_signal';
import { useAsync } from '../../common/hooks/use_async';
import { findLists } from '../api';
const findListsWithOptionalSignal = withOptionalSignal(findLists);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useFindLists = () => useAsync(findListsWithOptionalSignal);

View file

@ -6,14 +6,15 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import { useImportList } from '@kbn/securitysolution-list-hooks';
import * as Api from '@kbn/securitysolution-list-api';
import { httpServiceMock } from '../../../../../../src/core/public/mocks';
import { getListResponseMock } from '../../../common/schemas/response/list_schema.mock';
import * as Api from '../api';
import { useImportList } from './use_import_list';
jest.mock('@kbn/securitysolution-list-api');
jest.mock('../api');
// TODO: Port this test over to: packages/kbn-securitysolution-list-hooks/src/use_import_list/index.ts once mocks are moved to packages
describe('useImportList', () => {
let httpMock: ReturnType<typeof httpServiceMock.createStartContract>;

View file

@ -1,15 +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 { withOptionalSignal } from '../../common/with_optional_signal';
import { useAsync } from '../../common/hooks/use_async';
import { importList } from '../api';
const importListWithOptionalSignal = withOptionalSignal(importList);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useImportList = () => useAsync(importListWithOptionalSignal);

View file

@ -6,14 +6,15 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
import { useReadListIndex } from '@kbn/securitysolution-list-hooks';
import * as Api from '@kbn/securitysolution-list-api';
import * as Api from '../api';
import { httpServiceMock } from '../../../../../../src/core/public/mocks';
import { getAcknowledgeSchemaResponseMock } from '../../../common/schemas/response/acknowledge_schema.mock';
import { useReadListIndex } from './use_read_list_index';
jest.mock('@kbn/securitysolution-list-api');
jest.mock('../api');
// TODO: Port this code over to the package: packages/kbn-securitysolution-list-hooks/src/use_read_list_index/index.test.ts once kibana has mocks in packages
describe('useReadListIndex', () => {
let httpMock: ReturnType<typeof httpServiceMock.createStartContract>;

View file

@ -1,15 +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 { withOptionalSignal } from '../../common/with_optional_signal';
import { useAsync } from '../../common/hooks/use_async';
import { readListIndex } from '../api';
const readListIndexWithOptionalSignal = withOptionalSignal(readListIndex);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useReadListIndex = () => useAsync(readListIndexWithOptionalSignal);

View file

@ -1,15 +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 { withOptionalSignal } from '../../common/with_optional_signal';
import { useAsync } from '../../common/hooks/use_async';
import { readListPrivileges } from '../api';
const readListPrivilegesWithOptionalSignal = withOptionalSignal(readListPrivileges);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useReadListPrivileges = () => useAsync(readListPrivilegesWithOptionalSignal);

View file

@ -5,33 +5,6 @@
* 2.0.
*/
// Exports to be shared with plugins
export { withOptionalSignal } from './common/with_optional_signal';
export { useAsync } from './common/hooks/use_async';
export { useApi } from './exceptions/hooks/use_api';
export { useExceptionListItems } from './exceptions/hooks/use_exception_list_items';
export { useExceptionLists } from './exceptions/hooks/use_exception_lists';
export { useFindLists } from './lists/hooks/use_find_lists';
export { useImportList } from './lists/hooks/use_import_list';
export { useDeleteList } from './lists/hooks/use_delete_list';
export { exportList } from './lists/api';
export { useCursor } from './common/hooks/use_cursor';
export { useExportList } from './lists/hooks/use_export_list';
export { useReadListIndex } from './lists/hooks/use_read_list_index';
export { useCreateListIndex } from './lists/hooks/use_create_list_index';
export { useReadListPrivileges } from './lists/hooks/use_read_list_privileges';
export {
fetchExceptionListById,
addExceptionList,
addEndpointExceptionList,
} from './exceptions/api';
export type {
ExceptionList,
ExceptionListFilter,
ExceptionListIdentifiers,
Pagination,
UseExceptionListItemsSuccess,
UseExceptionListsSuccess,
} from './exceptions/types';
/** DEPRECATED, TRY NOT TO ADD ANYTHING HERE. INSTEAD TRY TO USE AND/OR CREATE kibana packages @kbn/... */
export * as ExceptionBuilder from './exceptions/components/builder/index';
export { transformNewItemOutput, transformOutput } from './exceptions/transforms';

View file

@ -10,6 +10,7 @@ import type {
ExceptionListItemSchema,
CreateExceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { buildExceptionFilter } from '@kbn/securitysolution-list-utils';
import {
Filter,
IIndexPattern,
@ -17,7 +18,6 @@ import {
EsQueryConfig,
} from '../../../../../src/plugins/data/common';
import { ESBoolQuery } from '../typed_json';
import { buildExceptionFilter } from '../shared_imports';
import { Query, Index, TimestampOverrideOrUndefined } from './schemas/common/schemas';
export const getQueryFilter = (

View file

@ -13,5 +13,4 @@ export {
ENDPOINT_EVENT_FILTERS_LIST_ID,
ENDPOINT_EVENT_FILTERS_LIST_NAME,
ENDPOINT_EVENT_FILTERS_LIST_DESCRIPTION,
buildExceptionFilter,
} from '../../lists/common';

View file

@ -28,8 +28,8 @@ const mockKeywordList: ListSchema = {
};
const mockResult = { ...getFoundListSchemaMock() };
mockResult.data = [...mockResult.data, mockKeywordList];
jest.mock('../../../shared_imports', () => {
const originalModule = jest.requireActual('../../../shared_imports');
jest.mock('@kbn/securitysolution-list-hooks', () => {
const originalModule = jest.requireActual('@kbn/securitysolution-list-hooks');
return {
...originalModule,

Some files were not shown because too many files have changed in this diff Show more