Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '4.9.0' into 6478-remove-discover-implement-embeddable-d…
…ashboard-on-threat-hunting-module
- Loading branch information
Showing
11 changed files
with
1,509 additions
and
5 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
24 changes: 24 additions & 0 deletions
24
...ents/common/data-source/pattern/alerts/alerts-virustotal/alerts-virustotal-data-source.ts
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,24 @@ | ||
import { tFilter } from '../../../index'; | ||
import { DATA_SOURCE_FILTER_CONTROLLED_VIRUSTOTAL_RULE_GROUP } from '../../../../../../../common/constants'; | ||
import { AlertsDataSource } from '../alerts-data-source'; | ||
|
||
const VIRUSTOTAL_GROUP_KEY = 'rule.groups'; | ||
const VIRUSTOTAL_GROUP_VALUE = 'virustotal'; | ||
|
||
export class AlertsVirustotalDataSource extends AlertsDataSource { | ||
constructor(id: string, title: string) { | ||
super(id, title); | ||
} | ||
|
||
getRuleGroupsFilter() { | ||
return super.getRuleGroupsFilter( | ||
VIRUSTOTAL_GROUP_KEY, | ||
VIRUSTOTAL_GROUP_VALUE, | ||
DATA_SOURCE_FILTER_CONTROLLED_VIRUSTOTAL_RULE_GROUP, | ||
); | ||
} | ||
|
||
getFixedFilters(): tFilter[] { | ||
return [...this.getRuleGroupsFilter(), ...super.getFixedFilters()]; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
plugins/main/public/components/common/data-source/pattern/alerts/alerts-virustotal/index.ts
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 @@ | ||
export * from './alerts-virustotal-data-source'; |
3 changes: 2 additions & 1 deletion
3
plugins/main/public/components/common/data-source/pattern/alerts/index.ts
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './alerts-vulnerabilities'; | ||
export * from './alerts-data-source-repository'; | ||
export * from './alerts-data-source'; | ||
export * from './alerts-data-source'; | ||
export * from './alerts-virustotal'; |
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
163 changes: 163 additions & 0 deletions
163
plugins/main/public/components/overview/virustotal/dashboard/dashboard.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,163 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { getPlugins } from '../../../../kibana-services'; | ||
import { ViewMode } from '../../../../../../../src/plugins/embeddable/public'; | ||
import { SearchResponse } from '../../../../../../../src/core/server'; | ||
import { IndexPattern } from '../../../../../../../src/plugins/data/common'; | ||
import { getDashboardPanels } from './dashboard_panels'; | ||
import { I18nProvider } from '@osd/i18n/react'; | ||
import useSearchBar from '../../../common/search-bar/use-search-bar'; | ||
import { getKPIsPanel } from './dashboard_panels_kpis'; | ||
import { | ||
ErrorFactory, | ||
ErrorHandler, | ||
HttpError, | ||
} from '../../../../react-services/error-management'; | ||
import { withErrorBoundary } from '../../../common/hocs/error-boundary/with-error-boundary'; | ||
import { SampleDataWarning } from '../../../visualize/components/sample-data-warning'; | ||
import { | ||
AlertsDataSourceRepository, | ||
PatternDataSource, | ||
tParsedIndexPattern, | ||
useDataSource, | ||
} from '../../../common/data-source'; | ||
import { LoadingSpinner } from '../../../common/loading-spinner/loading-spinner'; | ||
import { DiscoverNoResults } from '../../../common/no-results/no-results'; | ||
import { AlertsVirustotalDataSource } from '../../../common/data-source/pattern/alerts/alerts-virustotal/alerts-virustotal-data-source'; | ||
import './virustotal_dashboard.scss'; | ||
|
||
const plugins = getPlugins(); | ||
|
||
const SearchBar = getPlugins().data.ui.SearchBar; | ||
|
||
const DashboardByRenderer = plugins.dashboard.DashboardContainerByValueRenderer; | ||
const DashboardVT: React.FC = () => { | ||
const { | ||
filters, | ||
dataSource, | ||
fetchFilters, | ||
isLoading: isDataSourceLoading, | ||
fetchData, | ||
setFilters, | ||
} = useDataSource<tParsedIndexPattern, PatternDataSource>({ | ||
DataSource: AlertsVirustotalDataSource, | ||
repository: new AlertsDataSourceRepository(), | ||
}); | ||
|
||
const [results, setResults] = useState<SearchResponse>({} as SearchResponse); | ||
|
||
const { searchBarProps } = useSearchBar({ | ||
indexPattern: dataSource?.indexPattern as IndexPattern, | ||
filters, | ||
setFilters, | ||
}); | ||
const { query, dateRangeFrom, dateRangeTo } = searchBarProps; | ||
|
||
useEffect(() => { | ||
if (isDataSourceLoading) { | ||
return; | ||
} | ||
fetchData({ | ||
query, | ||
dateRange: { | ||
from: dateRangeFrom, | ||
to: dateRangeTo, | ||
}, | ||
}) | ||
.then(results => { | ||
setResults(results); | ||
}) | ||
.catch(error => { | ||
const searchError = ErrorFactory.create(HttpError, { | ||
error, | ||
message: 'Error fetching alerts', | ||
}); | ||
ErrorHandler.handleError(searchError); | ||
}); | ||
}, [ | ||
isDataSourceLoading, | ||
JSON.stringify(fetchFilters), | ||
JSON.stringify(query), | ||
dateRangeFrom, | ||
dateRangeTo, | ||
]); | ||
|
||
return ( | ||
<I18nProvider> | ||
<> | ||
{isDataSourceLoading && !dataSource ? ( | ||
<LoadingSpinner /> | ||
) : ( | ||
<div className='wz-search-bar hide-filter-control'> | ||
<SearchBar | ||
appName='virustotal-searchbar' | ||
{...searchBarProps} | ||
showDatePicker={true} | ||
showQueryInput={true} | ||
showQueryBar={true} | ||
showSaveQuery={true} | ||
/> | ||
</div> | ||
)} | ||
{!isDataSourceLoading && dataSource && results?.hits?.total > 0 ? ( | ||
<SampleDataWarning /> | ||
) : null} | ||
{dataSource && results?.hits?.total === 0 ? ( | ||
<DiscoverNoResults /> | ||
) : null} | ||
{!isDataSourceLoading && dataSource && results?.hits?.total > 0 ? ( | ||
<div className='virustotal-dashboard-responsive'> | ||
<DashboardByRenderer | ||
input={{ | ||
viewMode: ViewMode.VIEW, | ||
panels: getKPIsPanel(dataSource?.id), | ||
isFullScreenMode: false, | ||
filters: fetchFilters ?? [], | ||
useMargins: true, | ||
id: 'kpis-virustotal-dashboard-tab', | ||
timeRange: { | ||
from: dateRangeFrom, | ||
to: dateRangeTo, | ||
}, | ||
title: 'KPIs Virustotal dashboard', | ||
description: 'KPIs Dashboard of the Virustotal', | ||
query: query, | ||
refreshConfig: { | ||
pause: false, | ||
value: 15, | ||
}, | ||
hidePanelTitles: true, | ||
}} | ||
/> | ||
<DashboardByRenderer | ||
input={{ | ||
viewMode: ViewMode.VIEW, | ||
panels: getDashboardPanels( | ||
dataSource?.id, | ||
dataSource.getPinnedAgentFilter().length > 0, | ||
), | ||
isFullScreenMode: false, | ||
filters: fetchFilters ?? [], | ||
useMargins: true, | ||
id: 'virustotal-dashboard-tab', | ||
timeRange: { | ||
from: dateRangeFrom, | ||
to: dateRangeTo, | ||
}, | ||
title: 'Virustotal dashboard', | ||
description: 'Dashboard of the Virustotal', | ||
query: query, | ||
refreshConfig: { | ||
pause: false, | ||
value: 15, | ||
}, | ||
hidePanelTitles: false, | ||
}} | ||
/> | ||
</div> | ||
) : null} | ||
</> | ||
</I18nProvider> | ||
); | ||
}; | ||
|
||
export const DashboardVirustotal = withErrorBoundary(DashboardVT); |
Oops, something went wrong.