From cff912ee1b305f342212118a04785a804347ba45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Thu, 5 Sep 2024 12:46:57 +0200 Subject: [PATCH 01/15] chore: rename use-data-grid.ts file --- .../common/data-grid/{use-data-grid.ts => use-data-grid.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/main/public/components/common/data-grid/{use-data-grid.ts => use-data-grid.tsx} (100%) diff --git a/plugins/main/public/components/common/data-grid/use-data-grid.ts b/plugins/main/public/components/common/data-grid/use-data-grid.tsx similarity index 100% rename from plugins/main/public/components/common/data-grid/use-data-grid.ts rename to plugins/main/public/components/common/data-grid/use-data-grid.tsx From 13059bcc87d7c1fc73720dc37870ab30d7805b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Thu, 5 Sep 2024 12:58:17 +0200 Subject: [PATCH 02/15] fix: use the field formatter to render the fields in the WzDataGrid --- .../components/common/data-grid/use-data-grid.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/main/public/components/common/data-grid/use-data-grid.tsx b/plugins/main/public/components/common/data-grid/use-data-grid.tsx index ab0235bedf..3d41fc3e5c 100644 --- a/plugins/main/public/components/common/data-grid/use-data-grid.tsx +++ b/plugins/main/public/components/common/data-grid/use-data-grid.tsx @@ -13,6 +13,7 @@ import { parseColumns, } from './data-grid-service'; import { IndexPattern } from '../../../../../../src/plugins/data/common'; +import dompurify from 'dompurify'; const MAX_ENTRIES_PER_QUERY = 10000; const DEFAULT_PAGE_SIZE_OPTIONS = [20, 50, 100]; @@ -129,7 +130,18 @@ export const useDataGrid = (props: tDataGridProps): EuiDataGridProps => { ); } - return fieldFormatted; + // Format the value using the field formatter + // https://github.com/opensearch-project/OpenSearch-Dashboards/blob/2.16.0/src/plugins/discover/public/application/components/data_grid/data_grid_table_cell_value.tsx#L80-L89 + const formattedValue = indexPattern.formatField(rows[rowIndex], columnId); + if (typeof formattedValue === 'undefined') { + return -; + } else { + const sanitizedCellValue = dompurify.sanitize(formattedValue); + return ( + // eslint-disable-next-line react/no-danger + + ); + } } return null; }; From 97a3374a5032abc37690190c2dc458f948ce10ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Thu, 5 Sep 2024 13:00:48 +0200 Subject: [PATCH 03/15] feat: add the wazuh.vulnerability.under_evaluation field to the vulnerabilities sample data tool --- .../vulnerabilities-events-injector/DIS_Template.json | 9 ++++++++- .../vulnerabilities-events-injector/dataInjectScript.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/vulnerabilities-events-injector/DIS_Template.json b/scripts/vulnerabilities-events-injector/DIS_Template.json index 14d6167f1d..75a723b057 100644 --- a/scripts/vulnerabilities-events-injector/DIS_Template.json +++ b/scripts/vulnerabilities-events-injector/DIS_Template.json @@ -257,6 +257,13 @@ "type": "keyword" } } + }, + "vulnerability": { + "properties": { + "under_evaluation": { + "type": "boolean" + } + } } } } @@ -273,4 +280,4 @@ "refresh_interval": "2s" } } -} \ No newline at end of file +} diff --git a/scripts/vulnerabilities-events-injector/dataInjectScript.py b/scripts/vulnerabilities-events-injector/dataInjectScript.py index a15e5a761d..d919f913ae 100644 --- a/scripts/vulnerabilities-events-injector/dataInjectScript.py +++ b/scripts/vulnerabilities-events-injector/dataInjectScript.py @@ -122,6 +122,7 @@ def generateRandomVulnerability(): def generateRandomWazuh(): wazuh = {} wazuh['cluster'] = {'name':random.choice(['wazuh.manager', 'wazuh']), 'node':random.choice(['master','worker-01','worker-02','worker-03'])} + wazuh['vulnerability'] = {'under_evaluation': random.choice([True, False])} return(wazuh) def generateRandomData(number): From 60f802a8f0e456e4af67137c60be1d9570c81837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Thu, 5 Sep 2024 13:02:10 +0200 Subject: [PATCH 04/15] feat(vulnerabilities): add visualization related to evaluation status to the dashboard --- .../overview/dashboard_panels_kpis.ts | 116 ++++++++++++++++-- 1 file changed, 109 insertions(+), 7 deletions(-) diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts index c2d213b401..8b27b7fd41 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts @@ -341,6 +341,94 @@ const getVisStateSeverityLow = (indexPatternId: string) => { }; }; +const getVisStateEvaluatedEvaluationPending = (indexPatternId: string) => { + return { + id: 'vulnerabilities_evaluation_count', + title: 'Evalution', + type: 'metric', + params: { + addLegend: false, + addTooltip: true, + metric: { + colorSchema: 'Green to Red', + colorsRange: [ + { + from: 0, + to: 10000, + }, + ], + invertColors: false, + labels: { + show: true, + }, + metricColorMode: 'None', + percentageMode: false, + style: { + bgColor: false, + bgFill: '#000', + fontSize: 50, + labelColor: false, + subText: '', + }, + useRanges: false, + }, + type: 'metric', + }, + data: { + searchSource: { + query: { + language: 'kuery', + query: '', + }, + filter: [], + index: indexPatternId, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: indexPatternId, + }, + ], + aggs: [ + { + id: '1', + enabled: true, + type: 'count', + params: { + customLabel: 'Evaluation', + }, + schema: 'metric', + }, + { + id: '2', + enabled: true, + type: 'filters', + params: { + filters: [ + { + input: { + language: 'kuery', + query: 'wazuh.vulnerability.under_evaluation:false', + }, + label: 'Evaluated', + }, + { + input: { + language: 'kuery', + query: 'wazuh.vulnerability.under_evaluation:true', + }, + label: 'Pending', + }, + ], + }, + schema: 'group', + }, + ], + }, + }; +}; + export const getKPIsPanel = ( indexPatternId: string, ): { @@ -351,7 +439,7 @@ export const getKPIsPanel = ( return { '1': { gridData: { - w: 12, + w: 8, h: 6, x: 0, y: 0, @@ -365,9 +453,9 @@ export const getKPIsPanel = ( }, '2': { gridData: { - w: 12, + w: 8, h: 6, - x: 12, + x: 8, y: 0, i: '2', }, @@ -379,9 +467,9 @@ export const getKPIsPanel = ( }, '3': { gridData: { - w: 12, + w: 8, h: 6, - x: 24, + x: 16, y: 0, i: '3', }, @@ -393,9 +481,9 @@ export const getKPIsPanel = ( }, '4': { gridData: { - w: 12, + w: 8, h: 6, - x: 36, + x: 24, y: 0, i: '4', }, @@ -405,5 +493,19 @@ export const getKPIsPanel = ( savedVis: getVisStateSeverityLow(indexPatternId), }, }, + '5': { + gridData: { + w: 16, + h: 6, + x: 32, + y: 0, + i: '5', + }, + type: 'visualization', + explicitInput: { + id: '5', + savedVis: getVisStateEvaluatedEvaluationPending(indexPatternId), + }, + }, }; }; From fcc6d68fb9fd3f9fb815a0b0f7bfb94d33091b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Thu, 5 Sep 2024 13:10:43 +0200 Subject: [PATCH 05/15] changelog: add entry --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb56195b56..7948cdf443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ All notable changes to the Wazuh app project will be documented in this file. ### Added - Support for Wazuh 4.10.0 +- Added a visulization to Vulnerabilities Detection dashboard related to evalution status count [#6968](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6968) + +### Fixed + +- Fixed some fields were not rendering correctly or not using the field format in some tables [#6968](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6968) ### Changed From d4f70c8e3bfdc0bb7f35621c04ae3ff24195c042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Thu, 5 Sep 2024 13:13:05 +0200 Subject: [PATCH 06/15] fix(changelog): rephrase --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7948cdf443..a845cf6675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ All notable changes to the Wazuh app project will be documented in this file. ### Fixed -- Fixed some fields were not rendering correctly or not using the field format in some tables [#6968](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6968) +- Fixed some fields were not correctly rendering or not using the field format in some tables [#6968](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6968) ### Changed From df9500e46f1474c2df24523c7912660e7b25da7e Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Tue, 17 Sep 2024 20:17:28 +0200 Subject: [PATCH 07/15] Change visualization to only pending --- .../overview/dashboard_panels_kpis.ts | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts index 8b27b7fd41..06e49f7fcc 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts @@ -34,7 +34,7 @@ const getVisStateSeverityCritical = (indexPatternId: string) => { bgColor: false, labelColor: false, subText: '', - fontSize: 50, + fontSize: 40, }, }, }, @@ -119,7 +119,7 @@ const getVisStateSeverityHigh = (indexPatternId: string) => { bgColor: false, labelColor: false, subText: '', - fontSize: 50, + fontSize: 40, }, }, }, @@ -204,7 +204,7 @@ const getVisStateSeverityMedium = (indexPatternId: string) => { bgColor: false, labelColor: false, subText: '', - fontSize: 50, + fontSize: 40, }, }, }, @@ -289,7 +289,7 @@ const getVisStateSeverityLow = (indexPatternId: string) => { bgColor: false, labelColor: false, subText: '', - fontSize: 50, + fontSize: 40, }, }, }, @@ -344,7 +344,7 @@ const getVisStateSeverityLow = (indexPatternId: string) => { const getVisStateEvaluatedEvaluationPending = (indexPatternId: string) => { return { id: 'vulnerabilities_evaluation_count', - title: 'Evalution', + title: 'Evaluation', type: 'metric', params: { addLegend: false, @@ -366,7 +366,7 @@ const getVisStateEvaluatedEvaluationPending = (indexPatternId: string) => { style: { bgColor: false, bgFill: '#000', - fontSize: 50, + fontSize: 40, labelColor: false, subText: '', }, @@ -406,13 +406,6 @@ const getVisStateEvaluatedEvaluationPending = (indexPatternId: string) => { type: 'filters', params: { filters: [ - { - input: { - language: 'kuery', - query: 'wazuh.vulnerability.under_evaluation:false', - }, - label: 'Evaluated', - }, { input: { language: 'kuery', @@ -439,7 +432,7 @@ export const getKPIsPanel = ( return { '1': { gridData: { - w: 8, + w: 9, h: 6, x: 0, y: 0, @@ -453,9 +446,9 @@ export const getKPIsPanel = ( }, '2': { gridData: { - w: 8, + w: 9, h: 6, - x: 8, + x: 9, y: 0, i: '2', }, @@ -467,9 +460,9 @@ export const getKPIsPanel = ( }, '3': { gridData: { - w: 8, + w: 9, h: 6, - x: 16, + x: 18, y: 0, i: '3', }, @@ -481,9 +474,9 @@ export const getKPIsPanel = ( }, '4': { gridData: { - w: 8, + w: 9, h: 6, - x: 24, + x: 27, y: 0, i: '4', }, @@ -495,9 +488,9 @@ export const getKPIsPanel = ( }, '5': { gridData: { - w: 16, + w: 12, h: 6, - x: 32, + x: 36, y: 0, i: '5', }, From 1b41d51c12222867876d53d6e1d6780e620fb9d2 Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Thu, 26 Sep 2024 12:58:04 -0300 Subject: [PATCH 08/15] Add post fixed filter place to render components --- .../components/common/search-bar/search-bar.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/main/public/components/common/search-bar/search-bar.tsx b/plugins/main/public/components/common/search-bar/search-bar.tsx index 4dd1a6c8d4..5e64d164ab 100644 --- a/plugins/main/public/components/common/search-bar/search-bar.tsx +++ b/plugins/main/public/components/common/search-bar/search-bar.tsx @@ -12,11 +12,13 @@ export interface WzSearchBarProps extends SearchBarProps { userFilters?: Filter[]; preQueryBar?: React.ReactElement; postFilters?: React.ReactElement; + postFixedFilters?: () => React.ReactElement[]; hideFixedFilters?: boolean; } export const WzSearchBar = ({ fixedFilters = [], + postFixedFilters, preQueryBar, hideFixedFilters, postFilters, @@ -65,14 +67,18 @@ export const WzSearchBar = ({ {fixedFilters?.map((filter, idx) => ( - {`${filter.meta.key}: ${ - typeof filter.meta.value === 'function' - ? filter.meta.value() - : filter.meta.value - }`} + {`${filter.meta.key}: ${typeof filter.meta.value === 'function' + ? filter.meta.value() + : filter.meta.value + }`} ))} + {postFixedFilters ? postFixedFilters.map((Filter, idx) => ( + + + + )) : null} )} From 9d1359c3486b1b37e69260572724f45d3fa6a26c Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Thu, 26 Sep 2024 12:58:38 -0300 Subject: [PATCH 09/15] Add under evaluation filter component --- .../common/data-grid/use-data-grid.tsx | 1 + .../pattern-data-source-filter-manager.ts | 2 +- .../components/vuls-evaluation-filter.tsx | 92 +++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx diff --git a/plugins/main/public/components/common/data-grid/use-data-grid.tsx b/plugins/main/public/components/common/data-grid/use-data-grid.tsx index efa7996301..b641541f0b 100644 --- a/plugins/main/public/components/common/data-grid/use-data-grid.tsx +++ b/plugins/main/public/components/common/data-grid/use-data-grid.tsx @@ -17,6 +17,7 @@ import { IndexPattern, } from '../../../../../../src/plugins/data/common'; import { EuiDataGridPaginationProps } from '@opensearch-project/oui'; +import dompurify from 'dompurify'; export interface PaginationOptions extends Pick< diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts index f26282ad85..e763c93629 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts @@ -325,7 +325,7 @@ export class PatternDataSourceFilterManager static createFilter( type: FILTER_OPERATOR, key: string, - value: string | string[], + value: string | string[] | any, indexPatternId: string, controlledBy?: string, ) { diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx new file mode 100644 index 0000000000..b72193fbe2 --- /dev/null +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx @@ -0,0 +1,92 @@ +import React, { useState, useEffect } from "react"; +import { EuiButtonGroup } from "@elastic/eui" +import { FILTER_OPERATOR, PatternDataSourceFilterManager } from "../../../../common/data-source"; +import { Filter } from "../../../../../../../../src/plugins/data/common"; + +type VulsEvaluatedFilterProps = { + setValue: (underEvaluation: boolean | null) => void; + value: boolean | null; +} + +const UNDER_EVALUATION_FIELD = "wazuh.vulnerability.under_evaluation"; + +export const getUnderEvaluationFilterValue = (filters: Filter[]): boolean | null => { + const underEvaluationFilter = filters.find(f => f.meta?.key === UNDER_EVALUATION_FIELD); + if (underEvaluationFilter) { + return underEvaluationFilter.meta?.params.query as boolean; + } + return null; +} + +export const excludeUnderEvaluationFilter = (filters: Filter[]): Filter[] => { + return filters.filter(f => f.meta?.key !== UNDER_EVALUATION_FIELD); +} + +export const createUnderEvaluationFilter = (underEvaluation: boolean, indexPatternId: string): Filter => { + return PatternDataSourceFilterManager.createFilter( + FILTER_OPERATOR.IS, + UNDER_EVALUATION_FIELD, + underEvaluation, + indexPatternId + ) +} + +const VulsEvaluationFilter = ({ setValue, value }: VulsEvaluatedFilterProps) => { + + const toggleButtons = [ + { + id: 'evaluated', + label: 'Evaluated', + }, + { + id: 'underEvaluation', + label: 'Under evaluation', + } + ]; + + const getDefaultValue = () => { + if (value === true) { + return { underEvaluation: true, evaluated: false }; + } else if (value === false) { + return { underEvaluation: false, evaluated: true }; + } else { + return {}; + } + } + + const [toggleIdToSelectedMap, setToggleIdToSelectedMap] = useState(getDefaultValue()); + + + useEffect(() => { + setToggleIdToSelectedMap(getDefaultValue()); + }, [value]); + + + const handleChange = (optionId: string) => { + let newToggleIdToSelectedMap = {}; + if (!toggleIdToSelectedMap[optionId]) { + newToggleIdToSelectedMap = { [optionId]: true }; + } + setToggleIdToSelectedMap(newToggleIdToSelectedMap); + if (optionId === "underEvaluation" && newToggleIdToSelectedMap[optionId]) { + setValue(true); + } else if (optionId === "evaluated" && newToggleIdToSelectedMap[optionId]) { + setValue(false); + } else { + setValue(null); + } + + } + + return ( + handleChange(id)} + buttonSize="compressed" + /> + ) +} + +export default VulsEvaluationFilter; \ No newline at end of file From 5774eb7c292b5db32b11e0864b921cf78369aef5 Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Thu, 26 Sep 2024 12:58:50 -0300 Subject: [PATCH 10/15] Apply under evaluation filter in vuls tabs --- .../dashboards/inventory/inventory.tsx | 57 ++++++++++++++----- .../dashboards/overview/dashboard.tsx | 40 +++++++++++-- 2 files changed, 78 insertions(+), 19 deletions(-) diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx b/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx index ecef54dd3a..3bf2c5f88b 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { IntlProvider } from 'react-intl'; import { EuiDataGrid, @@ -34,7 +34,6 @@ import { LoadingSearchbarProgress } from '../../../../../../public/components/co // common components/hooks import useSearchBar from '../../../../common/search-bar/use-search-bar'; import { useDataGrid } from '../../../../common/data-grid/use-data-grid'; -import { useDocViewer } from '../../../../common/doc-viewer/use-doc-viewer'; import { withErrorBoundary } from '../../../../common/hocs'; import { exportSearchToCSV } from '../../../../common/data-grid/data-grid-service'; import { compose } from 'redux'; @@ -51,6 +50,7 @@ import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; import { wzDiscoverRenderColumns } from '../../../../common/wazuh-discover/render-columns'; import { DocumentViewTableAndJson } from '../../../../common/wazuh-discover/components/document-view-table-and-json'; import { WzSearchBar } from '../../../../common/search-bar'; +import VulsEvaluationFilter, { createUnderEvaluationFilter, excludeUnderEvaluationFilter, getUnderEvaluationFilterValue } from '../../common/components/vuls-evaluation-filter'; const InventoryVulsComponent = () => { const { @@ -104,6 +104,11 @@ const InventoryVulsComponent = () => { ); }; + const getUnderEvaluation = useCallback(getUnderEvaluationFilterValue, [ + JSON.stringify(filters), + isDataSourceLoading + ]); + const dataGridProps = useDataGrid({ ariaLabelledBy: 'Vulnerabilities Inventory Table', defaultColumns: inventoryTableDefaultColumns, @@ -117,11 +122,6 @@ const InventoryVulsComponent = () => { const { pagination, sorting, columnVisibility } = dataGridProps; - const docViewerProps = useDocViewer({ - doc: inspectedHit, - indexPattern: indexPattern as IndexPattern, - }); - const onClickExportResults = async () => { const params = { indexPattern: indexPattern as IndexPattern, @@ -152,6 +152,7 @@ const InventoryVulsComponent = () => { if (isDataSourceLoading) { return; } + setUnderEvaluation(getUnderEvaluation(filters || [])); setIndexPattern(dataSource?.indexPattern); fetchData({ query, pagination, sorting }) .then(results => { @@ -171,6 +172,28 @@ const InventoryVulsComponent = () => { JSON.stringify(sorting), ]); + + /** + * When the user changes the filter value, this function is called to update the filters + * If the value is null, the filter is removed + * If the filter already exists, it is remove and the new filter is added + * @param underEvaluation + * @returns + */ + const handleFilterChange = (underEvaluation: boolean | null) => { + const newFilters = excludeUnderEvaluationFilter(filters || []); + if (underEvaluation === null) { + setFilters(newFilters); + return; + } + newFilters.push(createUnderEvaluationFilter(underEvaluation, dataSource?.id || indexPattern?.id)); + setFilters(newFilters); + }; + + + const [underEvaluation, setUnderEvaluation] = useState(getUnderEvaluation(filters || [])); + + return ( <> @@ -190,7 +213,9 @@ const InventoryVulsComponent = () => { ]} showDatePicker={false} showQueryInput={true} showQueryBar={true} @@ -219,15 +244,17 @@ const InventoryVulsComponent = () => { showResetButton={false} tooltip={ results?.hits?.total && - results?.hits?.total > MAX_ENTRIES_PER_QUERY + results?.hits?.total > MAX_ENTRIES_PER_QUERY ? { - ariaLabel: 'Warning', - content: `The query results exceeded the limit of ${formatNumWithCommas( - MAX_ENTRIES_PER_QUERY, - )} hits. Please refine your search.`, - iconType: 'alert', - position: 'top', - } + ariaLabel: 'Warning', + content: `The query results has exceeded the limit of ${formatNumWithCommas( + MAX_ENTRIES_PER_QUERY, + )} hits. To provide a better experience the table only shows the first ${formatNumWithCommas( + MAX_ENTRIES_PER_QUERY, + )} hits.`, + iconType: 'alert', + position: 'top', + } : undefined } /> diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx index 2ea3d9846f..25523953a0 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useMemo } from 'react'; +import React, { useState, useEffect, useCallback } from 'react'; import { SearchResponse } from '../../../../../../../../src/core/server'; import { getPlugins } from '../../../../../kibana-services'; import { ViewMode } from '../../../../../../../../src/plugins/embeddable/public'; @@ -25,10 +25,13 @@ import { VulnerabilitiesDataSource, PatternDataSource, tParsedIndexPattern, + PatternDataSourceFilterManager, + FILTER_OPERATOR } from '../../../../common/data-source'; import { useDataSource } from '../../../../common/data-source/hooks'; import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; import { WzSearchBar } from '../../../../common/search-bar'; +import VulsEvaluationFilter, { createUnderEvaluationFilter, excludeUnderEvaluationFilter, getUnderEvaluationFilterValue } from '../../common/components/vuls-evaluation-filter'; const plugins = getPlugins(); const DashboardByRenderer = plugins.dashboard.DashboardContainerByValueRenderer; @@ -70,6 +73,7 @@ const DashboardVulsComponent: React.FC = ({ if (isDataSourceLoading) { return; } + setUnderEvaluation(getUnderEvaluation(filters || [])); fetchData({ query }) .then(results => { setResults(results); @@ -83,6 +87,33 @@ const DashboardVulsComponent: React.FC = ({ }); }, [JSON.stringify(fetchFilters), JSON.stringify(query)]); + /** + * When the user changes the filter value, this function is called to update the filters + * If the value is null, the filter is removed + * If the filter already exists, it is remove and the new filter is added + * @param underEvaluation + * @returns + */ + const handleFilterChange = (underEvaluation: boolean | null) => { + const newFilters = excludeUnderEvaluationFilter(filters || []); + if (underEvaluation === null) { + setFilters(newFilters); + return; + } + newFilters.push(createUnderEvaluationFilter(underEvaluation, dataSource?.id || indexPattern?.id)); + setFilters(newFilters); + } + + + const getUnderEvaluation = useCallback(getUnderEvaluationFilterValue, [ + JSON.stringify(filters), + isDataSourceLoading + ]); + + + const [underEvaluation, setUnderEvaluation] = useState(getUnderEvaluation(filters || [])); + + return ( <> @@ -94,7 +125,9 @@ const DashboardVulsComponent: React.FC = ({ ]} showDatePicker={false} showQueryInput={true} showQueryBar={true} @@ -105,9 +138,8 @@ const DashboardVulsComponent: React.FC = ({ ) : null}
0 ? '' : 'wz-no-display' - }`} + className={`vulnerability-dashboard-responsive vulnerability-dashboard-metrics ${dataSource && results?.hits?.total > 0 ? '' : 'wz-no-display' + }`} > Date: Thu, 26 Sep 2024 16:40:50 -0300 Subject: [PATCH 11/15] Add style to button group in filter --- .../components/vuls-evaluation-filter.scss | 21 +++++++++++++++++++ .../components/vuls-evaluation-filter.tsx | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss new file mode 100644 index 0000000000..98b4b7654d --- /dev/null +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss @@ -0,0 +1,21 @@ +.button-group-filter { + border-radius: 2px; + + .euiButton__content, + .euiButton__text { + font-size: 12px; + font-weight: 500; + } + + + .euiButtonGroup__buttons { + height: 30px; + border-radius: 2px; + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.2), 0 3px 2px -2px rgba(0, 0, 0, 0.2), inset 0 0 0 1px #424752 !important; + border: none !important; + + .euiButtonGroupButton { + line-height: 28px; + } + } +} \ No newline at end of file diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx index b72193fbe2..fc79a77c6a 100644 --- a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react"; import { EuiButtonGroup } from "@elastic/eui" import { FILTER_OPERATOR, PatternDataSourceFilterManager } from "../../../../common/data-source"; import { Filter } from "../../../../../../../../src/plugins/data/common"; +import "./vuls-evaluation-filter.scss"; type VulsEvaluatedFilterProps = { setValue: (underEvaluation: boolean | null) => void; @@ -80,6 +81,7 @@ const VulsEvaluationFilter = ({ setValue, value }: VulsEvaluatedFilterProps) => return ( Date: Thu, 26 Sep 2024 16:47:39 -0300 Subject: [PATCH 12/15] Apply prettier --- .../common/data-grid/use-data-grid.tsx | 20 +- .../pattern-data-source-filter-manager.ts | 2 +- .../common/search-bar/search-bar.tsx | 21 +- .../components/vuls-evaluation-filter.scss | 34 ++-- .../components/vuls-evaluation-filter.tsx | 180 +++++++++--------- .../dashboards/inventory/inventory.tsx | 55 ++++-- .../dashboards/overview/dashboard.tsx | 44 +++-- 7 files changed, 201 insertions(+), 155 deletions(-) diff --git a/plugins/main/public/components/common/data-grid/use-data-grid.tsx b/plugins/main/public/components/common/data-grid/use-data-grid.tsx index b641541f0b..d85d5898ea 100644 --- a/plugins/main/public/components/common/data-grid/use-data-grid.tsx +++ b/plugins/main/public/components/common/data-grid/use-data-grid.tsx @@ -23,7 +23,7 @@ export interface PaginationOptions extends Pick< EuiDataGridPaginationProps, 'pageIndex' | 'pageSize' | 'pageSizeOptions' - > { } + > {} type SortingColumns = EuiDataGridSorting['columns']; @@ -70,7 +70,7 @@ export const useDataGrid = (props: tDataGridProps): EuiDataGridProps => { useDefaultPagination = false, pagination: paginationProps = {}, filters = [], - setFilters = () => { }, + setFilters = () => {}, } = props; const [columnVisibility, setVisibility] = useState(() => columns.map(({ id }) => id), @@ -86,11 +86,11 @@ export const useDataGrid = (props: tDataGridProps): EuiDataGridProps => { ); return defaultSort ? [ - { - id: defaultSort.id, - direction: defaultSort.defaultSortDirection || 'desc', - }, - ] + { + id: defaultSort.id, + direction: defaultSort.defaultSortDirection || 'desc', + }, + ] : []; }; const defaultSorting: SortingColumns = getDefaultSorting(); @@ -105,9 +105,9 @@ export const useDataGrid = (props: tDataGridProps): EuiDataGridProps => { useDefaultPagination ? DEFAULT_PAGINATION_OPTIONS : { - ...DEFAULT_PAGINATION_OPTIONS, - ...paginationProps, - }, + ...DEFAULT_PAGINATION_OPTIONS, + ...paginationProps, + }, ); const onChangeItemsPerPage = useMemo( diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts index e763c93629..8e4781c360 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts @@ -325,7 +325,7 @@ export class PatternDataSourceFilterManager static createFilter( type: FILTER_OPERATOR, key: string, - value: string | string[] | any, + value: string | string[] | any, indexPatternId: string, controlledBy?: string, ) { diff --git a/plugins/main/public/components/common/search-bar/search-bar.tsx b/plugins/main/public/components/common/search-bar/search-bar.tsx index 5e64d164ab..8c7b57144a 100644 --- a/plugins/main/public/components/common/search-bar/search-bar.tsx +++ b/plugins/main/public/components/common/search-bar/search-bar.tsx @@ -67,18 +67,21 @@ export const WzSearchBar = ({ {fixedFilters?.map((filter, idx) => ( - {`${filter.meta.key}: ${typeof filter.meta.value === 'function' - ? filter.meta.value() - : filter.meta.value - }`} + {`${filter.meta.key}: ${ + typeof filter.meta.value === 'function' + ? filter.meta.value() + : filter.meta.value + }`} ))} - {postFixedFilters ? postFixedFilters.map((Filter, idx) => ( - - - - )) : null} + {postFixedFilters + ? postFixedFilters.map((Filter, idx) => ( + + + + )) + : null} )} diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss index 98b4b7654d..70c77d0343 100644 --- a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss @@ -1,21 +1,23 @@ .button-group-filter { - border-radius: 2px; - - .euiButton__content, - .euiButton__text { - font-size: 12px; - font-weight: 500; - } + border-radius: 2px; + .euiButton__content, + .euiButton__text { + font-size: 12px; + font-weight: 500; + } - .euiButtonGroup__buttons { - height: 30px; - border-radius: 2px; - box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.2), 0 3px 2px -2px rgba(0, 0, 0, 0.2), inset 0 0 0 1px #424752 !important; - border: none !important; + .euiButtonGroup__buttons { + height: 30px; + border-radius: 2px; + box-shadow: + 0 1px 1px -1px rgba(0, 0, 0, 0.2), + 0 3px 2px -2px rgba(0, 0, 0, 0.2), + inset 0 0 0 1px #424752 !important; + border: none !important; - .euiButtonGroupButton { - line-height: 28px; - } + .euiButtonGroupButton { + line-height: 28px; } -} \ No newline at end of file + } +} diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx index fc79a77c6a..babd2e99d9 100644 --- a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx @@ -1,94 +1,104 @@ -import React, { useState, useEffect } from "react"; -import { EuiButtonGroup } from "@elastic/eui" -import { FILTER_OPERATOR, PatternDataSourceFilterManager } from "../../../../common/data-source"; -import { Filter } from "../../../../../../../../src/plugins/data/common"; -import "./vuls-evaluation-filter.scss"; +import React, { useState, useEffect } from 'react'; +import { EuiButtonGroup } from '@elastic/eui'; +import { + FILTER_OPERATOR, + PatternDataSourceFilterManager, +} from '../../../../common/data-source'; +import { Filter } from '../../../../../../../../src/plugins/data/common'; +import './vuls-evaluation-filter.scss'; type VulsEvaluatedFilterProps = { - setValue: (underEvaluation: boolean | null) => void; - value: boolean | null; -} - -const UNDER_EVALUATION_FIELD = "wazuh.vulnerability.under_evaluation"; - -export const getUnderEvaluationFilterValue = (filters: Filter[]): boolean | null => { - const underEvaluationFilter = filters.find(f => f.meta?.key === UNDER_EVALUATION_FIELD); - if (underEvaluationFilter) { - return underEvaluationFilter.meta?.params.query as boolean; - } - return null; -} + setValue: (underEvaluation: boolean | null) => void; + value: boolean | null; +}; + +const UNDER_EVALUATION_FIELD = 'wazuh.vulnerability.under_evaluation'; + +export const getUnderEvaluationFilterValue = ( + filters: Filter[], +): boolean | null => { + const underEvaluationFilter = filters.find( + f => f.meta?.key === UNDER_EVALUATION_FIELD, + ); + if (underEvaluationFilter) { + return underEvaluationFilter.meta?.params.query as boolean; + } + return null; +}; export const excludeUnderEvaluationFilter = (filters: Filter[]): Filter[] => { - return filters.filter(f => f.meta?.key !== UNDER_EVALUATION_FIELD); -} - -export const createUnderEvaluationFilter = (underEvaluation: boolean, indexPatternId: string): Filter => { - return PatternDataSourceFilterManager.createFilter( - FILTER_OPERATOR.IS, - UNDER_EVALUATION_FIELD, - underEvaluation, - indexPatternId - ) -} - -const VulsEvaluationFilter = ({ setValue, value }: VulsEvaluatedFilterProps) => { - - const toggleButtons = [ - { - id: 'evaluated', - label: 'Evaluated', - }, - { - id: 'underEvaluation', - label: 'Under evaluation', - } - ]; - - const getDefaultValue = () => { - if (value === true) { - return { underEvaluation: true, evaluated: false }; - } else if (value === false) { - return { underEvaluation: false, evaluated: true }; - } else { - return {}; - } + return filters.filter(f => f.meta?.key !== UNDER_EVALUATION_FIELD); +}; + +export const createUnderEvaluationFilter = ( + underEvaluation: boolean, + indexPatternId: string, +): Filter => { + return PatternDataSourceFilterManager.createFilter( + FILTER_OPERATOR.IS, + UNDER_EVALUATION_FIELD, + underEvaluation, + indexPatternId, + ); +}; + +const VulsEvaluationFilter = ({ + setValue, + value, +}: VulsEvaluatedFilterProps) => { + const toggleButtons = [ + { + id: 'evaluated', + label: 'Evaluated', + }, + { + id: 'underEvaluation', + label: 'Under evaluation', + }, + ]; + + const getDefaultValue = () => { + if (value === true) { + return { underEvaluation: true, evaluated: false }; + } else if (value === false) { + return { underEvaluation: false, evaluated: true }; + } else { + return {}; } + }; - const [toggleIdToSelectedMap, setToggleIdToSelectedMap] = useState(getDefaultValue()); + const [toggleIdToSelectedMap, setToggleIdToSelectedMap] = + useState(getDefaultValue()); + useEffect(() => { + setToggleIdToSelectedMap(getDefaultValue()); + }, [value]); - useEffect(() => { - setToggleIdToSelectedMap(getDefaultValue()); - }, [value]); - - - const handleChange = (optionId: string) => { - let newToggleIdToSelectedMap = {}; - if (!toggleIdToSelectedMap[optionId]) { - newToggleIdToSelectedMap = { [optionId]: true }; - } - setToggleIdToSelectedMap(newToggleIdToSelectedMap); - if (optionId === "underEvaluation" && newToggleIdToSelectedMap[optionId]) { - setValue(true); - } else if (optionId === "evaluated" && newToggleIdToSelectedMap[optionId]) { - setValue(false); - } else { - setValue(null); - } - + const handleChange = (optionId: string) => { + let newToggleIdToSelectedMap = {}; + if (!toggleIdToSelectedMap[optionId]) { + newToggleIdToSelectedMap = { [optionId]: true }; } - - return ( - handleChange(id)} - buttonSize="compressed" - /> - ) -} - -export default VulsEvaluationFilter; \ No newline at end of file + setToggleIdToSelectedMap(newToggleIdToSelectedMap); + if (optionId === 'underEvaluation' && newToggleIdToSelectedMap[optionId]) { + setValue(true); + } else if (optionId === 'evaluated' && newToggleIdToSelectedMap[optionId]) { + setValue(false); + } else { + setValue(null); + } + }; + + return ( + handleChange(id)} + buttonSize='compressed' + /> + ); +}; + +export default VulsEvaluationFilter; diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx b/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx index 3bf2c5f88b..4786bf71a1 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/inventory/inventory.tsx @@ -50,7 +50,11 @@ import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; import { wzDiscoverRenderColumns } from '../../../../common/wazuh-discover/render-columns'; import { DocumentViewTableAndJson } from '../../../../common/wazuh-discover/components/document-view-table-and-json'; import { WzSearchBar } from '../../../../common/search-bar'; -import VulsEvaluationFilter, { createUnderEvaluationFilter, excludeUnderEvaluationFilter, getUnderEvaluationFilterValue } from '../../common/components/vuls-evaluation-filter'; +import VulsEvaluationFilter, { + createUnderEvaluationFilter, + excludeUnderEvaluationFilter, + getUnderEvaluationFilterValue, +} from '../../common/components/vuls-evaluation-filter'; const InventoryVulsComponent = () => { const { @@ -106,7 +110,7 @@ const InventoryVulsComponent = () => { const getUnderEvaluation = useCallback(getUnderEvaluationFilterValue, [ JSON.stringify(filters), - isDataSourceLoading + isDataSourceLoading, ]); const dataGridProps = useDataGrid({ @@ -172,13 +176,12 @@ const InventoryVulsComponent = () => { JSON.stringify(sorting), ]); - /** * When the user changes the filter value, this function is called to update the filters * If the value is null, the filter is removed * If the filter already exists, it is remove and the new filter is added - * @param underEvaluation - * @returns + * @param underEvaluation + * @returns */ const handleFilterChange = (underEvaluation: boolean | null) => { const newFilters = excludeUnderEvaluationFilter(filters || []); @@ -186,13 +189,18 @@ const InventoryVulsComponent = () => { setFilters(newFilters); return; } - newFilters.push(createUnderEvaluationFilter(underEvaluation, dataSource?.id || indexPattern?.id)); + newFilters.push( + createUnderEvaluationFilter( + underEvaluation, + dataSource?.id || indexPattern?.id, + ), + ); setFilters(newFilters); }; - - const [underEvaluation, setUnderEvaluation] = useState(getUnderEvaluation(filters || [])); - + const [underEvaluation, setUnderEvaluation] = useState( + getUnderEvaluation(filters || []), + ); return ( @@ -215,7 +223,14 @@ const InventoryVulsComponent = () => { {...searchBarProps} filters={excludeUnderEvaluationFilter(filters)} fixedFilters={fixedFilters} - postFixedFilters={[() => ]} + postFixedFilters={[ + () => ( + + ), + ]} showDatePicker={false} showQueryInput={true} showQueryBar={true} @@ -244,17 +259,17 @@ const InventoryVulsComponent = () => { showResetButton={false} tooltip={ results?.hits?.total && - results?.hits?.total > MAX_ENTRIES_PER_QUERY + results?.hits?.total > MAX_ENTRIES_PER_QUERY ? { - ariaLabel: 'Warning', - content: `The query results has exceeded the limit of ${formatNumWithCommas( - MAX_ENTRIES_PER_QUERY, - )} hits. To provide a better experience the table only shows the first ${formatNumWithCommas( - MAX_ENTRIES_PER_QUERY, - )} hits.`, - iconType: 'alert', - position: 'top', - } + ariaLabel: 'Warning', + content: `The query results has exceeded the limit of ${formatNumWithCommas( + MAX_ENTRIES_PER_QUERY, + )} hits. To provide a better experience the table only shows the first ${formatNumWithCommas( + MAX_ENTRIES_PER_QUERY, + )} hits.`, + iconType: 'alert', + position: 'top', + } : undefined } /> diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx index 25523953a0..7398da1bb4 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx @@ -26,12 +26,16 @@ import { PatternDataSource, tParsedIndexPattern, PatternDataSourceFilterManager, - FILTER_OPERATOR + FILTER_OPERATOR, } from '../../../../common/data-source'; import { useDataSource } from '../../../../common/data-source/hooks'; import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; import { WzSearchBar } from '../../../../common/search-bar'; -import VulsEvaluationFilter, { createUnderEvaluationFilter, excludeUnderEvaluationFilter, getUnderEvaluationFilterValue } from '../../common/components/vuls-evaluation-filter'; +import VulsEvaluationFilter, { + createUnderEvaluationFilter, + excludeUnderEvaluationFilter, + getUnderEvaluationFilterValue, +} from '../../common/components/vuls-evaluation-filter'; const plugins = getPlugins(); const DashboardByRenderer = plugins.dashboard.DashboardContainerByValueRenderer; @@ -91,8 +95,8 @@ const DashboardVulsComponent: React.FC = ({ * When the user changes the filter value, this function is called to update the filters * If the value is null, the filter is removed * If the filter already exists, it is remove and the new filter is added - * @param underEvaluation - * @returns + * @param underEvaluation + * @returns */ const handleFilterChange = (underEvaluation: boolean | null) => { const newFilters = excludeUnderEvaluationFilter(filters || []); @@ -100,19 +104,23 @@ const DashboardVulsComponent: React.FC = ({ setFilters(newFilters); return; } - newFilters.push(createUnderEvaluationFilter(underEvaluation, dataSource?.id || indexPattern?.id)); + newFilters.push( + createUnderEvaluationFilter( + underEvaluation, + dataSource?.id || indexPattern?.id, + ), + ); setFilters(newFilters); - } - + }; const getUnderEvaluation = useCallback(getUnderEvaluationFilterValue, [ JSON.stringify(filters), - isDataSourceLoading + isDataSourceLoading, ]); - - const [underEvaluation, setUnderEvaluation] = useState(getUnderEvaluation(filters || [])); - + const [underEvaluation, setUnderEvaluation] = useState( + getUnderEvaluation(filters || []), + ); return ( <> @@ -127,7 +135,14 @@ const DashboardVulsComponent: React.FC = ({ {...searchBarProps} filters={excludeUnderEvaluationFilter(filters)} fixedFilters={fixedFilters} - postFixedFilters={[() => ]} + postFixedFilters={[ + () => ( + + ), + ]} showDatePicker={false} showQueryInput={true} showQueryBar={true} @@ -138,8 +153,9 @@ const DashboardVulsComponent: React.FC = ({ ) : null}
0 ? '' : 'wz-no-display' - }`} + className={`vulnerability-dashboard-responsive vulnerability-dashboard-metrics ${ + dataSource && results?.hits?.total > 0 ? '' : 'wz-no-display' + }`} > Date: Thu, 26 Sep 2024 16:53:25 -0300 Subject: [PATCH 13/15] Apply prettier --- .../common/components/vuls-evaluation-filter.scss | 6 ++---- .../common/components/vuls-evaluation-filter.tsx | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss index 70c77d0343..26583e3336 100644 --- a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss @@ -10,10 +10,8 @@ .euiButtonGroup__buttons { height: 30px; border-radius: 2px; - box-shadow: - 0 1px 1px -1px rgba(0, 0, 0, 0.2), - 0 3px 2px -2px rgba(0, 0, 0, 0.2), - inset 0 0 0 1px #424752 !important; + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.2), + 0 3px 2px -2px rgba(0, 0, 0, 0.2), inset 0 0 0 1px #424752 !important; border: none !important; .euiButtonGroupButton { diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx index babd2e99d9..866dd7a791 100644 --- a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx @@ -67,8 +67,9 @@ const VulsEvaluationFilter = ({ } }; - const [toggleIdToSelectedMap, setToggleIdToSelectedMap] = - useState(getDefaultValue()); + const [toggleIdToSelectedMap, setToggleIdToSelectedMap] = useState( + getDefaultValue(), + ); useEffect(() => { setToggleIdToSelectedMap(getDefaultValue()); From 0eb91a66bd33d5530e1611f75c7001490ec6f0fb Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Thu, 26 Sep 2024 17:24:23 -0300 Subject: [PATCH 14/15] Fix style in dark and light theme --- .../components/vuls-evaluation-filter.scss | 21 ----------------- .../components/vuls-evaluation-filter.tsx | 1 - plugins/main/public/styles/common.scss | 23 +++++++++++++++++++ .../public/styles/theme/dark/index.dark.scss | 9 ++++++++ 4 files changed, 32 insertions(+), 22 deletions(-) delete mode 100644 plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss deleted file mode 100644 index 26583e3336..0000000000 --- a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.scss +++ /dev/null @@ -1,21 +0,0 @@ -.button-group-filter { - border-radius: 2px; - - .euiButton__content, - .euiButton__text { - font-size: 12px; - font-weight: 500; - } - - .euiButtonGroup__buttons { - height: 30px; - border-radius: 2px; - box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.2), - 0 3px 2px -2px rgba(0, 0, 0, 0.2), inset 0 0 0 1px #424752 !important; - border: none !important; - - .euiButtonGroupButton { - line-height: 28px; - } - } -} diff --git a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx index 866dd7a791..590b251faa 100644 --- a/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/common/components/vuls-evaluation-filter.tsx @@ -5,7 +5,6 @@ import { PatternDataSourceFilterManager, } from '../../../../common/data-source'; import { Filter } from '../../../../../../../../src/plugins/data/common'; -import './vuls-evaluation-filter.scss'; type VulsEvaluatedFilterProps = { setValue: (underEvaluation: boolean | null) => void; diff --git a/plugins/main/public/styles/common.scss b/plugins/main/public/styles/common.scss index 69f2be672e..a6fbe6be15 100644 --- a/plugins/main/public/styles/common.scss +++ b/plugins/main/public/styles/common.scss @@ -1833,3 +1833,26 @@ iframe.width-changed { fill: #000000bb; } } + +/* Vulnerabilities under evaluation filter */ +.button-group-filter { + border-radius: 2px; + + .euiButton__content, + .euiButton__text { + font-size: 12px; + font-weight: 500; + } + + .euiButtonGroup__buttons { + height: 30px; + border-radius: 2px; + box-shadow: 0 1px 1px -1px rgba(152, 162, 179, 0.2), + 0 3px 2px -2px rgba(152, 162, 179, 0.2), inset 0 0 0 1px #bcc3ce !important; + border: none !important; + + .euiButtonGroupButton { + line-height: 28px; + } + } +} diff --git a/plugins/main/public/styles/theme/dark/index.dark.scss b/plugins/main/public/styles/theme/dark/index.dark.scss index 4e2b58481b..421d51f17f 100644 --- a/plugins/main/public/styles/theme/dark/index.dark.scss +++ b/plugins/main/public/styles/theme/dark/index.dark.scss @@ -217,6 +217,7 @@ table thead > tr { .wzMultipleSelector select { border-color: #343741; } + .wzMultipleSelectorSelect { color: #dfe5ef; } @@ -456,3 +457,11 @@ svg .legend text { fill: #dfe5ef; } } + +/* Vulnerabilities under evaluation filter */ +.button-group-filter { + .euiButtonGroup__buttons { + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.2), + 0 3px 2px -2px rgba(0, 0, 0, 0.2), inset 0 0 0 1px #424752 !important; + } +} From 0ad503aa23625cc3abbdb0d36b08182b566fd0b8 Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Fri, 27 Sep 2024 11:10:12 +0200 Subject: [PATCH 15/15] Added changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9a02263b5..94d0cc4413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,12 @@ All notable changes to the Wazuh app project will be documented in this file. - Support for Wazuh 4.10.0 - Added sample data for YARA [#6964](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6964) +- Added a custom filter and visualization for vulnerability.under_evaluation field [#6968](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6968) ### Changed - Update malware detection group values in data sources [#6963](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6963) -- Changed the registration id of the Settings application for compatibility with Opensearch Dashboard 2.16.0 [#6938](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6938) +- Changed the registration id of the Settings application for compatibility with OpenSearch Dashboard 2.16.0 [#6938](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6938) - Changed Malware detection dashboard visualizations [#6964](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6964) ### Fixed