Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vulnerabilities dashboards] Add global vulnerabilities dashboards #5896

Merged
merged 22 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
37b42a2
Added plugins dependencies
Machi3mfl Sep 18, 2023
9a2ff52
Add new inventories tabs scaffolding
Machi3mfl Sep 18, 2023
5d5333d
Refactor arquitecture
Machi3mfl Sep 27, 2023
350d7f7
Add searchbar folder
Machi3mfl Sep 27, 2023
2ccf4cf
Add useDashboardConfiguration hook for configuring vulnerability dash…
jbiset Sep 29, 2023
8b76f24
[Vulnerabilities dashboards] Add search bar services (#5960)
Machi3mfl Sep 29, 2023
4bacf97
[Vulnerabilities dashboards] Fix wrong agent.id filters loaded in sea…
Machi3mfl Oct 5, 2023
f083c95
Change new vulnerabilities inventory table (#6047)
Machi3mfl Oct 25, 2023
d78defc
Feat/5894 vulnerabilities dashboard create the dashboard tab using os…
jbiset Oct 25, 2023
fcf1e78
Fix default filters on usesearchbar configuration
jbiset Oct 25, 2023
73cd071
[Vulnerabilities dashboards] Fix vulnerability dashboard filters (#6065)
jbiset Oct 27, 2023
68686f0
Remove date picker from searchbar on vuls inventory tab
Machi3mfl Oct 30, 2023
f583dd3
Remove date picker from searchbar and open vs close visualization on …
jbiset Oct 30, 2023
1267640
Change Accumulation of the most detected vulnerabilities chart
jbiset Oct 31, 2023
457917a
Add data grid csv export
Machi3mfl Oct 31, 2023
edb04e2
Add error management and export csv calls pagination
Machi3mfl Nov 1, 2023
2c91837
Merge branch '4.8.0' into feat/5763-global-vulnerabilities-dashboard
Machi3mfl Nov 1, 2023
d95a4bc
Merge branch '4.8.0' into feat/5763-global-vulnerabilities-dashboard
Machi3mfl Nov 2, 2023
09d3a84
Remove unused hook
Machi3mfl Nov 2, 2023
194e065
Update CHANGELOG
Machi3mfl Nov 2, 2023
ec01296
Fix CHANGELOG
Machi3mfl Nov 2, 2023
8cb2210
Remove explore agent in header
Machi3mfl Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Support for Wazuh 4.8.0
- Added remember server address check [#5791](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5791)
- Added the ssl_agent_ca configuration to the SSL Settings form [#6083](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6083)
- Added global vulnerabilities dashboards [#5896](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5896)

## Wazuh v4.7.1 - OpenSearch Dashboards 2.8.0 - Revision 00

Expand Down
2 changes: 2 additions & 0 deletions plugins/main/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"requiredPlugins": [
"navigation",
"data",
"dashboard",
"embeddable",
"discover",
"inspector",
"visualizations",
Expand Down
35 changes: 24 additions & 11 deletions plugins/main/public/components/common/hooks/use-filter-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,36 @@
*/
import { getDataPlugin } from '../../../kibana-services';
import { useState, useEffect, useMemo } from 'react';
import { Filter } from 'src/plugins/data/public';
import { Filter } from '../../../../../../src/plugins/data/public';
import _ from 'lodash';
import { FilterManager } from '../../../../../../src/plugins/data/public';
import { Subscription } from 'rxjs';

export const useFilterManager = () => {
const filterManager = useMemo(() => getDataPlugin().query.filterManager, []);
type tUseFilterManagerReturn = {
filterManager: FilterManager;
filters: Filter[];
};

export const useFilterManager = (): tUseFilterManagerReturn => {
const filterManager = getDataPlugin().query.filterManager;
const [filters, setFilters] = useState<Filter[]>(filterManager.getFilters());

useEffect(() => {
const subscription = filterManager.getUpdates$().subscribe(() => {
const newFilters = filterManager.getFilters();
if (!_.isEqual(filters, newFilters)) {
setFilters(newFilters);
}
});
const subscriptions = new Subscription();

subscriptions.add(
filterManager.getUpdates$().subscribe({
next: () => {
const newFilters = filterManager.getFilters();
setFilters(newFilters);
},
})
);

return () => {
subscription.unsubscribe();
subscriptions.unsubscribe();
};
}, []);
}, [filterManager]);

return { filterManager, filters };
};
15 changes: 10 additions & 5 deletions plugins/main/public/components/common/modules/modules-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import ButtonModuleExploreAgent from '../../../controllers/overview/components/o
import { ButtonModuleGenerateReport } from '../modules/buttons';
import { OfficePanel } from '../../overview/office-panel';
import { GitHubPanel } from '../../overview/github-panel';
import { withModuleNotForAgent } from '../hocs';
import { DashboardVuls, InventoryVuls } from '../../overview/vulnerabilities'
import { withModuleNotForAgent, withModuleTabLoader } from '../hocs';

const DashboardTab = {
id: 'dashboard',
Expand Down Expand Up @@ -130,18 +131,22 @@ export const ModulesDefaults = {
availableFor: ['manager', 'agent'],
},
vuls: {
init: 'inventory',
init: 'dashboard',
tabs: [
{
id: 'dashboard',
name: 'Dashboard',
component: withModuleNotForAgent(DashboardVuls),
},
{
id: 'inventory',
name: 'Inventory',
buttons: [ButtonModuleExploreAgent],
component: MainVuls,
component: withModuleNotForAgent(InventoryVuls),
},
EventsTab,
],
buttons: ['settings'],
availableFor: ['manager', 'agent'],
availableFor: ['manager'],
},
mitre: {
init: 'dashboard',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.discoverNoResults {
display: flex;
align-items: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import './loading_spinner.scss';
import React from 'react';
import { EuiTitle, EuiPanel, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui';
import { FormattedMessage } from '@osd/i18n/react';

export function LoadingSpinner() {
return (
<EuiPanel hasBorder={false} hasShadow={false} color="transparent" className="discoverNoResults">
<EuiEmptyPrompt
icon={<EuiLoadingSpinner data-test-subj="loadingSpinner" size="xl" />}
title={
<EuiTitle size="s" data-test-subj="loadingSpinnerText">
<h2>
<FormattedMessage id="discover.searchingTitle" defaultMessage="Searching" />
</h2>
</EuiTitle>
}
/>
</EuiPanel>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { Fragment } from 'react';
import { FormattedMessage, I18nProvider } from '@osd/i18n/react';

import {
EuiCallOut,
EuiCode,
EuiDescriptionList,
EuiLink,
EuiPanel,
EuiSpacer,
EuiText,
} from '@elastic/eui';

interface Props {
timeFieldName?: string;
queryLanguage?: string;
}

export const DiscoverNoResults = ({ timeFieldName, queryLanguage }: Props) => {
let timeFieldMessage;

if (timeFieldName) {
timeFieldMessage = (
<Fragment>
<EuiSpacer size="xl" />

<EuiText>
<h2 data-test-subj="discoverNoResultsTimefilter">
<FormattedMessage
id="discover.noResults.expandYourTimeRangeTitle"
defaultMessage="Expand your time range"
/>
</h2>

<p>
<FormattedMessage
id="discover.noResults.queryMayNotMatchTitle"
defaultMessage="One or more of the indices you&rsquo;re looking at contains a date field. Your query may
not match anything in the current time range, or there may not be any data at all in
the currently selected time range. You can try changing the time range to one which contains data."
/>
</p>
</EuiText>
</Fragment>
);
}

let luceneQueryMessage;

if (queryLanguage === 'lucene') {
const searchExamples = [
{
description: <EuiCode>200</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.anyField200StatusCodeExampleTitle"
defaultMessage="Find requests that contain the number 200, in any field"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:200</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.statusField200StatusCodeExampleTitle"
defaultMessage="Find 200 in the status field"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499]</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeExampleTitle"
defaultMessage="Find all status codes between 400-499"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499] AND extension:PHP</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeWithPhpExtensionExampleTitle"
defaultMessage="Find status codes 400-499 with the extension php"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499] AND (extension:php OR extension:html)</EuiCode>,
title: (
<EuiText>
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeWithPhpOrHtmlExtensionExampleTitle"
defaultMessage="Find status codes 400-499 with the extension php or html"
/>
</strong>
</EuiText>
),
},
];

luceneQueryMessage = (
<Fragment>
<EuiSpacer size="xl" />

<EuiText>
<h3>
<FormattedMessage
id="discover.noResults.searchExamples.refineYourQueryTitle"
defaultMessage="Refine your query"
/>
</h3>

<p>
<FormattedMessage
id="discover.noResults.searchExamples.howTosearchForWebServerLogsDescription"
defaultMessage="The search bar at the top uses OpenSearch&rsquo;s support for Lucene {queryStringSyntaxLink}.
Here are some examples of how you can search for web server logs that have been parsed into a few fields."
/>
</p>
</EuiText>

<EuiSpacer size="m" />

<EuiDescriptionList type="column" listItems={searchExamples} />

<EuiSpacer size="xl" />
</Fragment>
);
}

return (
<I18nProvider>
<EuiPanel hasBorder={false} hasShadow={false} color="transparent">
<EuiCallOut
title={
<FormattedMessage
id="discover.noResults.searchExamples.noResultsMatchSearchCriteriaTitle"
defaultMessage="No results match your search criteria"
/>
}
color="warning"
iconType="help"
data-test-subj="discoverNoResults"
/>
{timeFieldMessage}
{luceneQueryMessage}
</EuiPanel>
</I18nProvider>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VULNERABILITIES_INDEX_PATTERN_ID = 'wazuh-states-vulnerabilities';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './overview';
export * from './inventory';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { EuiDataGridColumn } from "@elastic/eui";

export const inventoryTableDefaultColumns: EuiDataGridColumn[] = [
{
id: 'package.name',
},
{
id: 'package.version',
},
{
id: 'package.architecture',
},
{
id: 'vulnerability.severity',
},
{
id: 'vulnerability.id',
},
{
id: 'vulnerability.score.version',
},
{
id: 'vulnerability.score.base',
},
{
id: 'event.created',
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './inventory';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.vulsInventoryContainer {
height: calc(100vh - 104px);
}


.headerIsExpanded .vulsInventoryContainer {
height: calc(100vh - 153px);
}

.vulsInventoryContainer .euiDataGrid--fullScreen {
height: calc(100vh - 49px);
bottom: 0;
top: auto;
}
Loading