Skip to content

Commit 33dba4d

Browse files
[Security Solution] Invalid kql query timeline refresh bug (#105525) (#106192)
* poc test * adds disable for refresh button Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Davis Plumlee <[email protected]>
1 parent 644d214 commit 33dba4d

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const SuperDatePickerComponent = React.memo<SuperDatePickerProps>(
9191
timelineId,
9292
toStr,
9393
updateReduxTime,
94+
disabled,
9495
}) => {
9596
const [recentlyUsedRanges, setRecentlyUsedRanges] = useState<EuiSuperDatePickerRecentRange[]>(
9697
[]
@@ -201,6 +202,7 @@ export const SuperDatePickerComponent = React.memo<SuperDatePickerProps>(
201202
refreshInterval={duration}
202203
showUpdateButton={true}
203204
start={startDate}
205+
isDisabled={disabled}
204206
/>
205207
);
206208
},
@@ -216,6 +218,7 @@ export const SuperDatePickerComponent = React.memo<SuperDatePickerProps>(
216218
prevProps.startAutoReload === nextProps.startAutoReload &&
217219
prevProps.stopAutoReload === nextProps.stopAutoReload &&
218220
prevProps.timelineId === nextProps.timelineId &&
221+
prevProps.disabled === nextProps.disabled &&
219222
prevProps.toStr === nextProps.toStr &&
220223
prevProps.updateReduxTime === nextProps.updateReduxTime &&
221224
deepEqual(prevProps.kqlQuery, nextProps.kqlQuery) &&

x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.tsx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,21 @@ export const QueryTabContentComponent: React.FC<Props> = ({
220220
});
221221

222222
const isBlankTimeline: boolean =
223-
isEmpty(dataProviders) && isEmpty(filters) && isEmpty(kqlQuery.query);
224-
225-
const canQueryTimeline = () =>
226-
combinedQueries != null &&
227-
loadingSourcerer != null &&
228-
!loadingSourcerer &&
229-
!isEmpty(start) &&
230-
!isEmpty(end);
223+
isEmpty(dataProviders) &&
224+
isEmpty(filters) &&
225+
isEmpty(kqlQuery.query) &&
226+
combinedQueries?.filterQuery === undefined;
227+
228+
const canQueryTimeline = useMemo(
229+
() =>
230+
combinedQueries != null &&
231+
loadingSourcerer != null &&
232+
!loadingSourcerer &&
233+
!isEmpty(start) &&
234+
!isEmpty(end) &&
235+
combinedQueries?.filterQuery !== undefined,
236+
[combinedQueries, end, loadingSourcerer, start]
237+
);
231238

232239
const getTimelineQueryFields = () => {
233240
const columnsHeader = isEmpty(columns) ? defaultHeaders : columns;
@@ -264,7 +271,7 @@ export const QueryTabContentComponent: React.FC<Props> = ({
264271
limit: itemsPerPage,
265272
filterQuery: combinedQueries?.filterQuery,
266273
startDate: start,
267-
skip: !canQueryTimeline() || combinedQueries?.filterQuery === undefined,
274+
skip: !canQueryTimeline,
268275
sort: timelineQuerySortField,
269276
timerangeKind,
270277
});
@@ -290,6 +297,10 @@ export const QueryTabContentComponent: React.FC<Props> = ({
290297
);
291298
}, [loadingSourcerer, timelineId, isQueryLoading, dispatch]);
292299

300+
const isDatePickerDisabled = useMemo(() => {
301+
return (combinedQueries && combinedQueries.kqlError != null) || false;
302+
}, [combinedQueries]);
303+
293304
const leadingControlColumns: ControlColumnProps[] = [defaultControlColumn];
294305
const trailingControlColumns: ControlColumnProps[] = [];
295306

@@ -304,6 +315,7 @@ export const QueryTabContentComponent: React.FC<Props> = ({
304315
inspect={inspect}
305316
loading={isQueryLoading}
306317
refetch={refetch}
318+
skip={!canQueryTimeline}
307319
/>
308320
<FullWidthFlexGroup gutterSize="none">
309321
<ScrollableFlexItem grow={2}>
@@ -323,7 +335,11 @@ export const QueryTabContentComponent: React.FC<Props> = ({
323335
/>
324336
)}
325337
<DatePicker grow={1}>
326-
<SuperDatePicker id="timeline" timelineId={timelineId} />
338+
<SuperDatePicker
339+
id="timeline"
340+
timelineId={timelineId}
341+
disabled={isDatePickerDisabled}
342+
/>
327343
</DatePicker>
328344
<EuiFlexItem grow={false}>
329345
<TimelineDatePickerLock />

x-pack/plugins/security_solution/public/timelines/components/timeline/refetch_timeline.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface TimelineRefetchProps {
1818
inspect: inputsModel.InspectQuery | null;
1919
loading: boolean;
2020
refetch: inputsModel.Refetch;
21+
skip?: boolean;
2122
}
2223

2324
const TimelineRefetchComponent: React.FC<TimelineRefetchProps> = ({
@@ -26,12 +27,15 @@ const TimelineRefetchComponent: React.FC<TimelineRefetchProps> = ({
2627
inspect,
2728
loading,
2829
refetch,
30+
skip,
2931
}) => {
3032
const dispatch = useDispatch();
3133

3234
useEffect(() => {
33-
dispatch(inputsActions.setQuery({ id, inputId, inspect, loading, refetch }));
34-
}, [dispatch, id, inputId, loading, refetch, inspect]);
35+
if (!skip) {
36+
dispatch(inputsActions.setQuery({ id, inputId, inspect, loading, refetch }));
37+
}
38+
}, [dispatch, id, inputId, loading, refetch, inspect, skip]);
3539

3640
return null;
3741
};

0 commit comments

Comments
 (0)