Skip to content

Commit

Permalink
[Security Solution] Cleanup graphql (#78403)
Browse files Browse the repository at this point in the history
* [Security Solution] Cleanup graphql

* cleanup

* cleanup

* fix types

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
patrykkopycinski and elasticmachine authored Sep 24, 2020
1 parent b8739c5 commit 179c7d9
Show file tree
Hide file tree
Showing 146 changed files with 8,597 additions and 32,113 deletions.
5 changes: 0 additions & 5 deletions x-pack/plugins/security_solution/common/ecs/network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@

export interface NetworkEcs {
bytes?: number[];

community_id?: string[];

direction?: string[];

packets?: number[];

protocol?: string[];

transport?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
import { GeoEcs } from '../../../../ecs/geo';
import { Maybe } from '../../..';

export enum NetworkDirectionEcs {
inbound = 'inbound',
outbound = 'outbound',
internal = 'internal',
external = 'external',
incoming = 'incoming',
outgoing = 'outgoing',
listening = 'listening',
unknown = 'unknown',
}

export enum NetworkTopTablesFields {
bytes_in = 'bytes_in',
bytes_out = 'bytes_out',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { set } from '@elastic/safer-lodash-set/fp';
import React from 'react';
import styled from 'styled-components';

import { DetailItem } from '../../../graphql/types';
import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';
import { omitTypenameAndEmpty } from '../../../timelines/components/timeline/body/helpers';

interface Props {
data: DetailItem[];
data: TimelineEventsDetailsItem[];
}

const JsonEditor = styled.div`
Expand All @@ -40,5 +40,5 @@ export const JsonView = React.memo<Props>(({ data }) => (

JsonView.displayName = 'JsonView';

export const buildJsonView = (data: DetailItem[]) =>
export const buildJsonView = (data: TimelineEventsDetailsItem[]) =>
data.reduce((accumulator, item) => set(item.field, item.originalValue, accumulator), {});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/

import { BrowserField } from '../../containers/source';
import { DetailItem } from '../../../graphql/types';
import { TimelineEventsDetailsItem } from '../../../../common/search_strategy';

export type EventFieldsData = BrowserField & DetailItem;
export type EventFieldsData = BrowserField & TimelineEventsDetailsItem;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';

import { getEmptyValue } from '../empty_value';
import { LastEventIndexKey } from '../../../graphql/types';
import { LastEventIndexKey } from '../../../../common/search_strategy';
import { mockLastEventTimeQuery } from '../../containers/events/last_event_time/mock';

import { useMountAppended } from '../../utils/use_mount_appended';
Expand Down Expand Up @@ -48,8 +48,8 @@ describe('Last Event Time Stat', () => {
(useTimelineLastEventTime as jest.Mock).mockReturnValue([
false,
{
lastSeen: mockLastEventTimeQuery[0].result.data!.source.LastEventTime.lastSeen,
errorMessage: mockLastEventTimeQuery[0].result.data!.source.LastEventTime.errorMessage,
lastSeen: mockLastEventTimeQuery.lastSeen,
errorMessage: mockLastEventTimeQuery.errorMessage,
},
]);
const wrapper = mount(
Expand All @@ -64,7 +64,7 @@ describe('Last Event Time Stat', () => {
false,
{
lastSeen: 'something-invalid',
errorMessage: mockLastEventTimeQuery[0].result.data!.source.LastEventTime.errorMessage,
errorMessage: mockLastEventTimeQuery.errorMessage,
},
]);
const wrapper = mount(
Expand All @@ -80,7 +80,7 @@ describe('Last Event Time Stat', () => {
false,
{
lastSeen: null,
errorMessage: mockLastEventTimeQuery[0].result.data!.source.LastEventTime.errorMessage,
errorMessage: mockLastEventTimeQuery.errorMessage,
},
]);
const wrapper = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { EuiIcon, EuiLoadingSpinner, EuiToolTip } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { memo } from 'react';

import { DocValueFields } from '../../../../common/search_strategy';
import { LastEventIndexKey } from '../../../graphql/types';
import { DocValueFields, LastEventIndexKey } from '../../../../common/search_strategy';
import { useTimelineLastEventTime } from '../../containers/events/last_event_time';
import { getEmptyTagValue } from '../empty_value';
import { FormattedRelativePreferenceDate } from '../formatted_date';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from './utils';
import { UpdateDateRange } from '../charts/common';
import { Position } from '@elastic/charts';
import { MatrixOverTimeHistogramData } from '../../../graphql/types';
import { MatrixHistogramData } from '../../../../common/search_strategy';
import { BarchartConfigs } from './types';

describe('utils', () => {
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('utils', () => {

describe('formatToChartDataItem', () => {
test('it should format data correctly', () => {
const data: [string, MatrixOverTimeHistogramData[]] = [
const data: [string, MatrixHistogramData[]] = [
'g1',
[
{ x: 1, y: 2, g: 'g1' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { get, groupBy, map, toPairs } from 'lodash/fp';

import { UpdateDateRange, ChartSeriesData } from '../charts/common';
import { MatrixHistogramMappingTypes, BarchartConfigs } from './types';
import { MatrixOverTimeHistogramData } from '../../../graphql/types';
import { MatrixHistogramData } from '../../../../common/search_strategy';
import { histogramDateTimeFormatter } from '../utils';

interface GetBarchartConfigsProps {
Expand Down Expand Up @@ -84,14 +84,14 @@ export const defaultLegendColors = [

export const formatToChartDataItem = ([key, value]: [
string,
MatrixOverTimeHistogramData[]
MatrixHistogramData[]
]): ChartSeriesData => ({
key,
value,
});

export const getCustomChartData = (
data: MatrixOverTimeHistogramData[] | null,
data: MatrixHistogramData[] | null,
mapping?: MatrixHistogramMappingTypes
): ChartSeriesData[] => {
if (!data) return [];
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { DEFAULT_INDEX_PATTERN } from '../../../../../common/constants';
import { GetLastEventTimeQuery, LastEventIndexKey } from '../../../../graphql/types';

import { LastEventTimeGqlQuery } from './last_event_time.gql_query';

interface MockLastEventTimeQuery {
request: {
query: GetLastEventTimeQuery.Query;
variables: GetLastEventTimeQuery.Variables;
};
result: {
data?: {
source: {
id: string;
LastEventTime: {
lastSeen: string | null;
errorMessage: string | null;
};
};
};
errors?: [{ message: string }];
};
lastSeen: string | null;
errorMessage: string | null;
}

const getTimeTwelveMinutesAgo = () => {
Expand All @@ -35,28 +16,7 @@ const getTimeTwelveMinutesAgo = () => {
return new Date(twelveMinutes).toISOString();
};

export const mockLastEventTimeQuery: MockLastEventTimeQuery[] = [
{
request: {
query: LastEventTimeGqlQuery,
variables: {
sourceId: 'default',
indexKey: LastEventIndexKey.hosts,
details: {},
defaultIndex: DEFAULT_INDEX_PATTERN,
docValueFields: [],
},
},
result: {
data: {
source: {
id: 'default',
LastEventTime: {
lastSeen: getTimeTwelveMinutesAgo(),
errorMessage: null,
},
},
},
},
},
];
export const mockLastEventTimeQuery: MockLastEventTimeQuery = {
lastSeen: getTimeTwelveMinutesAgo(),
errorMessage: null,
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { DetailItem } from '../../graphql/types';
import { TimelineEventsDetailsItem } from '../../../common/search_strategy';

export const mockDetailItemDataId = 'Y-6TfmcB0WOhS6qyMv3s';

export const mockDetailItemData: DetailItem[] = [
export const mockDetailItemData: TimelineEventsDetailsItem[] = [
{
field: '_id',
originalValue: 'pEMaMmkBUV60JmNWmWVi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ import { FilterStateStore } from '../../../../../../src/plugins/data/common/es_q
import { TimelineId, TimelineType, TimelineStatus } from '../../../common/types/timeline';

import { OpenTimelineResult } from '../../timelines/components/open_timeline/types';
import {
GetAllTimeline,
SortFieldTimeline,
TimelineResult,
Direction,
DetailItem,
} from '../../graphql/types';
import { GetAllTimeline, SortFieldTimeline, TimelineResult, Direction } from '../../graphql/types';
import { TimelineEventsDetailsItem } from '../../../common/search_strategy';
import { allTimelinesQuery } from '../../timelines/containers/all/index.gql_query';
import { CreateTimelineProps } from '../../detections/components/alerts_table/types';
import { TimelineModel } from '../../timelines/store/timeline/model';
Expand Down Expand Up @@ -2264,7 +2259,7 @@ export const defaultTimelineProps: CreateTimelineProps = {
ruleNote: '# this is some markdown documentation',
};

export const mockTimelineDetails: DetailItem[] = [
export const mockTimelineDetails: TimelineEventsDetailsItem[] = [
{
field: 'host.name',
values: ['apache'],
Expand Down
Loading

0 comments on commit 179c7d9

Please sign in to comment.