Skip to content

Commit ade2b57

Browse files
angoraycpatrykkopycinskiXavierM
authored
[SIEM] Import timeline fix (#65448) (#70145)
* fix import timeline and clean up fix unit tests apply failure checker clean up error message fix update template * add unit tests * clean up common libs * rename variables * add unit tests * fix types * Fix imports * rename file * poc * fix unit test * review * cleanup fallback values * cleanup * check if title exists * fix unit test * add unit test * lint error * put the flag for disableTemplate into common * add immutiable * fix unit * check templateTimelineVersion only when update via import * update template timeline via import with response * add template filter * add filter count * add filter numbers * rename * enable pin events and note under active status * disable comment and pinnedEvents for template timelines * add timelineType for openTimeline * enable note icon for template * add timeline type for propertyLeft * fix types * duplicate elastic template * update schema * fix status check * fix import * add templateTimelineType * disable note for immutable timeline * fix unit * fix error message * fix update * fix types * rollback change * rollback change * fix create template timeline * add i18n for error message * fix unit test * fix wording and disable delete btn for immutable timeline * fix unit test provider * fix types * fix toaster * fix notes and pins * add i18n * fix selected items * set disableTemplateto true * move templateInfo to helper * review + imporvement * fix review * fix types * fix types Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com> Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com> # Conflicts: # x-pack/plugins/security_solution/public/timelines/store/timeline/epic.ts
1 parent abb659c commit ade2b57

File tree

126 files changed

+4541
-1366
lines changed

Some content is hidden

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

126 files changed

+4541
-1366
lines changed

x-pack/plugins/security_solution/common/constants.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ export const showAllOthersBucket: string[] = [
158158

159159
/**
160160
* CreateTemplateTimelineBtn
161+
* https://github.com/elastic/kibana/pull/66613
161162
* Remove the comment here to enable template timeline
162163
*/
163-
export const disableTemplate = true;
164+
export const disableTemplate = false;
165+
166+
/*
167+
* This should be set to true after https://github.com/elastic/kibana/pull/67496 is merged
168+
*/
169+
export const enableElasticFilter = false;

x-pack/plugins/security_solution/common/types/timeline/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@ const SavedSortRuntimeType = runtimeTypes.partial({
137137
export enum TimelineStatus {
138138
active = 'active',
139139
draft = 'draft',
140+
immutable = 'immutable',
140141
}
141142

142143
export const TimelineStatusLiteralRt = runtimeTypes.union([
143144
runtimeTypes.literal(TimelineStatus.active),
144145
runtimeTypes.literal(TimelineStatus.draft),
146+
runtimeTypes.literal(TimelineStatus.immutable),
145147
]);
146148

147149
const TimelineStatusLiteralWithNullRt = unionWithNullType(TimelineStatusLiteralRt);
@@ -151,6 +153,29 @@ export type TimelineStatusLiteralWithNull = runtimeTypes.TypeOf<
151153
typeof TimelineStatusLiteralWithNullRt
152154
>;
153155

156+
/**
157+
* Template timeline type
158+
*/
159+
160+
export enum TemplateTimelineType {
161+
elastic = 'elastic',
162+
custom = 'custom',
163+
}
164+
165+
export const TemplateTimelineTypeLiteralRt = runtimeTypes.union([
166+
runtimeTypes.literal(TemplateTimelineType.elastic),
167+
runtimeTypes.literal(TemplateTimelineType.custom),
168+
]);
169+
170+
export const TemplateTimelineTypeLiteralWithNullRt = unionWithNullType(
171+
TemplateTimelineTypeLiteralRt
172+
);
173+
174+
export type TemplateTimelineTypeLiteral = runtimeTypes.TypeOf<typeof TemplateTimelineTypeLiteralRt>;
175+
export type TemplateTimelineTypeLiteralWithNull = runtimeTypes.TypeOf<
176+
typeof TemplateTimelineTypeLiteralWithNullRt
177+
>;
178+
154179
/*
155180
* Timeline Types
156181
*/
@@ -273,6 +298,13 @@ export const TimelineResponseType = runtimeTypes.type({
273298
}),
274299
});
275300

301+
export const TimelineErrorResponseType = runtimeTypes.type({
302+
status_code: runtimeTypes.number,
303+
message: runtimeTypes.string,
304+
});
305+
306+
export interface TimelineErrorResponse
307+
extends runtimeTypes.TypeOf<typeof TimelineErrorResponseType> {}
276308
export interface TimelineResponse extends runtimeTypes.TypeOf<typeof TimelineResponseType> {}
277309

278310
/**

x-pack/plugins/security_solution/public/alerts/components/alerts_table/actions.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ describe('alert actions', () => {
215215
columnId: '@timestamp',
216216
sortDirection: 'desc',
217217
},
218-
status: TimelineStatus.draft,
219-
title: '',
218+
status: TimelineStatus.active,
219+
title: 'Test rule - Duplicate',
220220
timelineType: TimelineType.default,
221221
templateTimelineId: null,
222222
templateTimelineVersion: null,

x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/index.test.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
mockGlobalState,
1313
TestProviders,
1414
SUB_PLUGINS_REDUCER,
15+
kibanaObservable,
1516
createSecuritySolutionStorageMock,
1617
} from '../../mock';
1718
import { createStore, State } from '../../store';
@@ -35,10 +36,22 @@ jest.mock('../../lib/kibana', () => ({
3536
describe('AddFilterToGlobalSearchBar Component', () => {
3637
const state: State = mockGlobalState;
3738
const { storage } = createSecuritySolutionStorageMock();
38-
let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
39+
let store = createStore(
40+
state,
41+
SUB_PLUGINS_REDUCER,
42+
apolloClientObservable,
43+
kibanaObservable,
44+
storage
45+
);
3946

4047
beforeEach(() => {
41-
store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
48+
store = createStore(
49+
state,
50+
SUB_PLUGINS_REDUCER,
51+
apolloClientObservable,
52+
kibanaObservable,
53+
storage
54+
);
4255
mockAddFilters.mockClear();
4356
});
4457

x-pack/plugins/security_solution/public/common/components/error_toast_dispatcher/index.test.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
apolloClientObservable,
1313
mockGlobalState,
1414
SUB_PLUGINS_REDUCER,
15+
kibanaObservable,
1516
createSecuritySolutionStorageMock,
1617
} from '../../mock';
1718
import { createStore } from '../../store/store';
@@ -22,10 +23,22 @@ import { State } from '../../store/types';
2223
describe('Error Toast Dispatcher', () => {
2324
const state: State = mockGlobalState;
2425
const { storage } = createSecuritySolutionStorageMock();
25-
let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
26+
let store = createStore(
27+
state,
28+
SUB_PLUGINS_REDUCER,
29+
apolloClientObservable,
30+
kibanaObservable,
31+
storage
32+
);
2633

2734
beforeEach(() => {
28-
store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
35+
store = createStore(
36+
state,
37+
SUB_PLUGINS_REDUCER,
38+
apolloClientObservable,
39+
kibanaObservable,
40+
storage
41+
);
2942
});
3043

3144
describe('rendering', () => {

x-pack/plugins/security_solution/public/common/components/inspect/index.test.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
mockGlobalState,
1515
apolloClientObservable,
1616
SUB_PLUGINS_REDUCER,
17+
kibanaObservable,
1718
createSecuritySolutionStorageMock,
1819
} from '../../mock';
1920
import { createStore, State } from '../../store';
@@ -36,13 +37,25 @@ describe('Inspect Button', () => {
3637
state: state.inputs,
3738
};
3839

39-
let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
40+
let store = createStore(
41+
state,
42+
SUB_PLUGINS_REDUCER,
43+
apolloClientObservable,
44+
kibanaObservable,
45+
storage
46+
);
4047

4148
describe('Render', () => {
4249
beforeEach(() => {
4350
const myState = cloneDeep(state);
4451
myState.inputs = upsertQuery(newQuery);
45-
store = createStore(myState, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
52+
store = createStore(
53+
myState,
54+
SUB_PLUGINS_REDUCER,
55+
apolloClientObservable,
56+
kibanaObservable,
57+
storage
58+
);
4659
});
4760
test('Eui Empty Button', () => {
4861
const wrapper = mount(
@@ -146,7 +159,13 @@ describe('Inspect Button', () => {
146159
response: ['my response'],
147160
};
148161
myState.inputs = upsertQuery(myQuery);
149-
store = createStore(myState, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
162+
store = createStore(
163+
myState,
164+
SUB_PLUGINS_REDUCER,
165+
apolloClientObservable,
166+
kibanaObservable,
167+
storage
168+
);
150169
});
151170
test('Open Inspect Modal', () => {
152171
const wrapper = mount(

x-pack/plugins/security_solution/public/common/components/stat_items/index.test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
mockGlobalState,
3535
apolloClientObservable,
3636
SUB_PLUGINS_REDUCER,
37+
kibanaObservable,
3738
createSecuritySolutionStorageMock,
3839
} from '../../mock';
3940
import { State, createStore } from '../../store';
@@ -55,7 +56,13 @@ describe('Stat Items Component', () => {
5556
const theme = () => ({ eui: euiDarkVars, darkMode: true });
5657
const state: State = mockGlobalState;
5758
const { storage } = createSecuritySolutionStorageMock();
58-
const store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
59+
const store = createStore(
60+
state,
61+
SUB_PLUGINS_REDUCER,
62+
apolloClientObservable,
63+
kibanaObservable,
64+
storage
65+
);
5966

6067
describe.each([
6168
[

x-pack/plugins/security_solution/public/common/components/super_date_picker/index.test.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
apolloClientObservable,
1515
mockGlobalState,
1616
SUB_PLUGINS_REDUCER,
17+
kibanaObservable,
1718
createSecuritySolutionStorageMock,
1819
} from '../../mock';
1920
import { createUseUiSetting$Mock } from '../../mock/kibana_react';
@@ -81,11 +82,23 @@ describe('SIEM Super Date Picker', () => {
8182
describe('#SuperDatePicker', () => {
8283
const state: State = mockGlobalState;
8384
const { storage } = createSecuritySolutionStorageMock();
84-
let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
85+
let store = createStore(
86+
state,
87+
SUB_PLUGINS_REDUCER,
88+
apolloClientObservable,
89+
kibanaObservable,
90+
storage
91+
);
8592

8693
beforeEach(() => {
8794
jest.clearAllMocks();
88-
store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
95+
store = createStore(
96+
state,
97+
SUB_PLUGINS_REDUCER,
98+
apolloClientObservable,
99+
kibanaObservable,
100+
storage
101+
);
89102
mockUseUiSetting$.mockImplementation((key, defaultValue) => {
90103
const useUiSetting$Mock = createUseUiSetting$Mock();
91104

x-pack/plugins/security_solution/public/common/components/top_n/index.test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
mockGlobalState,
1414
TestProviders,
1515
SUB_PLUGINS_REDUCER,
16+
kibanaObservable,
1617
createSecuritySolutionStorageMock,
1718
} from '../../mock';
1819
import { createKibanaCoreStartMock } from '../../mock/kibana_core';
@@ -156,7 +157,13 @@ const state: State = {
156157
};
157158

158159
const { storage } = createSecuritySolutionStorageMock();
159-
const store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
160+
const store = createStore(
161+
state,
162+
SUB_PLUGINS_REDUCER,
163+
apolloClientObservable,
164+
kibanaObservable,
165+
storage
166+
);
160167

161168
describe('StatefulTopN', () => {
162169
// Suppress warnings about "react-beautiful-dnd"

x-pack/plugins/security_solution/public/common/lib/compose/kibana_compose.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import ApolloClient from 'apollo-client';
99
import { ApolloLink } from 'apollo-link';
1010

1111
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
12-
import { CoreStart } from '../../../../../../../src/core/public';
1312
import introspectionQueryResultData from '../../../graphql/introspection.json';
1413
import { AppFrontendLibs } from '../lib';
1514
import { getLinks } from './helpers';
15+
import { CoreStart } from '../../../../../../../src/core/public';
1616

1717
export function composeLibs(core: CoreStart): AppFrontendLibs {
1818
const cache = new InMemoryCache({

0 commit comments

Comments
 (0)