From 79fe18150393a2c5d7fbf6eb0f8fb8bb2f54bf60 Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Tue, 22 Mar 2022 15:25:33 +0100 Subject: [PATCH 1/6] Added all fields prop and changed column width --- public/components/agents/vuls/inventory/detail.tsx | 6 ++++-- public/components/common/modules/discover/discover.tsx | 6 +++++- public/components/common/modules/discover/row-details.tsx | 7 ++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/public/components/agents/vuls/inventory/detail.tsx b/public/components/agents/vuls/inventory/detail.tsx index 36aa40f956..4b5e707df9 100644 --- a/public/components/agents/vuls/inventory/detail.tsx +++ b/public/components/agents/vuls/inventory/detail.tsx @@ -129,14 +129,14 @@ export class Details extends Component { }, { field: 'last_full_scan', - name: 'Last Full Scan', + name: 'Last full scan', icon: 'clock', link: false, transformValue: formatUIDate }, { field: 'last_partial_scan', - name: 'Last Partial Scan', + name: 'Last partial scan', icon: 'clock', link: false, transformValue: formatUIDate @@ -435,6 +435,7 @@ export class Details extends Component { { const itemIdToExpandedRowMap = { ...this.state.itemIdToExpandedRowMap }; + const { showAllFields } = this.props; + if (itemIdToExpandedRowMap[item._id]) { delete itemIdToExpandedRowMap[item._id]; this.setState({ itemIdToExpandedRowMap }); @@ -336,6 +339,7 @@ export const Discover = compose( addFilter={(filter) => this.addFilter(filter)} addFilterOut={(filter) => this.addFilterOut(filter)} toggleColumn={(id) => this.addColumn(id)} + showAllFields={showAllFields} /> ); @@ -474,7 +478,7 @@ export const Discover = compose( const columns = columnsList.map((item) => { if (item === 'icon') { return { - width: '25px', + width: '2.3%', isExpander: true, render: (item) => { return ( diff --git a/public/components/common/modules/discover/row-details.tsx b/public/components/common/modules/discover/row-details.tsx index a6f4dbd1a4..96bfa389dd 100644 --- a/public/components/common/modules/discover/row-details.tsx +++ b/public/components/common/modules/discover/row-details.tsx @@ -60,6 +60,7 @@ export class RowDetails extends Component { }, syscheck: Object } + showAllFields?: boolean } constructor(props) { @@ -146,7 +147,11 @@ export class RowDetails extends Component { renderRows() { - const fieldsToShow = ['agent', 'cluster', 'manager', 'rule', 'decoder', 'syscheck', 'full_log', 'location']; + this.props.showAllFields + const fieldsToShow = this.props.showAllFields ? + Object.keys(this.props.item) + : + ['agent', 'cluster', 'manager', 'rule', 'decoder', 'syscheck', 'full_log', 'location']; var rows: any[] = []; const isString = val => typeof val === 'string'; for (var i = 0; i < fieldsToShow.length; i++) { From 9d3a1c6686799ff4d0083d756ac4e84bacee04be Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Tue, 22 Mar 2022 15:36:57 +0100 Subject: [PATCH 2/6] Fixed coding leftover --- public/components/common/modules/discover/row-details.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/public/components/common/modules/discover/row-details.tsx b/public/components/common/modules/discover/row-details.tsx index 96bfa389dd..8fc17157eb 100644 --- a/public/components/common/modules/discover/row-details.tsx +++ b/public/components/common/modules/discover/row-details.tsx @@ -147,7 +147,6 @@ export class RowDetails extends Component { renderRows() { - this.props.showAllFields const fieldsToShow = this.props.showAllFields ? Object.keys(this.props.item) : From 0699f7de453b71b1a27d8ff16313a4523ab996ab Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Wed, 23 Mar 2022 10:54:51 +0100 Subject: [PATCH 3/6] show all available fields by default --- public/components/agents/vuls/inventory/detail.tsx | 1 - public/components/common/modules/discover/discover.tsx | 6 +++--- .../components/common/modules/discover/row-details.tsx | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/public/components/agents/vuls/inventory/detail.tsx b/public/components/agents/vuls/inventory/detail.tsx index 4b5e707df9..5e9815ff62 100644 --- a/public/components/agents/vuls/inventory/detail.tsx +++ b/public/components/agents/vuls/inventory/detail.tsx @@ -435,7 +435,6 @@ export class Details extends Component { { const itemIdToExpandedRowMap = { ...this.state.itemIdToExpandedRowMap }; - const { showAllFields } = this.props; + const { rowDetailsFields } = this.props; if (itemIdToExpandedRowMap[item._id]) { delete itemIdToExpandedRowMap[item._id]; @@ -339,7 +339,7 @@ export const Discover = compose( addFilter={(filter) => this.addFilter(filter)} addFilterOut={(filter) => this.addFilterOut(filter)} toggleColumn={(id) => this.addColumn(id)} - showAllFields={showAllFields} + rowDetailsFields={rowDetailsFields} /> ); diff --git a/public/components/common/modules/discover/row-details.tsx b/public/components/common/modules/discover/row-details.tsx index 8fc17157eb..1e9b0406f3 100644 --- a/public/components/common/modules/discover/row-details.tsx +++ b/public/components/common/modules/discover/row-details.tsx @@ -60,7 +60,7 @@ export class RowDetails extends Component { }, syscheck: Object } - showAllFields?: boolean + rowDetailsFields?: string[] } constructor(props) { @@ -147,10 +147,10 @@ export class RowDetails extends Component { renderRows() { - const fieldsToShow = this.props.showAllFields ? - Object.keys(this.props.item) - : - ['agent', 'cluster', 'manager', 'rule', 'decoder', 'syscheck', 'full_log', 'location']; + // By default show all available fields, otherwise show the fields specified in rowDetailsFields string array + const fieldsToShow = this.props.rowDetailsFields?.length ? + this.props.rowDetailsFields : Object.keys(this.props.item); + var rows: any[] = []; const isString = val => typeof val === 'string'; for (var i = 0; i < fieldsToShow.length; i++) { From e1f80477b7329b635bec626dad29e5798792c37c Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Wed, 23 Mar 2022 12:13:33 +0100 Subject: [PATCH 4/6] Added sorting to row details fields --- .../common/modules/discover/row-details.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/components/common/modules/discover/row-details.tsx b/public/components/common/modules/discover/row-details.tsx index 1e9b0406f3..fdc5dc471e 100644 --- a/public/components/common/modules/discover/row-details.tsx +++ b/public/components/common/modules/discover/row-details.tsx @@ -95,6 +95,15 @@ export class RowDetails extends Component { const paths = (obj = {}, head = '') => { return Object.entries(obj) + .sort(([keyA], [keyB]) => { + if (keyA > keyB) { + return 1; + } else if (keyA < keyB) { + return -1; + } else { + return 0; + }; + }) .reduce((product, [key, value]) => { let fullPath = addDelimiter(head, key) return isObject(value) ? @@ -149,7 +158,7 @@ export class RowDetails extends Component { renderRows() { // By default show all available fields, otherwise show the fields specified in rowDetailsFields string array const fieldsToShow = this.props.rowDetailsFields?.length ? - this.props.rowDetailsFields : Object.keys(this.props.item); + this.props.rowDetailsFields.sort() : Object.keys(this.props.item).sort(); var rows: any[] = []; const isString = val => typeof val === 'string'; From 10138db9995cbaa87553300ac99bcc02b6e49f90 Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Wed, 23 Mar 2022 14:16:06 +0100 Subject: [PATCH 5/6] Fixed default value for last scan details --- public/components/agents/vuls/inventory/detail.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/public/components/agents/vuls/inventory/detail.tsx b/public/components/agents/vuls/inventory/detail.tsx index 5e9815ff62..1d3700615f 100644 --- a/public/components/agents/vuls/inventory/detail.tsx +++ b/public/components/agents/vuls/inventory/detail.tsx @@ -132,14 +132,14 @@ export class Details extends Component { name: 'Last full scan', icon: 'clock', link: false, - transformValue: formatUIDate + transformValue: this.beautifyDate }, { field: 'last_partial_scan', name: 'Last partial scan', icon: 'clock', link: false, - transformValue: formatUIDate + transformValue: this.beautifyDate }, { field: 'published', @@ -165,6 +165,13 @@ export class Details extends Component { ]; } + // This method was created because Wazuh API returns 1970-01-01T00:00:00Z dates + // when vulnerability module is not configured + // its meant to render nothing when such date is received + beautifyDate(date: string) { + return ['', '1970-01-01T00:00:00Z'].includes(date) ? '-' : formatUIDate(date); + } + viewInEvents = (ev) => { const { cve } = this.props.currentItem; if (this.props.view === 'extern') { From 56b76a86e21685c0c8457d870d4f20dbae395b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Wed, 23 Mar 2022 14:38:22 +0100 Subject: [PATCH 6/6] changelog: Add PR to changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a63aef054e..63719e7528 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Added a toast message when there is an error creating a new group [#3804](https://github.com/wazuh/wazuh-kibana-app/pull/3804) - Added a step to start the agent to the deploy new Windowns agent guide [#3846](https://github.com/wazuh/wazuh-kibana-app/pull/3846) - Added 3 new panels to `Vulnerabilities/Inventory` [#3893](https://github.com/wazuh/wazuh-kibana-app/pull/3893) +- Added new fields of `Vulnerabilities` to the details flyout [#3893](https://github.com/wazuh/wazuh-kibana-app/pull/3893) [#3908](https://github.com/wazuh/wazuh-kibana-app/pull/3908) ### Changed @@ -75,6 +76,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Changed agent install codeblock copy button and powershell terminal warning [#3792](https://github.com/wazuh/wazuh-kibana-app/pull/3792) - Refactored as the plugin platform name and references is managed [#3811](https://github.com/wazuh/wazuh-kibana-app/pull/3811) - Removed `Dashboard` tab for the `Vulnerabilities` modules [#3893](https://github.com/wazuh/wazuh-kibana-app/pull/3893) +- Display all fields in the `Table` tab when expading an alert row in the alerts tables of flyouts and the `Modules/Security Events/Dashboard` table [#3908](https://github.com/wazuh/wazuh-kibana-app/pull/3908) ### Fixed