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] Create template timeline #63136

Merged
merged 52 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d3b3ba6
init routes for template timeline
angorayc Apr 8, 2020
8a05dd9
create template timeline
angorayc Apr 9, 2020
79d53c8
Merge remote-tracking branch 'upstream/master' into template-timeline
angorayc Apr 9, 2020
99f0da5
add create/update timelines route
angorayc Apr 15, 2020
5a9b6ac
update api entry point
angorayc Apr 15, 2020
91798ee
fix types
angorayc Apr 15, 2020
dcae730
add template type
angorayc Apr 15, 2020
086996a
Merge remote-tracking branch 'upstream/master' into template-timeline
angorayc Apr 16, 2020
cab3e60
fix types
angorayc Apr 16, 2020
a33cbb6
add types and template timeline id
angorayc Apr 16, 2020
8243614
fix types
angorayc Apr 16, 2020
89f2b12
update import timeline to handle template timeline
angorayc Apr 16, 2020
464ee77
unit test
angorayc Apr 17, 2020
3a37628
sudo code
XavierM Apr 17, 2020
9bb3552
remove class for savedobject
angorayc Apr 20, 2020
aba9d8e
add template timeline version
angorayc Apr 20, 2020
e26a803
clean up arguments
angorayc Apr 20, 2020
5351219
fix types for framework request
XavierM Apr 20, 2020
7584715
show filter in find
XavierM Apr 20, 2020
d120d73
fix create template timeline
angorayc Apr 20, 2020
7aeb123
update mock data
angorayc Apr 20, 2020
7416fca
handle missing timeline when exporting
angorayc Apr 21, 2020
4b93431
update the order for timeline routes
angorayc Apr 21, 2020
3c51485
update schemas
angorayc Apr 21, 2020
c17ea0c
Merge remote-tracking branch 'upstream/master' into template-timeline
angorayc Apr 21, 2020
b94159f
Merge remote-tracking branch 'upstream/master' into template-timeline
angorayc Apr 21, 2020
0a7b275
move type to common folder so we can re-use them on UI and server side
XavierM Apr 21, 2020
0f22a03
fix types + integrate persist with epic timeline
XavierM Apr 21, 2020
bebb133
update all timeline when persit timeline
XavierM Apr 21, 2020
785ec34
add timeline api readme
angorayc Apr 22, 2020
2abe09b
fix validation error
angorayc Apr 22, 2020
8707b34
fix unit test
angorayc Apr 22, 2020
b7fa77a
Merge remote-tracking branch 'upstream/master' into template-timeline
angorayc Apr 23, 2020
8c56978
Merge branch 'master' into template-timeline
elasticmachine Apr 24, 2020
be2aea3
display error if unexpected format is given
angorayc Apr 27, 2020
7194dc5
Merge branch 'template-timeline' of github.com:angorayc/kibana into t…
angorayc Apr 27, 2020
21b535e
Merge remote-tracking branch 'upstream/master' into template-timeline
angorayc Apr 27, 2020
292c35e
Merge branch 'master' into template-timeline
elasticmachine Apr 27, 2020
f106ff4
fix issue with reftech all timeline query
XavierM Apr 27, 2020
a8c0501
fix flashing timeline while refetch
angorayc Apr 28, 2020
d1c851e
Merge branch 'template-timeline' of github.com:angorayc/kibana into t…
angorayc Apr 28, 2020
4eca630
fix types
angorayc Apr 28, 2020
7d3d120
Merge remote-tracking branch 'upstream/master' into template-timeline
angorayc Apr 28, 2020
5315cc7
fix types
angorayc Apr 28, 2020
1995a71
fix dependency
angorayc Apr 28, 2020
6413a11
fix timeline deletion
XavierM Apr 28, 2020
b1d54e7
Merge branch 'template-timeline' of github.com:angorayc/kibana into t…
XavierM Apr 28, 2020
48d43b7
remove redundant dependency
angorayc Apr 28, 2020
3993d5d
add i18n message
angorayc Apr 28, 2020
184711f
Merge branch 'master' into template-timeline
elasticmachine Apr 28, 2020
fd3a036
Merge branch 'master' into template-timeline
elasticmachine Apr 28, 2020
bdade71
fix unit test
angorayc Apr 29, 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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export interface TimelineActionsOverflowColumns {
} | null>;
}

enum TimelineTypes {
angorayc marked this conversation as resolved.
Show resolved Hide resolved
default = 'default',
template = 'template',
}
/** The results of the query run by the OpenTimeline component */
export interface OpenTimelineResult {
angorayc marked this conversation as resolved.
Show resolved Hide resolved
created?: number | null;
Expand All @@ -47,6 +51,8 @@ export interface OpenTimelineResult {
pinnedEventIds?: Readonly<Record<string, boolean>> | null;
savedObjectId?: string | null;
title?: string | null;
templateTimelineId?: string | null;
type?: TimelineTypes.template | TimelineTypes.default;
updated?: number | null;
updatedBy?: string | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const allTimelinesQuery = gql`
noteIds
pinnedEventIds
title
timelineType
templateTimelineId
created
createdBy
updated
Expand Down
51 changes: 51 additions & 0 deletions x-pack/legacy/plugins/siem/public/graphql/introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -9728,6 +9728,22 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "templateTimelineId",
"description": "",
"args": [],
"type": { "kind": "SCALAR", "name": "String", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "timelineType",
"description": "",
"args": [],
"type": { "kind": "ENUM", "name": "TimelineType", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updated",
"description": "",
Expand Down Expand Up @@ -10323,6 +10339,29 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "TimelineType",
"description": "",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "default",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "template",
"description": "",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "PageInfoTimeline",
Expand Down Expand Up @@ -10863,6 +10902,18 @@
"type": { "kind": "SCALAR", "name": "String", "ofType": null },
"defaultValue": null
},
{
"name": "templateTimelineId",
"description": "",
"type": { "kind": "SCALAR", "name": "String", "ofType": null },
"defaultValue": null
},
{
"name": "timelineType",
"description": "",
"type": { "kind": "ENUM", "name": "TimelineType", "ofType": null },
"defaultValue": null
},
{
"name": "dateRange",
"description": "",
Expand Down
17 changes: 17 additions & 0 deletions x-pack/legacy/plugins/siem/public/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export interface TimelineInput {

title?: Maybe<string>;

templateTimelineId?: Maybe<string>;

timelineType?: Maybe<TimelineType>;

dateRange?: Maybe<DateRangePickerInput>;

savedQueryId?: Maybe<string>;
Expand Down Expand Up @@ -334,6 +338,11 @@ export enum TlsFields {
_id = '_id',
}

export enum TimelineType {
default = 'default',
template = 'template',
}

export enum SortFieldTimeline {
title = 'title',
description = 'description',
Expand Down Expand Up @@ -1944,6 +1953,10 @@ export interface TimelineResult {

title?: Maybe<string>;

templateTimelineId?: Maybe<string>;

timelineType?: Maybe<TimelineType>;

updated?: Maybe<number>;

updatedBy?: Maybe<string>;
Expand Down Expand Up @@ -4030,6 +4043,10 @@ export namespace GetAllTimeline {

title: Maybe<string>;

timelineType: Maybe<TimelineType>;

templateTimelineId: Maybe<string>;

created: Maybe<number>;

createdBy: Maybe<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export const timelineSchema = gql`
script: String
}

enum TimelineType {
default
template
}

input TimelineInput {
columns: [ColumnHeaderInput!]
dataProviders: [DataProviderInput!]
Expand All @@ -134,6 +139,8 @@ export const timelineSchema = gql`
kqlMode: String
kqlQuery: SerializedFilterQueryInput
title: String
templateTimelineId: String
timelineType: TimelineType
dateRange: DateRangePickerInput
savedQueryId: String
sort: SortTimelineInput
Expand Down Expand Up @@ -237,6 +244,8 @@ export const timelineSchema = gql`
savedObjectId: String!
sort: SortTimelineResult
title: String
templateTimelineId: String
timelineType: TimelineType
updated: Float
updatedBy: String
version: String!
Expand Down
27 changes: 27 additions & 0 deletions x-pack/legacy/plugins/siem/server/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export interface TimelineInput {

title?: Maybe<string>;

templateTimelineId?: Maybe<string>;

timelineType?: Maybe<TimelineType>;

dateRange?: Maybe<DateRangePickerInput>;

savedQueryId?: Maybe<string>;
Expand Down Expand Up @@ -336,6 +340,11 @@ export enum TlsFields {
_id = '_id',
}

export enum TimelineType {
default = 'default',
template = 'template',
}

export enum SortFieldTimeline {
title = 'title',
description = 'description',
Expand Down Expand Up @@ -1946,6 +1955,10 @@ export interface TimelineResult {

title?: Maybe<string>;

templateTimelineId?: Maybe<string>;

timelineType?: Maybe<TimelineType>;

updated?: Maybe<number>;

updatedBy?: Maybe<string>;
Expand Down Expand Up @@ -8023,6 +8036,10 @@ export namespace TimelineResultResolvers {

title?: TitleResolver<Maybe<string>, TypeParent, TContext>;

templateTimelineId?: TemplateTimelineIdResolver<Maybe<string>, TypeParent, TContext>;

timelineType?: TimelineTypeResolver<Maybe<TimelineType>, TypeParent, TContext>;

updated?: UpdatedResolver<Maybe<number>, TypeParent, TContext>;

updatedBy?: UpdatedByResolver<Maybe<string>, TypeParent, TContext>;
Expand Down Expand Up @@ -8130,6 +8147,16 @@ export namespace TimelineResultResolvers {
Parent = TimelineResult,
TContext = SiemContext
> = Resolver<R, Parent, TContext>;
export type TemplateTimelineIdResolver<
R = Maybe<string>,
Parent = TimelineResult,
TContext = SiemContext
> = Resolver<R, Parent, TContext>;
export type TimelineTypeResolver<
R = Maybe<TimelineType>,
Parent = TimelineResult,
TContext = SiemContext
> = Resolver<R, Parent, TContext>;
export type UpdatedResolver<
R = Maybe<number>,
Parent = TimelineResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import { TimelineSavedObjectRuntimeType, TimelineSavedObject } from './types';
export const convertSavedObjectToSavedTimeline = (savedObject: unknown): TimelineSavedObject => {
const timeline = pipe(
TimelineSavedObjectRuntimeType.decode(savedObject),
map(savedTimeline => ({
savedObjectId: savedTimeline.id,
version: savedTimeline.version,
...savedTimeline.attributes,
})),
map(savedTimeline => {
return {
savedObjectId: savedTimeline.id,
version: savedTimeline.version,
...savedTimeline.attributes,
};
}),
fold(errors => {
throw new Error(failure(errors).join('\n'));
}, identity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import uuid from 'uuid';
import { AuthenticatedUser } from '../../../../../../plugins/security/common/model';
import { UNAUTHENTICATED_USER } from '../../../common/constants';
import { SavedTimeline } from './types';
import { TimelineType } from '../../../public/graphql/types';
angorayc marked this conversation as resolved.
Show resolved Hide resolved

export const pickSavedTimeline = (
timelineId: string | null,
savedTimeline: SavedTimeline,
userInfo: AuthenticatedUser | null
userInfo: AuthenticatedUser | null,
timelineType?: TimelineType | null
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any => {
const dateNow = new Date().valueOf();
Expand All @@ -24,5 +26,15 @@ export const pickSavedTimeline = (
savedTimeline.updated = dateNow;
savedTimeline.updatedBy = userInfo?.username ?? UNAUTHENTICATED_USER;
}

if (timelineType === TimelineType.template) {
savedTimeline.timelineType = TimelineType.template;
if (savedTimeline.templateTimelineId === null) {
savedTimeline.templateTimelineId = uuid.v4();
}
} else {
savedTimeline.timelineType = TimelineType.default;
}

return savedTimeline;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { omit } from 'lodash/fp';
import { TimelineType } from '../../../../graphql/types';

export const mockDuplicateIdErrors = [];

Expand Down Expand Up @@ -148,6 +149,12 @@ export const mockGetTimelineValue = {
pinnedEventIds: ['k-gi8nABm-sIqJ_scOoS'],
};

export const mockGetTemplateTimelineValue = {
...mockGetTimelineValue,
timelineType: TimelineType.template,
templateTimelineId: 'existing template timeline id',
};

export const mockParsedTimelineObject = omit(
[
'globalNotes',
Expand Down
Loading