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

Fix default last scan date formatter #4975

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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:/wazuh/wazuh-kibana-app/issues/4653)
- Fixed WAZUH_PROTOCOL param suggestion [#4849](https:/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:/wazuh/wazuh-kibana-app/pull/4876) [#4880](https:/wazuh/wazuh-kibana-app/pull/4880)
- Fixed vulnerabilities default last scan date formatter [#4975](https:/wazuh/wazuh-kibana-app/pull/4975)

## Wazuh v4.3.10 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4311

Expand Down
11 changes: 3 additions & 8 deletions public/components/agents/vuls/inventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
Expand Down
17 changes: 6 additions & 11 deletions public/components/agents/vuls/inventory/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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',
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion public/components/agents/vuls/inventory/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './api-requests';
export * from './api-requests';
export * from './utils';
10 changes: 10 additions & 0 deletions public/components/agents/vuls/inventory/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -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) : '-';
}