diff --git a/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_container.tsx b/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_container.tsx index 513713921d2e4..fd0cf9089092e 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_container.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_container.tsx @@ -21,13 +21,13 @@ import { useEsClientMutation, isNonNullable, } from './utils'; -import type { CSPFinding, FindingsFetchState } from './types'; +import type { CspFinding, FindingsFetchState } from './types'; import type { DataView, IKibanaSearchResponse } from '../../../../../../src/plugins/data/common'; import type { SearchBarProps } from '../../../../../../src/plugins/data/public'; import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; type FindingsEsSearchMutation = UseMutationResult< - IKibanaSearchResponse>, + IKibanaSearchResponse>, unknown, void >; @@ -66,9 +66,9 @@ export const getFetchState = (v: T): Finding */ export const FindingsTableContainer = ({ dataView }: { dataView: DataView }) => { const { notifications } = useKibana().services; - const [selectedFinding, setSelectedFinding] = useState(); + const [selectedFinding, setSelectedFinding] = useState(); const { source: searchState, setSource: setSearchSource } = useSourceQueryParam(getDefaultQuery); - const mutation = useEsClientMutation({ + const mutation = useEsClientMutation({ ...searchState, dataView, }); diff --git a/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_flyout.tsx b/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_flyout.tsx index 592fe6dac0ac8..5762675094f3c 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_flyout.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_flyout.tsx @@ -23,7 +23,7 @@ import { PropsOf, } from '@elastic/eui'; import { assertNever } from '@kbn/std'; -import type { CSPFinding } from './types'; +import type { CspFinding } from './types'; import { CSPEvaluationBadge } from '../../components/csp_evaluation_badge'; const tabs = ['result', 'rule', 'resource'] as const; @@ -39,7 +39,7 @@ interface Card { interface FindingFlyoutProps { onClose(): void; - findings: CSPFinding; + findings: CspFinding; } export const FindingsRuleFlyout = ({ onClose, findings }: FindingFlyoutProps) => { @@ -89,7 +89,7 @@ const Cards = ({ data }: { data: Card[] }) => ( ); -const FindingsTab = ({ tab, findings }: { findings: CSPFinding; tab: FindingsTab }) => { +const FindingsTab = ({ tab, findings }: { findings: CspFinding; tab: FindingsTab }) => { switch (tab) { case 'result': return ; @@ -102,7 +102,7 @@ const FindingsTab = ({ tab, findings }: { findings: CSPFinding; tab: FindingsTab } }; -const getResourceCards = ({ resource }: CSPFinding): Card[] => [ +const getResourceCards = ({ resource }: CspFinding): Card[] => [ { title: 'Resource', listItems: [ @@ -116,7 +116,7 @@ const getResourceCards = ({ resource }: CSPFinding): Card[] => [ }, ]; -const getRuleCards = ({ rule }: CSPFinding): Card[] => [ +const getRuleCards = ({ rule }: CspFinding): Card[] => [ { title: 'Rule', listItems: [ @@ -136,7 +136,7 @@ const getRuleCards = ({ rule }: CSPFinding): Card[] => [ }, ]; -const getResultCards = ({ result, agent, host, ...rest }: CSPFinding): Card[] => [ +const getResultCards = ({ result, agent, host, ...rest }: CspFinding): Card[] => [ { title: 'Result', listItems: [ diff --git a/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_table.tsx index 6c979e1e75d5c..9ba37dc2ca54c 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/findings/findings_table.tsx @@ -19,11 +19,11 @@ import { } from '@elastic/eui'; import { orderBy } from 'lodash'; import { TEST_SUBJECTS } from './constants'; -import type { CSPFinding, FindingsFetchState } from './types'; +import type { CspFinding, FindingsFetchState } from './types'; import { CSPEvaluationBadge } from '../../components/csp_evaluation_badge'; interface BaseFindingsTableProps { - selectItem(v: CSPFinding | undefined): void; + selectItem(v: CspFinding | undefined): void; } type FindingsTableProps = FindingsFetchState & BaseFindingsTableProps; @@ -32,11 +32,11 @@ export const FindingsTable = ({ data, status, error, selectItem }: FindingsTable const [pageIndex, setPageIndex] = useState(0); const [pageSize, setPageSize] = useState(25); - const getCellProps = (item: CSPFinding, column: EuiTableFieldDataColumnType) => ({ + const getCellProps = (item: CspFinding, column: EuiTableFieldDataColumnType) => ({ onClick: column.field === 'rule.name' ? () => selectItem(item) : undefined, }); - const onTableChange = ({ page }: Criteria) => { + const onTableChange = ({ page }: Criteria) => { if (!page) return; const { index, size } = page; @@ -57,7 +57,7 @@ export const FindingsTable = ({ data, status, error, selectItem }: FindingsTable if (!data) return null; // TODO: async pagination - const pagination: EuiBasicTableProps['pagination'] = { + const pagination: EuiBasicTableProps['pagination'] = { pageIndex, pageSize, totalItemCount: data.length, @@ -98,7 +98,7 @@ const resultEvaluationRenderer = (type: PropsOf['type ); -const columns: Array> = [ +const columns: Array> = [ { field: 'resource.filename', name: 'Resource', diff --git a/x-pack/plugins/cloud_security_posture/public/pages/findings/types.ts b/x-pack/plugins/cloud_security_posture/public/pages/findings/types.ts index afea03d6ccb6c..f73767f9875f9 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/findings/types.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/findings/types.ts @@ -7,23 +7,22 @@ import type { MutationFetchState } from '../../common/types'; -export type FindingsFetchState = MutationFetchState; +export type FindingsFetchState = MutationFetchState; -export interface CSPFinding { +export interface CspFinding { '@timestamp': string; run_id: string; - result: CSPFindingResult; - resource: CSPFindingResource; - rule: CSPRule; - host: CSPFindingHost; - agent: CSPFindingAgent; + result: CspFindingResult; + resource: CspFindingResource; + rule: CspRule; + host: CspFindingHost; + agent: CspFindingAgent; ecs: { version: string; }; } -// TODO: rename -interface CSPRule { +interface CspRule { benchmark: string; description: string; impact: string; @@ -32,16 +31,14 @@ interface CSPRule { tags: string[]; } -// TODO: rename -interface CSPFindingResult { +interface CspFindingResult { evaluation: 'passed' | 'failed'; evidence: { filemode: string; }; } -// TODO: rename -interface CSPFindingResource { +interface CspFindingResource { uid: string; filename: string; gid: string; @@ -50,8 +47,7 @@ interface CSPFindingResource { type: string; } -// TODO: rename -interface CSPFindingHost { +interface CspFindingHost { id: string; containerized: boolean; ip: string[]; @@ -70,8 +66,7 @@ interface CSPFindingHost { }; } -// TODO: rename -interface CSPFindingAgent { +interface CspFindingAgent { version: string; ephemeral_id: string; id: string;