Skip to content

Commit

Permalink
rename CSP to Csp (elastic#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
orouz committed Jan 13, 2022
1 parent 35790b1 commit 51cb8ef
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SearchResponse<CSPFinding>>,
IKibanaSearchResponse<SearchResponse<CspFinding>>,
unknown,
void
>;
Expand Down Expand Up @@ -66,9 +66,9 @@ export const getFetchState = <T extends FindingsEsSearchMutation>(v: T): Finding
*/
export const FindingsTableContainer = ({ dataView }: { dataView: DataView }) => {
const { notifications } = useKibana().services;
const [selectedFinding, setSelectedFinding] = useState<CSPFinding | undefined>();
const [selectedFinding, setSelectedFinding] = useState<CspFinding | undefined>();
const { source: searchState, setSource: setSearchSource } = useSourceQueryParam(getDefaultQuery);
const mutation = useEsClientMutation<CSPFinding>({
const mutation = useEsClientMutation<CspFinding>({
...searchState,
dataView,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,7 +39,7 @@ interface Card {

interface FindingFlyoutProps {
onClose(): void;
findings: CSPFinding;
findings: CspFinding;
}

export const FindingsRuleFlyout = ({ onClose, findings }: FindingFlyoutProps) => {
Expand Down Expand Up @@ -89,7 +89,7 @@ const Cards = ({ data }: { data: Card[] }) => (
</EuiFlexGrid>
);

const FindingsTab = ({ tab, findings }: { findings: CSPFinding; tab: FindingsTab }) => {
const FindingsTab = ({ tab, findings }: { findings: CspFinding; tab: FindingsTab }) => {
switch (tab) {
case 'result':
return <Cards data={getResultCards(findings)} />;
Expand All @@ -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: [
Expand All @@ -116,7 +116,7 @@ const getResourceCards = ({ resource }: CSPFinding): Card[] => [
},
];

const getRuleCards = ({ rule }: CSPFinding): Card[] => [
const getRuleCards = ({ rule }: CspFinding): Card[] => [
{
title: 'Rule',
listItems: [
Expand All @@ -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: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<CSPFinding>) => ({
const getCellProps = (item: CspFinding, column: EuiTableFieldDataColumnType<CspFinding>) => ({
onClick: column.field === 'rule.name' ? () => selectItem(item) : undefined,
});

const onTableChange = ({ page }: Criteria<CSPFinding>) => {
const onTableChange = ({ page }: Criteria<CspFinding>) => {
if (!page) return;
const { index, size } = page;

Expand All @@ -57,7 +57,7 @@ export const FindingsTable = ({ data, status, error, selectItem }: FindingsTable
if (!data) return null;

// TODO: async pagination
const pagination: EuiBasicTableProps<CSPFinding>['pagination'] = {
const pagination: EuiBasicTableProps<CspFinding>['pagination'] = {
pageIndex,
pageSize,
totalItemCount: data.length,
Expand Down Expand Up @@ -98,7 +98,7 @@ const resultEvaluationRenderer = (type: PropsOf<typeof CSPEvaluationBadge>['type
<CSPEvaluationBadge type={type} />
);

const columns: Array<EuiTableFieldDataColumnType<CSPFinding>> = [
const columns: Array<EuiTableFieldDataColumnType<CspFinding>> = [
{
field: 'resource.filename',
name: 'Resource',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@

import type { MutationFetchState } from '../../common/types';

export type FindingsFetchState = MutationFetchState<CSPFinding[], string>;
export type FindingsFetchState = MutationFetchState<CspFinding[], string>;

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;
Expand All @@ -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;
Expand All @@ -50,8 +47,7 @@ interface CSPFindingResource {
type: string;
}

// TODO: rename
interface CSPFindingHost {
interface CspFindingHost {
id: string;
containerized: boolean;
ip: string[];
Expand All @@ -70,8 +66,7 @@ interface CSPFindingHost {
};
}

// TODO: rename
interface CSPFindingAgent {
interface CspFindingAgent {
version: string;
ephemeral_id: string;
id: string;
Expand Down

0 comments on commit 51cb8ef

Please sign in to comment.