From 4de5297b584c309ac4c1ab0fc72eee60b6099e31 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Thu, 13 Feb 2020 14:18:04 +0200 Subject: [PATCH] Timestamps to Zulu time --- .../siem/public/containers/case/types.ts | 4 ++-- .../public/containers/case/use_get_case.tsx | 4 ++-- .../api/__fixtures__/mock_saved_objects.ts | 24 +++++++++---------- .../plugins/case/server/routes/api/schema.ts | 6 ++--- .../plugins/case/server/routes/api/types.ts | 6 ++--- .../case/server/routes/api/update_case.ts | 2 +- .../case/server/routes/api/update_comment.ts | 2 +- .../plugins/case/server/routes/api/utils.ts | 8 +++---- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/x-pack/legacy/plugins/siem/public/containers/case/types.ts b/x-pack/legacy/plugins/siem/public/containers/case/types.ts index cf9e0c9fa4fc1e..e98ff9677815b7 100644 --- a/x-pack/legacy/plugins/siem/public/containers/case/types.ts +++ b/x-pack/legacy/plugins/siem/public/containers/case/types.ts @@ -19,13 +19,13 @@ export interface NewCase extends FormData { export interface Case { case_id: string; case_type: string; - created_at: number; + created_at: string; created_by: ElasticUser; description: string; state: string; tags: string[]; title: string; - updated_at: number; + updated_at: string; } export interface QueryParams { diff --git a/x-pack/legacy/plugins/siem/public/containers/case/use_get_case.tsx b/x-pack/legacy/plugins/siem/public/containers/case/use_get_case.tsx index 845471b6e1c7ed..0de8a5fe80fdda 100644 --- a/x-pack/legacy/plugins/siem/public/containers/case/use_get_case.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/case/use_get_case.tsx @@ -52,7 +52,7 @@ const dataFetchReducer = (state: CaseState, action: Action): CaseState => { const initialData: Case = { case_id: '', case_type: '', - created_at: 0, + created_at: '', created_by: { username: '', }, @@ -60,7 +60,7 @@ const initialData: Case = { state: '', tags: [], title: '', - updated_at: 0, + updated_at: '', }; export const useGetCase = (caseId: string): [CaseState] => { diff --git a/x-pack/plugins/case/server/routes/api/__fixtures__/mock_saved_objects.ts b/x-pack/plugins/case/server/routes/api/__fixtures__/mock_saved_objects.ts index 51cf0f74010ad2..42b2f32a639a6c 100644 --- a/x-pack/plugins/case/server/routes/api/__fixtures__/mock_saved_objects.ts +++ b/x-pack/plugins/case/server/routes/api/__fixtures__/mock_saved_objects.ts @@ -9,7 +9,7 @@ export const mockCases = [ type: 'case-workflow', id: 'mock-id-1', attributes: { - created_at: 1574718888885, + created_at: '2019-11-25T21:54:48.952Z', created_by: { full_name: null, username: 'elastic', @@ -19,7 +19,7 @@ export const mockCases = [ state: 'open', tags: ['defacement'], case_type: 'security', - updated_at: 1574718888885, + updated_at: '2019-11-25T21:54:48.952Z', }, references: [], updated_at: '2019-11-25T21:54:48.952Z', @@ -29,7 +29,7 @@ export const mockCases = [ type: 'case-workflow', id: 'mock-id-2', attributes: { - created_at: 1574721120834, + created_at: '2019-11-25T22:32:00.900Z', created_by: { full_name: null, username: 'elastic', @@ -39,7 +39,7 @@ export const mockCases = [ state: 'open', tags: ['Data Destruction'], case_type: 'security', - updated_at: 1574721130834, + updated_at: '2019-11-25T22:32:00.900Z', }, references: [], updated_at: '2019-11-25T22:32:00.900Z', @@ -49,7 +49,7 @@ export const mockCases = [ type: 'case-workflow', id: 'mock-id-3', attributes: { - created_at: 1574721137881, + created_at: '2019-11-25T22:32:17.947Z', created_by: { full_name: null, username: 'elastic', @@ -59,7 +59,7 @@ export const mockCases = [ state: 'open', tags: ['LOLBins'], case_type: 'security', - updated_at: 1574721147881, + updated_at: '2019-11-25T22:32:17.947Z', }, references: [], updated_at: '2019-11-25T22:32:17.947Z', @@ -82,12 +82,12 @@ export const mockCaseComments = [ id: 'mock-comment-1', attributes: { comment: 'Wow, good luck catching that bad meanie!', - created_at: 1574718900112, + created_at: '2019-11-25T21:55:00.177Z', created_by: { full_name: 'elastic', username: 'elastic', }, - updated_at: 1574718900112, + updated_at: '2019-11-25T21:55:00.177Z', }, references: [ { @@ -104,12 +104,12 @@ export const mockCaseComments = [ id: 'mock-comment-2', attributes: { comment: 'Well I decided to update my comment. So what? Deal with it.', - created_at: 1574718902724, + created_at: '2019-11-25T21:55:14.633Z', created_by: { full_name: 'elastic', username: 'elastic', }, - updated_at: 1574718902724, + updated_at: '2019-11-25T21:55:14.633Z', }, references: [ { @@ -126,12 +126,12 @@ export const mockCaseComments = [ id: 'mock-comment-3', attributes: { comment: 'Wow, good luck catching that bad meanie!', - created_at: 1574721150542, + created_at: '2019-11-25T22:32:30.608Z', created_by: { full_name: 'elastic', username: 'elastic', }, - updated_at: 1574721150542, + updated_at: '2019-11-25T22:32:30.608Z', }, references: [ { diff --git a/x-pack/plugins/case/server/routes/api/schema.ts b/x-pack/plugins/case/server/routes/api/schema.ts index e3c0a21717b3fe..0f09283f21ecb1 100644 --- a/x-pack/plugins/case/server/routes/api/schema.ts +++ b/x-pack/plugins/case/server/routes/api/schema.ts @@ -17,14 +17,14 @@ export const NewCommentSchema = schema.object({ export const CommentSchema = schema.object({ comment: schema.string(), - created_at: schema.number(), + created_at: schema.string(), created_by: UserSchema, - updated_at: schema.number(), + updated_at: schema.string(), }); export const UpdatedCommentSchema = schema.object({ comment: schema.string(), - updated_at: schema.number(), + updated_at: schema.string(), }); export const NewCaseSchema = schema.object({ diff --git a/x-pack/plugins/case/server/routes/api/types.ts b/x-pack/plugins/case/server/routes/api/types.ts index 24f9f791ce6c7d..a5c565029b29a6 100644 --- a/x-pack/plugins/case/server/routes/api/types.ts +++ b/x-pack/plugins/case/server/routes/api/types.ts @@ -25,9 +25,9 @@ export type UpdatedCommentType = TypeOf; export type UserType = TypeOf; export interface CaseAttributes extends NewCaseType, SavedObjectAttributes { - created_at: number; + created_at: string; created_by: UserType; - updated_at: number; + updated_at: string; } export type FlattenedCaseSavedObject = CaseAttributes & { @@ -68,5 +68,5 @@ export interface UpdatedCaseType { state?: UpdatedCaseTyped['state']; tags?: UpdatedCaseTyped['tags']; title?: UpdatedCaseTyped['title']; - updated_at: number; + updated_at: string; } diff --git a/x-pack/plugins/case/server/routes/api/update_case.ts b/x-pack/plugins/case/server/routes/api/update_case.ts index ffa0d9431224e3..2a814c7259e4a6 100644 --- a/x-pack/plugins/case/server/routes/api/update_case.ts +++ b/x-pack/plugins/case/server/routes/api/update_case.ts @@ -27,7 +27,7 @@ export function initUpdateCaseApi({ caseService, router }: RouteDeps) { caseId: request.params.id, updatedAttributes: { ...request.body, - updated_at: new Date().valueOf(), + updated_at: new Date().toISOString(), }, }); return response.ok({ body: updatedCase.attributes }); diff --git a/x-pack/plugins/case/server/routes/api/update_comment.ts b/x-pack/plugins/case/server/routes/api/update_comment.ts index 60ed0587f5dfd6..815f44a14e2e70 100644 --- a/x-pack/plugins/case/server/routes/api/update_comment.ts +++ b/x-pack/plugins/case/server/routes/api/update_comment.ts @@ -27,7 +27,7 @@ export function initUpdateCommentApi({ caseService, router }: RouteDeps) { commentId: request.params.id, updatedAttributes: { ...request.body, - updated_at: new Date().valueOf(), + updated_at: new Date().toISOString(), }, }); return response.ok({ body: updatedComment.attributes }); diff --git a/x-pack/plugins/case/server/routes/api/utils.ts b/x-pack/plugins/case/server/routes/api/utils.ts index ad97a409e94b6e..51944b04836ab6 100644 --- a/x-pack/plugins/case/server/routes/api/utils.ts +++ b/x-pack/plugins/case/server/routes/api/utils.ts @@ -27,9 +27,9 @@ export const formatNewCase = ( newCase: NewCaseType, { full_name, username }: { full_name?: string; username: string } ): CaseAttributes => ({ - created_at: new Date().valueOf(), + created_at: new Date().toISOString(), created_by: { full_name, username }, - updated_at: new Date().valueOf(), + updated_at: new Date().toISOString(), ...newCase, }); @@ -44,9 +44,9 @@ export const formatNewComment = ({ username, }: NewCommentArgs): CommentAttributes => ({ ...newComment, - created_at: new Date().valueOf(), + created_at: new Date().toISOString(), created_by: { full_name, username }, - updated_at: new Date().valueOf(), + updated_at: new Date().toISOString(), }); export function wrapError(error: any): CustomHttpResponseOptions {