Skip to content

Commit

Permalink
[SECURITY] Bug do not allow saving when opening a timeline (#74139) (#…
Browse files Browse the repository at this point in the history
…74232)

* only saved timeline when you are duplicating them

* fix unit test
  • Loading branch information
XavierM authored Aug 4, 2020
1 parent 485f438 commit a1b852e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ describe('helpers', () => {

expect(dispatchAddTimeline).toHaveBeenCalledWith({
id: 'timeline-1',
savedTimeline: true,
timeline: mockTimelineModel,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export const dispatchUpdateTimeline = (dispatch: Dispatch): DispatchUpdateTimeli
ruleNote,
}: UpdateTimeline): (() => void) => () => {
dispatch(dispatchSetTimelineRangeDatePicker({ from, to }));
dispatch(dispatchAddTimeline({ id, timeline }));
dispatch(dispatchAddTimeline({ id, timeline, savedTimeline: duplicate }));
if (
timeline.kqlQuery != null &&
timeline.kqlQuery.filterQuery != null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const updateTimeline = actionCreator<{
export const addTimeline = actionCreator<{
id: string;
timeline: TimelineModel;
savedTimeline?: boolean;
}>('ADD_TIMELINE');

export const setInsertTimeline = actionCreator<InsertTimeline | null>('SET_INSERT_TIMELINE');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import {
get,
getOr,
has,
merge as mergeObject,
set,
Expand Down Expand Up @@ -172,7 +173,7 @@ export const createTimelineEpic = <State>(): Epic<
myEpicTimelineId.setTimelineVersion(addNewTimeline.version);
myEpicTimelineId.setTemplateTimelineId(addNewTimeline.templateTimelineId);
myEpicTimelineId.setTemplateTimelineVersion(addNewTimeline.templateTimelineVersion);
return true;
return getOr(false, 'payload.savedTimeline', action);
} else if (
timelineActionsType.includes(action.type) &&
!timelineObj.isLoading &&
Expand Down

0 comments on commit a1b852e

Please sign in to comment.