From cfcb6e8f4ddf078ccdcec2a03788e39c6e4dfdef Mon Sep 17 00:00:00 2001 From: Konrad Szwarc Date: Tue, 17 Sep 2024 10:18:09 +0200 Subject: [PATCH] [EDR Workflows][Osquery] Fix last results pack value (#192678) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The “Last Results” tab in the active pack details is displaying incorrect date-time values. This is due to a mismatch in data format. The component responsible for formatting the date-time values expects a string, but it is currently receiving an array with a single string inside. Before: ![Screenshot 2024-09-12 at 10 33 39](https://github.com/user-attachments/assets/844fd699-a086-44d8-aa0b-a06e65e5aa60) After: ![Screenshot 2024-09-12 at 12 40 04](https://github.com/user-attachments/assets/bcce9b69-58b8-438d-89e8-c78a3922845c) --- .../packs/pack_queries_status_table.tsx | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx index 53d55aef7475c..d43721a61b6d2 100644 --- a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx +++ b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx @@ -187,7 +187,7 @@ const ViewResultsInLensActionComponent: React.FC { + (event: React.MouseEvent) => { event.preventDefault(); if (logsDataView?.id) { @@ -372,33 +372,31 @@ const ScheduledQueryLastResults: React.FC = ({ interval, }); + const timestamp = useMemo(() => { + const dateTime = lastResultsData?.['@timestamp']; + if (!dateTime) return undefined; + + return Array.isArray(dateTime) ? dateTime[0] : dateTime; + }, [lastResultsData]); + if (isLoading) { return ; } - if (!lastResultsData) { - return <>{'-'}; - } - return ( - {lastResultsData?.['@timestamp'] ? ( + {timestamp ? ( - {' '} - + {' '} + } >
- +
) : ( @@ -584,7 +582,7 @@ const PackQueriesStatusTableComponent: React.FC = ( Record> >({}); - const renderQueryColumn = useCallback((query: string, item: any) => { + const renderQueryColumn = useCallback((query: string, item: PackQueryFormData) => { const singleLine = removeMultilines(query); const content = singleLine.length > 55 ? `${singleLine.substring(0, 55)}...` : singleLine; @@ -618,7 +616,7 @@ const PackQueriesStatusTableComponent: React.FC = ( ); const renderLastResultsColumn = useCallback( - (item: any) => ( + (item: PackQueryFormData) => ( = ( [packName] ); const renderDocsColumn = useCallback( - (item: any) => ( + (item: PackQueryFormData) => ( ), [packName] ); const renderAgentsColumn = useCallback( - (item: any) => ( + (item: PackQueryFormData) => ( ), [packName] ); const renderErrorsColumn = useCallback( - (item: any) => ( + (item: PackQueryFormData) => ( = ( ); const renderDiscoverResultsAction = useCallback( - (item: any) => , + (item: PackQueryFormData) => , [packName] ); const renderLensResultsAction = useCallback( - (item: any) => , + (item: PackQueryFormData) => , [packName] );