-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Defend Workflows] Common response actions tab in alert Flyout (#155362)
- Loading branch information
Showing
61 changed files
with
1,279 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export interface LogsOsqueryAction { | ||
'@timestamp': string; | ||
action_id: string; | ||
alert_ids: string[]; | ||
expiration: string; | ||
input_type: 'osquery'; | ||
queries: Array<{ | ||
action_id: string; | ||
id: string; | ||
query: string; | ||
agents: string[]; | ||
ecs_mapping?: unknown; | ||
version?: string; | ||
platform?: string; | ||
saved_query_id?: string; | ||
expiration?: string; | ||
}>; | ||
type: 'INPUT_ACTION'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/osquery/public/routes/components/empty_prompt.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiCode, EuiEmptyPrompt } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { PERMISSION_DENIED } from '../../shared_components/osquery_action/translations'; | ||
|
||
const EmptyPromptComponent = () => ( | ||
<EuiEmptyPrompt | ||
iconType="logoOsquery" | ||
title={<h2>{PERMISSION_DENIED}</h2>} | ||
titleSize="xs" | ||
body={ | ||
<FormattedMessage | ||
id="xpack.osquery.results.permissionDenied" | ||
defaultMessage="To access these results, ask your administrator for {osquery} Kibana | ||
privileges." | ||
// eslint-disable-next-line react-perf/jsx-no-new-object-as-prop | ||
values={{ | ||
osquery: <EuiCode>osquery</EuiCode>, | ||
}} | ||
/> | ||
} | ||
/> | ||
); | ||
|
||
export const EmptyPrompt = React.memo(EmptyPromptComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/osquery/public/shared_components/lazy_osquery_result.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { lazy, Suspense } from 'react'; | ||
import type { OsqueryActionResultProps } from './osquery_results/types'; | ||
import type { StartServices } from '../types'; | ||
|
||
interface BigServices extends StartServices { | ||
kibanaVersion: string; | ||
storage: unknown; | ||
} | ||
|
||
const OsqueryResult = lazy(() => import('./osquery_results/osquery_result_wrapper')); | ||
|
||
export const getLazyOsqueryResult = | ||
// eslint-disable-next-line react/display-name | ||
(services: BigServices) => (props: OsqueryActionResultProps) => | ||
( | ||
<Suspense fallback={null}> | ||
<OsqueryResult services={services} {...props} /> | ||
</Suspense> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
x-pack/plugins/osquery/public/shared_components/osquery_results/osquery_result_wrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiComment, EuiErrorBoundary, EuiSpacer } from '@elastic/eui'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { FormattedRelative } from '@kbn/i18n-react'; | ||
|
||
import type { CoreStart } from '@kbn/core-lifecycle-browser'; | ||
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; | ||
import { QueryClientProvider } from '@tanstack/react-query'; | ||
import { EmptyPrompt } from '../../routes/components/empty_prompt'; | ||
import { useKibana } from '../../common/lib/kibana'; | ||
import type { StartPlugins } from '../../types'; | ||
import { queryClient } from '../../query_client'; | ||
import { AlertAttachmentContext } from '../../common/contexts'; | ||
import { PackQueriesStatusTable } from '../../live_queries/form/pack_queries_status_table'; | ||
import { ATTACHED_QUERY } from '../../agents/translations'; | ||
import { useLiveQueryDetails } from '../../actions/use_live_query_details'; | ||
import type { OsqueryActionResultProps } from './types'; | ||
|
||
const OsqueryResultComponent = React.memo<OsqueryActionResultProps>( | ||
({ actionId, ruleName, startDate, ecsData }) => { | ||
const { read } = useKibana().services.application.capabilities.osquery; | ||
|
||
const [isLive, setIsLive] = useState(false); | ||
const { data } = useLiveQueryDetails({ | ||
actionId, | ||
isLive, | ||
skip: !read, | ||
}); | ||
|
||
useEffect(() => { | ||
setIsLive(() => !(data?.status === 'completed')); | ||
}, [data?.status]); | ||
|
||
return ( | ||
<AlertAttachmentContext.Provider value={ecsData}> | ||
<EuiSpacer size="s" /> | ||
<EuiComment | ||
username={ruleName && ruleName[0]} | ||
timestamp={<FormattedRelative value={startDate} />} | ||
event={ATTACHED_QUERY} | ||
data-test-subj={'osquery-results-comment'} | ||
> | ||
{!read ? ( | ||
<EmptyPrompt /> | ||
) : ( | ||
<PackQueriesStatusTable | ||
actionId={actionId} | ||
data={data?.queries} | ||
startDate={data?.['@timestamp']} | ||
expirationDate={data?.expiration} | ||
agentIds={data?.agents} | ||
/> | ||
)} | ||
</EuiComment> | ||
<EuiSpacer size="s" /> | ||
</AlertAttachmentContext.Provider> | ||
); | ||
} | ||
); | ||
|
||
export const OsqueryActionResult = React.memo(OsqueryResultComponent); | ||
type OsqueryActionResultsWrapperProps = { | ||
services: CoreStart & StartPlugins; | ||
} & OsqueryActionResultProps; | ||
|
||
const OsqueryActionResultWrapperComponent: React.FC<OsqueryActionResultsWrapperProps> = ({ | ||
services, | ||
...restProps | ||
}) => ( | ||
<KibanaThemeProvider theme$={services.theme.theme$}> | ||
<KibanaContextProvider services={services}> | ||
<EuiErrorBoundary> | ||
<QueryClientProvider client={queryClient}> | ||
<OsqueryActionResult {...restProps} /> | ||
</QueryClientProvider> | ||
</EuiErrorBoundary> | ||
</KibanaContextProvider> | ||
</KibanaThemeProvider> | ||
); | ||
|
||
const OsqueryActionResultWrapper = React.memo(OsqueryActionResultWrapperComponent); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export { OsqueryActionResultWrapper as default }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.