From b2101f5ee92c8a161e11095315b559a4d3e2bdb0 Mon Sep 17 00:00:00 2001 From: Patryk Kopycinski Date: Mon, 31 Aug 2020 12:46:18 +0200 Subject: [PATCH] cleanup --- .../security_solution/network/index.ts | 85 +------------------ .../security_solution/network/tls.ts | 75 ++++++++++++++++ .../public/network/containers/tls/index.tsx | 13 +-- .../pages/navigation/tls_query_tab_body.tsx | 8 +- 4 files changed, 86 insertions(+), 95 deletions(-) create mode 100644 x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls.ts diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/index.ts index 48f6dc4260989..680a3697ef0bd 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/index.ts @@ -4,91 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IEsSearchResponse } from '../../../../../../../src/plugins/data/common'; - -import { CursorType, Inspect, Maybe, PageInfoPaginated, RequestOptionsPaginated } from '..'; +export * from './tls'; export enum NetworkQueries { tls = 'tls', } - -export interface TlsBuckets { - key: string; - timestamp?: { - value: number; - value_as_string: string; - }; - - subjects: { - buckets: Readonly>; - }; - - ja3: { - buckets: Readonly>; - }; - - issuers: { - buckets: Readonly>; - }; - - not_after: { - buckets: Readonly>; - }; -} - -export interface TlsNode { - _id?: Maybe; - - timestamp?: Maybe; - - notAfter?: Maybe; - - subjects?: Maybe; - - ja3?: Maybe; - - issuers?: Maybe; -} - -export enum FlowTargetSourceDest { - destination = 'destination', - source = 'source', -} - -export enum TlsFields { - _id = '_id', -} - -export interface TlsEdges { - node: TlsNode; - - cursor: CursorType; -} - -export enum Direction { - asc = 'asc', - desc = 'desc', -} - -export interface TlsSortField { - field: TlsFields; - - direction: Direction; -} - -export interface NetworkTlsRequestOptions extends RequestOptionsPaginated { - ip: string; - flowTarget: FlowTargetSourceDest; - sort: TlsSortField; - defaultIndex: string[]; -} - -export interface NetworkTlsStrategyResponse extends IEsSearchResponse { - edges: TlsEdges[]; - - totalCount: number; - - pageInfo: PageInfoPaginated; - - inspect?: Maybe; -} diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls.ts new file mode 100644 index 0000000000000..bdd2ae84cc7ea --- /dev/null +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls.ts @@ -0,0 +1,75 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { IEsSearchResponse } from '../../../../../../../src/plugins/data/common'; +import { CursorType, Inspect, Maybe, PageInfoPaginated, RequestOptionsPaginated } from '..'; + +export interface TlsBuckets { + key: string; + timestamp?: { + value: number; + value_as_string: string; + }; + subjects: { + buckets: Readonly>; + }; + ja3: { + buckets: Readonly>; + }; + issuers: { + buckets: Readonly>; + }; + not_after: { + buckets: Readonly>; + }; +} + +export interface TlsNode { + _id?: Maybe; + timestamp?: Maybe; + notAfter?: Maybe; + subjects?: Maybe; + ja3?: Maybe; + issuers?: Maybe; +} + +export enum FlowTargetSourceDest { + destination = 'destination', + source = 'source', +} + +export enum TlsFields { + _id = '_id', +} + +export interface TlsEdges { + node: TlsNode; + cursor: CursorType; +} + +export enum Direction { + asc = 'asc', + desc = 'desc', +} + +export interface TlsSortField { + field: TlsFields; + direction: Direction; +} + +export interface NetworkTlsRequestOptions extends RequestOptionsPaginated { + ip: string; + flowTarget: FlowTargetSourceDest; + sort: TlsSortField; + defaultIndex: string[]; +} + +export interface NetworkTlsStrategyResponse extends IEsSearchResponse { + edges: TlsEdges[]; + totalCount: number; + pageInfo: PageInfoPaginated; + inspect?: Maybe; +} diff --git a/x-pack/plugins/security_solution/public/network/containers/tls/index.tsx b/x-pack/plugins/security_solution/public/network/containers/tls/index.tsx index ee5d74a3c0eff..487ffcf62d428 100644 --- a/x-pack/plugins/security_solution/public/network/containers/tls/index.tsx +++ b/x-pack/plugins/security_solution/public/network/containers/tls/index.tsx @@ -59,8 +59,6 @@ export const useNetworkTls = ({ startDate, type, }: UseNetworkTls): [boolean, NetworkTlsArgs] => { - // const getQuery = inputsSelectors.globalQueryByIdSelector(); - // const { isInspected } = useSelector((state: State) => getQuery(state, id), shallowEqual); const getTlsSelector = networkSelectors.tlsSelector(); const { activePage, limit, sort } = useSelector( (state: State) => getTlsSelector(state, type, flowTarget), @@ -77,7 +75,6 @@ export const useNetworkTls = ({ factoryQueryType: NetworkQueries.tls, filterQuery: createFilter(filterQuery), flowTarget, - // inspect: isInspected, ip, pagination: generateTablePaginationOptions(activePage, limit), sort, @@ -90,12 +87,10 @@ export const useNetworkTls = ({ const wrappedLoadMore = useCallback( (newActivePage: number) => { - setHostRequest((prevRequest) => { - return { - ...prevRequest, - pagination: generateTablePaginationOptions(newActivePage, limit), - }; - }); + setHostRequest((prevRequest) => ({ + ...prevRequest, + pagination: generateTablePaginationOptions(newActivePage, limit), + })); }, [limit] ); diff --git a/x-pack/plugins/security_solution/public/network/pages/navigation/tls_query_tab_body.tsx b/x-pack/plugins/security_solution/public/network/pages/navigation/tls_query_tab_body.tsx index 1e49f9ca747c3..279891cc181e3 100644 --- a/x-pack/plugins/security_solution/public/network/pages/navigation/tls_query_tab_body.tsx +++ b/x-pack/plugins/security_solution/public/network/pages/navigation/tls_query_tab_body.tsx @@ -12,7 +12,7 @@ import { TlsQueryTabBodyProps } from './types'; const TlsTableManage = manageQuery(TlsTable); -export const TlsQueryTabBody = ({ +const TlsQueryTabBodyComponent: React.FC = ({ endDate, filterQuery, flowTarget, @@ -21,7 +21,7 @@ export const TlsQueryTabBody = ({ skip, startDate, type, -}: TlsQueryTabBodyProps) => { +}) => { const [ loading, { id, inspect, isInspected, tls, totalCount, pageInfo, loadPage, refetch }, @@ -52,3 +52,7 @@ export const TlsQueryTabBody = ({ /> ); }; + +TlsQueryTabBodyComponent.displayName = 'TlsQueryTabBodyComponent'; + +export const TlsQueryTabBody = React.memo(TlsQueryTabBodyComponent);