diff --git a/CHANGELOG.md b/CHANGELOG.md index 65bee9cd22..4362b0fc1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Fixed pagination to SCA table [#4653](https://github.com/wazuh/wazuh-kibana-app/issues/4653) - Fixed WAZUH_PROTOCOL param suggestion [#4849](https://github.com/wazuh/wazuh-kibana-app/pull/4849) - Raspbian OS, Ubuntu, Amazon Linux and Amazon Linux 2 commands in the wizard deploy agent now change when a different architecture is selected [#4876](https://github.com/wazuh/wazuh-kibana-app/pull/4876) [#4880](https://github.com/wazuh/wazuh-kibana-app/pull/4880) +- Fixed vulnerabilities default last scan date formatter [#4975](https://github.com/wazuh/wazuh-kibana-app/pull/4975) ## Wazuh v4.3.10 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4311 diff --git a/public/components/agents/vuls/inventory.tsx b/public/components/agents/vuls/inventory.tsx index 6b25d4c073..52b8d9aad7 100644 --- a/public/components/agents/vuls/inventory.tsx +++ b/public/components/agents/vuls/inventory.tsx @@ -33,7 +33,7 @@ import { VisualizationBasicWidget, } from '../../common/charts/visualizations/basic'; import { WzStat } from '../../wz-stat'; -import { formatUIDate } from '../../../react-services/time-service'; +import { beautifyDate } from './inventory/lib'; interface Aggregation { title: number; @@ -104,11 +104,6 @@ export class Inventory extends Component { this.colorsVisualizationVulnerabilitiesSummaryData = euiPaletteColorBlind(); } - // when vulnerability module is not configured - // its meant to render nothing when such date is received - beautifyDate(date?: string) { - return date && !['1970-01-01T00:00:00Z', '-'].includes(date) ? formatUIDate(date) : '-'; - } async componentDidMount() { this._isMount = true; @@ -234,8 +229,8 @@ export class Inventory extends Component { if (isLoading) { return this.loadingInventory(); } - const last_full_scan = this.beautifyDate(vulnerabilityLastScan.last_full_scan); - const last_partial_scan = this.beautifyDate(vulnerabilityLastScan.last_partial_scan); + const last_full_scan = beautifyDate(vulnerabilityLastScan.last_full_scan); + const last_partial_scan = beautifyDate(vulnerabilityLastScan.last_partial_scan); const table = this.renderTable(); return ( diff --git a/public/components/agents/vuls/inventory/detail.tsx b/public/components/agents/vuls/inventory/detail.tsx index 4a71a2d7c0..b99aecaabf 100644 --- a/public/components/agents/vuls/inventory/detail.tsx +++ b/public/components/agents/vuls/inventory/detail.tsx @@ -36,7 +36,7 @@ import { AppNavigate } from '../../../../react-services/app-navigate'; import { TruncateHorizontalComponents } from '../../../common/util'; import { getDataPlugin, getUiSettings } from '../../../../kibana-services'; import { FilterManager } from '../../../../../../../src/plugins/data/public/'; -import { formatUIDate } from '../../../../react-services/time-service'; +import { beautifyDate } from './lib/'; export class Details extends Component { props!: { currentItem: { @@ -132,28 +132,28 @@ export class Details extends Component { name: 'Last full scan', icon: 'clock', link: false, - transformValue: this.beautifyDate + transformValue: beautifyDate }, { field: 'last_partial_scan', name: 'Last partial scan', icon: 'clock', link: false, - transformValue: this.beautifyDate + transformValue: beautifyDate }, { field: 'published', name: 'Published', icon: 'clock', link: false, - transformValue: this.beautifyDate + transformValue: beautifyDate }, { field: 'updated', name: 'Updated', icon: 'clock', link: false, - transformValue: this.beautifyDate + transformValue: beautifyDate }, { field: 'external_references', @@ -165,12 +165,7 @@ export class Details extends Component { ]; } - // This method was created because Wazuh API returns 1970-01-01T00:00:00Z dates or undefined ones - // when vulnerability module is not configured - // its meant to render nothing when such date is received - beautifyDate(date?: string) { - return date && !['1970-01-01T00:00:00Z', '-'].includes(date) ? formatUIDate(date) : '-'; - } + viewInEvents = (ev) => { const { cve } = this.props.currentItem; diff --git a/public/components/agents/vuls/inventory/lib/index.ts b/public/components/agents/vuls/inventory/lib/index.ts index 54579ea0ab..3db5ec6559 100644 --- a/public/components/agents/vuls/inventory/lib/index.ts +++ b/public/components/agents/vuls/inventory/lib/index.ts @@ -1 +1,2 @@ -export * from './api-requests'; \ No newline at end of file +export * from './api-requests'; +export * from './utils'; diff --git a/public/components/agents/vuls/inventory/lib/utils.ts b/public/components/agents/vuls/inventory/lib/utils.ts new file mode 100644 index 0000000000..bc37df757b --- /dev/null +++ b/public/components/agents/vuls/inventory/lib/utils.ts @@ -0,0 +1,10 @@ +import { formatUIDate } from '../../../../../react-services/time-service'; + +// This method was created because Wazuh API returns 1970-01-01T00:00:00Z dates or undefined ones +// when vulnerability module is not configured +// its meant to render nothing when such date is received +export function beautifyDate(date?: string) { + return date && + (!['-'].includes(date) && !date.startsWith('1970')) ? + formatUIDate(date) : '-'; +}