Skip to content

Commit

Permalink
[Security Solution] Refactor timeline details to use search strategy (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Sep 3, 2020
1 parent ec95a24 commit 3477fc9
Show file tree
Hide file tree
Showing 42 changed files with 702 additions and 326 deletions.
24 changes: 0 additions & 24 deletions x-pack/plugins/security_solution/common/ecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,28 @@ import { SystemEcs } from './system';

export interface Ecs {
_id: string;

_index?: string;

auditd?: AuditdEcs;

destination?: DestinationEcs;

dns?: DnsEcs;

endgame?: EndgameEcs;

event?: EventEcs;

geo?: GeoEcs;

host?: HostEcs;

network?: NetworkEcs;

rule?: RuleEcs;

signal?: SignalEcs;

source?: SourceEcs;

suricata?: SuricataEcs;

tls?: TlsEcs;

zeek?: ZeekEcs;

http?: HttpEcs;

url?: UrlEcs;

timestamp?: string;

message?: string[];

user?: UserEcs;

winlog?: WinlogEcs;

process?: ProcessEcs;

file?: File;

system?: SystemEcs;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* 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';

export type Maybe<T> = T | null;

export type SearchHit = IEsSearchResponse<object>['rawResponse']['hits']['hits'][0];

export interface TotalValue {
value: number;
relation: string;
}

export interface Inspect {
dsl: string[];
}

export interface PageInfoPaginated {
activePage: number;
fakeTotalCount: number;
showMorePagesIndicator: boolean;
}

export interface CursorType {
value?: Maybe<string>;
tiebreaker?: Maybe<string>;
}

export enum Direction {
asc = 'asc',
desc = 'desc',
}

export interface SortField<Field = string> {
field: Field;
direction: Direction;
}

export interface TimerangeInput {
/** The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan. */
interval: string;
/** The end of the timerange */
to: string;
/** The beginning of the timerange */
from: string;
}

export interface PaginationInput {
/** The limit parameter allows you to configure the maximum amount of items to be returned */
limit: number;
/** The cursor parameter defines the next result you want to fetch */
cursor?: Maybe<string>;
/** The tiebreaker parameter allow to be more precise to fetch the next item */
tiebreaker?: Maybe<string>;
}

export interface PaginationInputPaginated {
/** The activePage parameter defines the page of results you want to fetch */
activePage: number;
/** The cursorStart parameter defines the start of the results to be displayed */
cursorStart: number;
/** The fakePossibleCount parameter determines the total count in order to show 5 additional pages */
fakePossibleCount: number;
/** The querySize parameter is the number of items to be returned */
querySize: number;
}

export interface DocValueFields {
field: string;
format: string;
}

export interface Explanation {
value: number;
description: string;
details: Explanation[];
}

export interface TotalValue {
value: number;
relation: string;
}
export interface ShardsResponse {
total: number;
successful: number;
failed: number;
skipped: number;
}

export interface TotalHit {
value: number;
relation: string;
}

export interface Hit {
_index: string;
_type: string;
_id: string;
_score: number | null;
}

export interface Hits<T, U> {
hits: {
total: T;
max_score: number | null;
hits: U[];
};
}

export interface GenericBuckets {
key: string;
doc_count: number;
}

export type StringOrNumber = string | number;
Original file line number Diff line number Diff line change
@@ -0,0 +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;
* you may not use this file except in compliance with the Elastic License.
*/

export * from './common';
export * from './security_solution';
export * from './timeline';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common';

import { HostItem, HostsFields } from '../common';
import { CursorType, Inspect, Maybe, PageInfoPaginated, RequestOptionsPaginated } from '../..';
import { CursorType, Inspect, Maybe, PageInfoPaginated } from '../../../common';
import { RequestOptionsPaginated } from '../..';

export interface HostsEdges {
node: HostItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
Inspect,
Maybe,
PageInfoPaginated,
RequestOptionsPaginated,
StringOrNumber,
Hit,
TotalHit,
} from '../../';
} from '../../../common';
import { RequestOptionsPaginated } from '../../';

export interface AuthenticationsStrategyResponse extends IEsSearchResponse {
edges: AuthenticationsEdges[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { CloudEcs } from '../../../../ecs/cloud';
import { HostEcs, OsEcs } from '../../../../ecs/host';
import { Maybe, SearchHit, TotalValue } from '../..';
import { Maybe, SearchHit, TotalValue } from '../../../common';

export enum HostPolicyResponseActionStatus {
success = 'success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common';
import { Inspect, Maybe, RequestOptionsPaginated } from '../..';
import { Inspect, Maybe } from '../../../common';
import { RequestOptionsPaginated } from '../..';
import { HostsFields } from '../common';

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

export * from './authentications';
export * from './all';
export * from './common';
export * from './overview';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common';

import { Inspect, Maybe, TimerangeInput } from '../../../common';
import { HostItem, HostsFields } from '../common';
import { Inspect, Maybe, RequestOptionsPaginated, TimerangeInput } from '../..';
import { RequestOptionsPaginated } from '../..';

export interface HostOverviewStrategyResponse extends IEsSearchResponse {
hostOverview: HostItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { IEsSearchRequest, IEsSearchResponse } from '../../../../../../src/plugins/data/common';
import { IEsSearchRequest } from '../../../../../../src/plugins/data/common';
import { ESQuery } from '../../typed_json';
import {
HostOverviewStrategyResponse,
Expand All @@ -28,116 +28,19 @@ import {
NetworkTopCountriesStrategyResponse,
NetworkTopCountriesRequestOptions,
} from './network';
import {
DocValueFields,
TimerangeInput,
SortField,
PaginationInput,
PaginationInputPaginated,
} from '../common';

export * from './hosts';
export * from './network';
export type Maybe<T> = T | null;

export type FactoryQueryTypes = HostsQueries | NetworkQueries;

export type SearchHit = IEsSearchResponse<object>['rawResponse']['hits']['hits'][0];

export interface TotalValue {
value: number;
relation: string;
}

export interface Inspect {
dsl: string[];
}

export interface PageInfoPaginated {
activePage: number;
fakeTotalCount: number;
showMorePagesIndicator: boolean;
}

export interface CursorType {
value?: Maybe<string>;
tiebreaker?: Maybe<string>;
}

export enum Direction {
asc = 'asc',
desc = 'desc',
}

export interface SortField<Field = string> {
field: Field;
direction: Direction;
}

export interface TimerangeInput {
/** The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan. */
interval: string;
/** The end of the timerange */
to: string;
/** The beginning of the timerange */
from: string;
}

export interface PaginationInput {
/** The limit parameter allows you to configure the maximum amount of items to be returned */
limit: number;
/** The cursor parameter defines the next result you want to fetch */
cursor?: Maybe<string>;
/** The tiebreaker parameter allow to be more precise to fetch the next item */
tiebreaker?: Maybe<string>;
}

export interface PaginationInputPaginated {
/** The activePage parameter defines the page of results you want to fetch */
activePage: number;
/** The cursorStart parameter defines the start of the results to be displayed */
cursorStart: number;
/** The fakePossibleCount parameter determines the total count in order to show 5 additional pages */
fakePossibleCount: number;
/** The querySize parameter is the number of items to be returned */
querySize: number;
}

export interface DocValueFields {
field: string;
format: string;
}

export interface Explanation {
value: number;
description: string;
details: Explanation[];
}

export interface TotalValue {
value: number;
relation: string;
}
export interface ShardsResponse {
total: number;
successful: number;
failed: number;
skipped: number;
}

export interface TotalHit {
value: number;
relation: string;
}

export interface Hit {
_index: string;
_type: string;
_id: string;
_score: number | null;
}

export interface Hits<T, U> {
hits: {
total: T;
max_score: number | null;
hits: U[];
};
}

export interface RequestBasicOptions extends IEsSearchRequest {
timerange: TimerangeInput;
filterQuery: ESQuery | string | undefined;
Expand Down Expand Up @@ -189,10 +92,3 @@ export type StrategyRequestType<T extends FactoryQueryTypes> = T extends HostsQu
: T extends NetworkQueries.topCountries
? NetworkTopCountriesRequestOptions
: never;

export type StringOrNumber = string | number;

export interface GenericBuckets {
key: string;
doc_count: number;
}
Loading

0 comments on commit 3477fc9

Please sign in to comment.