Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM] Import timeline fix #65448

Merged
merged 89 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
67e7406
fix import timeline and clean up
angorayc May 6, 2020
f30c970
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc May 8, 2020
f5893e5
add unit tests
angorayc May 11, 2020
9ee6cc0
clean up common libs
angorayc May 12, 2020
1668031
rename variables
angorayc May 12, 2020
6aff660
add unit tests
angorayc May 12, 2020
10880fa
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc May 12, 2020
2b8a694
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc May 15, 2020
d69bfb5
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc May 19, 2020
c49b7d4
fix types
angorayc May 19, 2020
09b03e0
Merge branch 'master' of github.com:elastic/kibana into import-timeli…
patrykkopycinski May 20, 2020
18f98a8
Fix imports
patrykkopycinski May 20, 2020
af21224
rename file
angorayc May 20, 2020
5cf93cd
poc
patrykkopycinski May 20, 2020
2ec6f0c
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc May 21, 2020
e76d860
fix unit test
angorayc May 21, 2020
e6263f3
review
angorayc May 21, 2020
11b5599
Merge branch 'master' of github.com:elastic/kibana into import-timeli…
patrykkopycinski May 25, 2020
98160b9
cleanup fallback values
patrykkopycinski May 25, 2020
a3ef3e4
cleanup
patrykkopycinski May 25, 2020
90658bb
check if title exists
angorayc May 26, 2020
826fcb8
Merge branch 'import-timeline-fix' of github.com:angorayc/kibana into…
angorayc May 26, 2020
330fe75
fix unit test
angorayc May 26, 2020
71e66da
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc May 27, 2020
4872d9b
add unit test
angorayc May 27, 2020
132b538
lint error
angorayc May 27, 2020
3d9ea8f
put the flag for disableTemplate into common
angorayc May 28, 2020
06ceb29
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc May 29, 2020
073ff08
add immutiable
angorayc May 29, 2020
adc0c76
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 1, 2020
a87ad1c
fix unit
angorayc Jun 1, 2020
5293e32
check templateTimelineVersion only when update via import
angorayc Jun 2, 2020
f84b540
update template timeline via import with response
XavierM Jun 1, 2020
017846c
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 4, 2020
7039cd9
add template filter
angorayc Jun 5, 2020
fe2525e
add filter count
angorayc Jun 5, 2020
d5a62e3
add filter numbers
angorayc Jun 6, 2020
e296a2a
rename
angorayc Jun 6, 2020
75f3d46
enable pin events and note under active status
angorayc Jun 7, 2020
c151765
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 8, 2020
72d8b03
disable comment and pinnedEvents for template timelines
angorayc Jun 8, 2020
427e8f7
add timelineType for openTimeline
angorayc Jun 8, 2020
98e4376
enable note icon for template
angorayc Jun 8, 2020
333c47e
add timeline type for propertyLeft
angorayc Jun 8, 2020
5c68f19
fix types
angorayc Jun 8, 2020
3b97fae
duplicate elastic template
angorayc Jun 9, 2020
0f81b33
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 9, 2020
83d37bc
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 9, 2020
3dae9a9
update schema
angorayc Jun 9, 2020
ae4bcc1
Merge branch 'master' of github.com:elastic/kibana into import-timeli…
angorayc Jun 9, 2020
64404ed
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 9, 2020
9126d58
fix status check
angorayc Jun 10, 2020
be5665c
fix import
angorayc Jun 10, 2020
cae2e69
add templateTimelineType
angorayc Jun 11, 2020
67b525d
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 11, 2020
0d61f94
disable note for immutable timeline
angorayc Jun 12, 2020
0020c39
fix unit
angorayc Jun 14, 2020
a8b8fce
fix error message
angorayc Jun 15, 2020
3063fb3
fix update
angorayc Jun 16, 2020
fc6511a
fix types
angorayc Jun 16, 2020
2662c96
rollback change
angorayc Jun 16, 2020
77378d3
rollback change
angorayc Jun 16, 2020
3e788b9
fix create template timeline
angorayc Jun 16, 2020
f29afc3
add i18n for error message
angorayc Jun 16, 2020
d84a57a
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 16, 2020
0bd39d2
fix unit test
angorayc Jun 16, 2020
acd2477
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 17, 2020
aea522e
fix wording and disable delete btn for immutable timeline
angorayc Jun 17, 2020
8ff5593
fix unit test provider
angorayc Jun 17, 2020
f9b961f
fix types
angorayc Jun 17, 2020
bdf62d6
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 18, 2020
200aacc
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 23, 2020
1d1791f
fix toaster
angorayc Jun 24, 2020
1fd2639
fix notes and pins
angorayc Jun 24, 2020
51455e6
add i18n
angorayc Jun 24, 2020
0ad6538
fix selected items
angorayc Jun 24, 2020
82cc49c
set disableTemplateto true
angorayc Jun 24, 2020
635a6e5
move templateInfo to helper
angorayc Jun 24, 2020
07222f2
Merge branch 'master' of github.com:elastic/kibana into pr/65448
XavierM Jun 25, 2020
f5c68e2
review + imporvement
XavierM Jun 25, 2020
94f2a7d
fix review
angorayc Jun 25, 2020
cd0bde5
fix types
angorayc Jun 25, 2020
c1127aa
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 25, 2020
005c8d4
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 26, 2020
c917ce8
fix types
angorayc Jun 26, 2020
0e3003d
Merge branch 'master' of github.com:elastic/kibana into import-timeli…
patrykkopycinski Jun 26, 2020
71aeed2
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 26, 2020
3db3ffc
Merge branch 'import-timeline-fix' of github.com:angorayc/kibana into…
angorayc Jun 26, 2020
fed80c3
Merge remote-tracking branch 'upstream/master' into import-timeline-fix
angorayc Jun 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ export const showAllOthersBucket: string[] = [

/**
* CreateTemplateTimelineBtn
* https://github.com/elastic/kibana/pull/66613
* Remove the comment here to enable template timeline
*/
export const disableTemplate = true;
export const disableTemplate = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we still need the flag. Maybe, we can create another PR later on to remove this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, in another PR sounds good.


/*
* This should be set to true after https://github.com/elastic/kibana/pull/67496 is merged
*/
export const enableElasticFilter = false;
32 changes: 32 additions & 0 deletions x-pack/plugins/security_solution/common/types/timeline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ const SavedSortRuntimeType = runtimeTypes.partial({
export enum TimelineStatus {
active = 'active',
draft = 'draft',
immutable = 'immutable',
}

export const TimelineStatusLiteralRt = runtimeTypes.union([
runtimeTypes.literal(TimelineStatus.active),
runtimeTypes.literal(TimelineStatus.draft),
runtimeTypes.literal(TimelineStatus.immutable),
]);

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

/**
* Template timeline type
*/

export enum TemplateTimelineType {
elastic = 'elastic',
custom = 'custom',
}

export const TemplateTimelineTypeLiteralRt = runtimeTypes.union([
runtimeTypes.literal(TemplateTimelineType.elastic),
runtimeTypes.literal(TemplateTimelineType.custom),
]);

export const TemplateTimelineTypeLiteralWithNullRt = unionWithNullType(
TemplateTimelineTypeLiteralRt
);

export type TemplateTimelineTypeLiteral = runtimeTypes.TypeOf<typeof TemplateTimelineTypeLiteralRt>;
export type TemplateTimelineTypeLiteralWithNull = runtimeTypes.TypeOf<
typeof TemplateTimelineTypeLiteralWithNullRt
>;

/*
* Timeline Types
*/
Expand Down Expand Up @@ -273,6 +298,13 @@ export const TimelineResponseType = runtimeTypes.type({
}),
});

export const TimelineErrorResponseType = runtimeTypes.type({
status_code: runtimeTypes.number,
message: runtimeTypes.string,
});

export interface TimelineErrorResponse
extends runtimeTypes.TypeOf<typeof TimelineErrorResponseType> {}
export interface TimelineResponse extends runtimeTypes.TypeOf<typeof TimelineResponseType> {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ describe('alert actions', () => {
columnId: '@timestamp',
sortDirection: 'desc',
},
status: TimelineStatus.draft,
title: '',
status: TimelineStatus.active,
title: 'Test rule - Duplicate',
timelineType: TimelineType.default,
templateTimelineId: null,
templateTimelineVersion: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
mockGlobalState,
TestProviders,
SUB_PLUGINS_REDUCER,
kibanaObservable,
createSecuritySolutionStorageMock,
} from '../../mock';
import { createStore, State } from '../../store';
Expand All @@ -35,10 +36,22 @@ jest.mock('../../lib/kibana', () => ({
describe('AddFilterToGlobalSearchBar Component', () => {
const state: State = mockGlobalState;
const { storage } = createSecuritySolutionStorageMock();
let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
let store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);

beforeEach(() => {
store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);
mockAddFilters.mockClear();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
apolloClientObservable,
mockGlobalState,
SUB_PLUGINS_REDUCER,
kibanaObservable,
createSecuritySolutionStorageMock,
} from '../../mock';
import { createStore } from '../../store/store';
Expand All @@ -22,10 +23,22 @@ import { State } from '../../store/types';
describe('Error Toast Dispatcher', () => {
const state: State = mockGlobalState;
const { storage } = createSecuritySolutionStorageMock();
let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
let store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);

beforeEach(() => {
store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);
});

describe('rendering', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
mockGlobalState,
apolloClientObservable,
SUB_PLUGINS_REDUCER,
kibanaObservable,
createSecuritySolutionStorageMock,
} from '../../mock';
import { createStore, State } from '../../store';
Expand All @@ -36,13 +37,25 @@ describe('Inspect Button', () => {
state: state.inputs,
};

let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
let store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);

describe('Render', () => {
beforeEach(() => {
const myState = cloneDeep(state);
myState.inputs = upsertQuery(newQuery);
store = createStore(myState, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
store = createStore(
myState,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);
});
test('Eui Empty Button', () => {
const wrapper = mount(
Expand Down Expand Up @@ -146,7 +159,13 @@ describe('Inspect Button', () => {
response: ['my response'],
};
myState.inputs = upsertQuery(myQuery);
store = createStore(myState, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
store = createStore(
myState,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);
});
test('Open Inspect Modal', () => {
const wrapper = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
mockGlobalState,
apolloClientObservable,
SUB_PLUGINS_REDUCER,
kibanaObservable,
createSecuritySolutionStorageMock,
} from '../../mock';
import { State, createStore } from '../../store';
Expand All @@ -55,7 +56,13 @@ describe('Stat Items Component', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
const state: State = mockGlobalState;
const { storage } = createSecuritySolutionStorageMock();
const store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
const store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);

describe.each([
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
apolloClientObservable,
mockGlobalState,
SUB_PLUGINS_REDUCER,
kibanaObservable,
createSecuritySolutionStorageMock,
} from '../../mock';
import { createUseUiSetting$Mock } from '../../mock/kibana_react';
Expand Down Expand Up @@ -81,11 +82,23 @@ describe('SIEM Super Date Picker', () => {
describe('#SuperDatePicker', () => {
const state: State = mockGlobalState;
const { storage } = createSecuritySolutionStorageMock();
let store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
let store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);

beforeEach(() => {
jest.clearAllMocks();
store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);
mockUseUiSetting$.mockImplementation((key, defaultValue) => {
const useUiSetting$Mock = createUseUiSetting$Mock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
mockGlobalState,
TestProviders,
SUB_PLUGINS_REDUCER,
kibanaObservable,
createSecuritySolutionStorageMock,
} from '../../mock';
import { createKibanaCoreStartMock } from '../../mock/kibana_core';
Expand Down Expand Up @@ -156,7 +157,13 @@ const state: State = {
};

const { storage } = createSecuritySolutionStorageMock();
const store = createStore(state, SUB_PLUGINS_REDUCER, apolloClientObservable, storage);
const store = createStore(
state,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage
);

describe('StatefulTopN', () => {
// Suppress warnings about "react-beautiful-dnd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import ApolloClient from 'apollo-client';
import { ApolloLink } from 'apollo-link';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { CoreStart } from '../../../../../../../src/core/public';
import introspectionQueryResultData from '../../../graphql/introspection.json';
import { AppFrontendLibs } from '../lib';
import { getLinks } from './helpers';
import { CoreStart } from '../../../../../../../src/core/public';

export function composeLibs(core: CoreStart): AppFrontendLibs {
const cache = new InMemoryCache({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { coreMock } from '../../../../../../../src/core/public/mocks';
import { StartPlugins } from '../../../types';
import { depsStartMock } from './dependencies_start_mock';
import { MiddlewareActionSpyHelper, createSpyMiddleware } from '../../store/test_utils';
import { apolloClientObservable } from '../test_providers';
import { apolloClientObservable, kibanaObservable } from '../test_providers';
import { createStore, State, substateMiddlewareFactory } from '../../store';
import { alertMiddlewareFactory } from '../../../endpoint_alerts/store/middleware';
import { AppRootProvider } from './app_root_provider';
Expand Down Expand Up @@ -58,14 +58,21 @@ export const createAppRootMockRenderer = (): AppContextTestRender => {
const middlewareSpy = createSpyMiddleware();
const { storage } = createSecuritySolutionStorageMock();

const store = createStore(mockGlobalState, SUB_PLUGINS_REDUCER, apolloClientObservable, storage, [
substateMiddlewareFactory(
(globalState) => globalState.alertList,
alertMiddlewareFactory(coreStart, depsStart)
),
...managementMiddlewareFactory(coreStart, depsStart),
middlewareSpy.actionSpyMiddleware,
]);
const store = createStore(
mockGlobalState,
SUB_PLUGINS_REDUCER,
apolloClientObservable,
kibanaObservable,
storage,
[
substateMiddlewareFactory(
(globalState) => globalState.alertList,
alertMiddlewareFactory(coreStart, depsStart)
),
...managementMiddlewareFactory(coreStart, depsStart),
middlewareSpy.actionSpyMiddleware,
]
);

const MockKibanaContextProvider = createKibanaContextProviderMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
DEFAULT_INDEX_PATTERN,
} from '../../../common/constants';
import { createKibanaCoreStartMock, createKibanaPluginsStartMock } from './kibana_core';
import { StartServices } from '../../types';
import { createSecuritySolutionStorageMock } from './mock_local_storage';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -71,6 +72,8 @@ export const createUseUiSetting$Mock = () => {
): [T, () => void] | undefined => [useUiSettingMock(key, defaultValue), jest.fn()];
};

export const createKibanaObservable$Mock = createKibanaCoreStartMock;

export const createUseKibanaMock = () => {
const core = createKibanaCoreStartMock();
const plugins = createKibanaPluginsStartMock();
Expand All @@ -90,6 +93,36 @@ export const createUseKibanaMock = () => {
return () => ({ services });
};

export const createStartServices = () => {
const core = createKibanaCoreStartMock();
const plugins = createKibanaPluginsStartMock();
const security = {
authc: {
getCurrentUser: jest.fn(),
areAPIKeysEnabled: jest.fn(),
},
sessionTimeout: {
start: jest.fn(),
stop: jest.fn(),
extend: jest.fn(),
},
license: {
isEnabled: jest.fn(),
getFeatures: jest.fn(),
features$: jest.fn(),
},
__legacyCompat: { logoutUrl: 'logoutUrl', tenant: 'tenant' },
};

const services = ({
...core,
...plugins,
security,
} as unknown) as StartServices;

return services;
};

export const createWithKibanaMock = () => {
const kibana = createUseKibanaMock()();

Expand Down
Loading