Skip to content

Commit cfcd10c

Browse files
[Security Solution] Refactor timeline details to use search strategy (#75591)
1 parent 53c7414 commit cfcd10c

42 files changed

Lines changed: 702 additions & 326 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

x-pack/plugins/security_solution/common/ecs/index.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,28 @@ import { SystemEcs } from './system';
2727

2828
export interface Ecs {
2929
_id: string;
30-
3130
_index?: string;
32-
3331
auditd?: AuditdEcs;
34-
3532
destination?: DestinationEcs;
36-
3733
dns?: DnsEcs;
38-
3934
endgame?: EndgameEcs;
40-
4135
event?: EventEcs;
42-
4336
geo?: GeoEcs;
44-
4537
host?: HostEcs;
46-
4738
network?: NetworkEcs;
48-
4939
rule?: RuleEcs;
50-
5140
signal?: SignalEcs;
52-
5341
source?: SourceEcs;
54-
5542
suricata?: SuricataEcs;
56-
5743
tls?: TlsEcs;
58-
5944
zeek?: ZeekEcs;
60-
6145
http?: HttpEcs;
62-
6346
url?: UrlEcs;
64-
6547
timestamp?: string;
66-
6748
message?: string[];
68-
6949
user?: UserEcs;
70-
7150
winlog?: WinlogEcs;
72-
7351
process?: ProcessEcs;
74-
7552
file?: File;
76-
7753
system?: SystemEcs;
7854
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { IEsSearchResponse } from '../../../../../../src/plugins/data/common';
8+
9+
export type Maybe<T> = T | null;
10+
11+
export type SearchHit = IEsSearchResponse<object>['rawResponse']['hits']['hits'][0];
12+
13+
export interface TotalValue {
14+
value: number;
15+
relation: string;
16+
}
17+
18+
export interface Inspect {
19+
dsl: string[];
20+
}
21+
22+
export interface PageInfoPaginated {
23+
activePage: number;
24+
fakeTotalCount: number;
25+
showMorePagesIndicator: boolean;
26+
}
27+
28+
export interface CursorType {
29+
value?: Maybe<string>;
30+
tiebreaker?: Maybe<string>;
31+
}
32+
33+
export enum Direction {
34+
asc = 'asc',
35+
desc = 'desc',
36+
}
37+
38+
export interface SortField<Field = string> {
39+
field: Field;
40+
direction: Direction;
41+
}
42+
43+
export interface TimerangeInput {
44+
/** 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. */
45+
interval: string;
46+
/** The end of the timerange */
47+
to: string;
48+
/** The beginning of the timerange */
49+
from: string;
50+
}
51+
52+
export interface PaginationInput {
53+
/** The limit parameter allows you to configure the maximum amount of items to be returned */
54+
limit: number;
55+
/** The cursor parameter defines the next result you want to fetch */
56+
cursor?: Maybe<string>;
57+
/** The tiebreaker parameter allow to be more precise to fetch the next item */
58+
tiebreaker?: Maybe<string>;
59+
}
60+
61+
export interface PaginationInputPaginated {
62+
/** The activePage parameter defines the page of results you want to fetch */
63+
activePage: number;
64+
/** The cursorStart parameter defines the start of the results to be displayed */
65+
cursorStart: number;
66+
/** The fakePossibleCount parameter determines the total count in order to show 5 additional pages */
67+
fakePossibleCount: number;
68+
/** The querySize parameter is the number of items to be returned */
69+
querySize: number;
70+
}
71+
72+
export interface DocValueFields {
73+
field: string;
74+
format: string;
75+
}
76+
77+
export interface Explanation {
78+
value: number;
79+
description: string;
80+
details: Explanation[];
81+
}
82+
83+
export interface TotalValue {
84+
value: number;
85+
relation: string;
86+
}
87+
export interface ShardsResponse {
88+
total: number;
89+
successful: number;
90+
failed: number;
91+
skipped: number;
92+
}
93+
94+
export interface TotalHit {
95+
value: number;
96+
relation: string;
97+
}
98+
99+
export interface Hit {
100+
_index: string;
101+
_type: string;
102+
_id: string;
103+
_score: number | null;
104+
}
105+
106+
export interface Hits<T, U> {
107+
hits: {
108+
total: T;
109+
max_score: number | null;
110+
hits: U[];
111+
};
112+
}
113+
114+
export interface GenericBuckets {
115+
key: string;
116+
doc_count: number;
117+
}
118+
119+
export type StringOrNumber = string | number;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export * from './common';
8+
export * from './security_solution';
9+
export * from './timeline';

x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/all/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common';
88

99
import { HostItem, HostsFields } from '../common';
10-
import { CursorType, Inspect, Maybe, PageInfoPaginated, RequestOptionsPaginated } from '../..';
10+
import { CursorType, Inspect, Maybe, PageInfoPaginated } from '../../../common';
11+
import { RequestOptionsPaginated } from '../..';
1112

1213
export interface HostsEdges {
1314
node: HostItem;

x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/authentications/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import {
1313
Inspect,
1414
Maybe,
1515
PageInfoPaginated,
16-
RequestOptionsPaginated,
1716
StringOrNumber,
1817
Hit,
1918
TotalHit,
20-
} from '../../';
19+
} from '../../../common';
20+
import { RequestOptionsPaginated } from '../../';
2121

2222
export interface AuthenticationsStrategyResponse extends IEsSearchResponse {
2323
edges: AuthenticationsEdges[];

x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/common/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { CloudEcs } from '../../../../ecs/cloud';
88
import { HostEcs, OsEcs } from '../../../../ecs/host';
9-
import { Maybe, SearchHit, TotalValue } from '../..';
9+
import { Maybe, SearchHit, TotalValue } from '../../../common';
1010

1111
export enum HostPolicyResponseActionStatus {
1212
success = 'success',

x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/first_last_seen/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common';
8-
import { Inspect, Maybe, RequestOptionsPaginated } from '../..';
8+
import { Inspect, Maybe } from '../../../common';
9+
import { RequestOptionsPaginated } from '../..';
910
import { HostsFields } from '../common';
1011

1112
export interface HostFirstLastSeenRequestOptions

x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
export * from './authentications';
78
export * from './all';
89
export * from './common';
910
export * from './overview';

x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/overview/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66

77
import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common';
8-
8+
import { Inspect, Maybe, TimerangeInput } from '../../../common';
99
import { HostItem, HostsFields } from '../common';
10-
import { Inspect, Maybe, RequestOptionsPaginated, TimerangeInput } from '../..';
10+
import { RequestOptionsPaginated } from '../..';
1111

1212
export interface HostOverviewStrategyResponse extends IEsSearchResponse {
1313
hostOverview: HostItem;

x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts

Lines changed: 8 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { IEsSearchRequest, IEsSearchResponse } from '../../../../../../src/plugins/data/common';
7+
import { IEsSearchRequest } from '../../../../../../src/plugins/data/common';
88
import { ESQuery } from '../../typed_json';
99
import {
1010
HostOverviewStrategyResponse,
@@ -28,116 +28,19 @@ import {
2828
NetworkTopCountriesStrategyResponse,
2929
NetworkTopCountriesRequestOptions,
3030
} from './network';
31+
import {
32+
DocValueFields,
33+
TimerangeInput,
34+
SortField,
35+
PaginationInput,
36+
PaginationInputPaginated,
37+
} from '../common';
3138

3239
export * from './hosts';
3340
export * from './network';
34-
export type Maybe<T> = T | null;
3541

3642
export type FactoryQueryTypes = HostsQueries | NetworkQueries;
3743

38-
export type SearchHit = IEsSearchResponse<object>['rawResponse']['hits']['hits'][0];
39-
40-
export interface TotalValue {
41-
value: number;
42-
relation: string;
43-
}
44-
45-
export interface Inspect {
46-
dsl: string[];
47-
}
48-
49-
export interface PageInfoPaginated {
50-
activePage: number;
51-
fakeTotalCount: number;
52-
showMorePagesIndicator: boolean;
53-
}
54-
55-
export interface CursorType {
56-
value?: Maybe<string>;
57-
tiebreaker?: Maybe<string>;
58-
}
59-
60-
export enum Direction {
61-
asc = 'asc',
62-
desc = 'desc',
63-
}
64-
65-
export interface SortField<Field = string> {
66-
field: Field;
67-
direction: Direction;
68-
}
69-
70-
export interface TimerangeInput {
71-
/** 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. */
72-
interval: string;
73-
/** The end of the timerange */
74-
to: string;
75-
/** The beginning of the timerange */
76-
from: string;
77-
}
78-
79-
export interface PaginationInput {
80-
/** The limit parameter allows you to configure the maximum amount of items to be returned */
81-
limit: number;
82-
/** The cursor parameter defines the next result you want to fetch */
83-
cursor?: Maybe<string>;
84-
/** The tiebreaker parameter allow to be more precise to fetch the next item */
85-
tiebreaker?: Maybe<string>;
86-
}
87-
88-
export interface PaginationInputPaginated {
89-
/** The activePage parameter defines the page of results you want to fetch */
90-
activePage: number;
91-
/** The cursorStart parameter defines the start of the results to be displayed */
92-
cursorStart: number;
93-
/** The fakePossibleCount parameter determines the total count in order to show 5 additional pages */
94-
fakePossibleCount: number;
95-
/** The querySize parameter is the number of items to be returned */
96-
querySize: number;
97-
}
98-
99-
export interface DocValueFields {
100-
field: string;
101-
format: string;
102-
}
103-
104-
export interface Explanation {
105-
value: number;
106-
description: string;
107-
details: Explanation[];
108-
}
109-
110-
export interface TotalValue {
111-
value: number;
112-
relation: string;
113-
}
114-
export interface ShardsResponse {
115-
total: number;
116-
successful: number;
117-
failed: number;
118-
skipped: number;
119-
}
120-
121-
export interface TotalHit {
122-
value: number;
123-
relation: string;
124-
}
125-
126-
export interface Hit {
127-
_index: string;
128-
_type: string;
129-
_id: string;
130-
_score: number | null;
131-
}
132-
133-
export interface Hits<T, U> {
134-
hits: {
135-
total: T;
136-
max_score: number | null;
137-
hits: U[];
138-
};
139-
}
140-
14144
export interface RequestBasicOptions extends IEsSearchRequest {
14245
timerange: TimerangeInput;
14346
filterQuery: ESQuery | string | undefined;
@@ -189,10 +92,3 @@ export type StrategyRequestType<T extends FactoryQueryTypes> = T extends HostsQu
18992
: T extends NetworkQueries.topCountries
19093
? NetworkTopCountriesRequestOptions
19194
: never;
192-
193-
export type StringOrNumber = string | number;
194-
195-
export interface GenericBuckets {
196-
key: string;
197-
doc_count: number;
198-
}

0 commit comments

Comments
 (0)