Commit a6b29235 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '230380-add-detected-column' into 'master'

Add detected column with timestamp on security dashboards

See merge request gitlab-org/gitlab!41092
parents df6565e4 1239f3c4
...@@ -193,6 +193,10 @@ table { ...@@ -193,6 +193,10 @@ table {
} }
} }
.detected {
width: 9%;
}
.status { .status {
width: 8%; width: 8%;
} }
...@@ -202,7 +206,7 @@ table { ...@@ -202,7 +206,7 @@ table {
} }
.identifier { .identifier {
width: 12%; width: 16%;
} }
.scanner { .scanner {
......
...@@ -3,14 +3,14 @@ import { difference } from 'lodash'; ...@@ -3,14 +3,14 @@ import { difference } from 'lodash';
import { import {
GlFormCheckbox, GlFormCheckbox,
GlLink, GlLink,
GlDeprecatedSkeletonLoading as GlSkeletonLoading,
GlSprintf, GlSprintf,
GlTable, GlTable,
GlSkeletonLoading,
GlTooltipDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import RemediatedBadge from 'ee/vulnerabilities/components/remediated_badge.vue'; import RemediatedBadge from 'ee/vulnerabilities/components/remediated_badge.vue';
import FiltersProducedNoResults from 'ee/security_dashboard/components/empty_states/filters_produced_no_results.vue'; import FiltersProducedNoResults from 'ee/security_dashboard/components/empty_states/filters_produced_no_results.vue';
import DashboardHasNoVulnerabilities from 'ee/security_dashboard/components/empty_states/dashboard_has_no_vulnerabilities.vue'; import DashboardHasNoVulnerabilities from 'ee/security_dashboard/components/empty_states/dashboard_has_no_vulnerabilities.vue';
import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue'; import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue';
import VulnerabilityCommentIcon from 'ee/security_dashboard/components/vulnerability_comment_icon.vue'; import VulnerabilityCommentIcon from 'ee/security_dashboard/components/vulnerability_comment_icon.vue';
import IssueLink from 'ee/vulnerabilities/components/issue_link.vue'; import IssueLink from 'ee/vulnerabilities/components/issue_link.vue';
...@@ -18,6 +18,7 @@ import convertReportType from 'ee/vue_shared/security_reports/store/utils/conver ...@@ -18,6 +18,7 @@ import convertReportType from 'ee/vue_shared/security_reports/store/utils/conver
import getPrimaryIdentifier from 'ee/vue_shared/security_reports/store/utils/get_primary_identifier'; import getPrimaryIdentifier from 'ee/vue_shared/security_reports/store/utils/get_primary_identifier';
import SecurityScannerAlert from './security_scanner_alert.vue'; import SecurityScannerAlert from './security_scanner_alert.vue';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue'; import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import { formatDate } from '~/lib/utils/datetime_utility';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import SelectionSummary from './selection_summary.vue'; import SelectionSummary from './selection_summary.vue';
import { VULNERABILITIES_PER_PAGE } from '../store/constants'; import { VULNERABILITIES_PER_PAGE } from '../store/constants';
...@@ -43,6 +44,9 @@ export default { ...@@ -43,6 +44,9 @@ export default {
FiltersProducedNoResults, FiltersProducedNoResults,
DashboardHasNoVulnerabilities, DashboardHasNoVulnerabilities,
}, },
directives: {
GlTooltip: GlTooltipDirective,
},
props: { props: {
filters: { filters: {
type: Object, type: Object,
...@@ -129,6 +133,12 @@ export default { ...@@ -129,6 +133,12 @@ export default {
}, },
fields() { fields() {
const baseFields = [ const baseFields = [
{
key: 'detected',
label: s__('Vulnerability|Detected'),
thClass: 'detected',
tdClass: 'detected',
},
{ {
key: 'state', key: 'state',
label: s__('Vulnerability|Status'), label: s__('Vulnerability|Status'),
...@@ -257,6 +267,12 @@ export default { ...@@ -257,6 +267,12 @@ export default {
issue(item) { issue(item) {
return item.issueLinks?.nodes[0]?.issue; return item.issueLinks?.nodes[0]?.issue;
}, },
formatDate(item) {
return formatDate(item.detectedAt, 'yyyy-mm-dd');
},
formatDateTooltip(item) {
return formatDate(item.detectedAt);
},
hasComments(item) { hasComments(item) {
return item.userNotesCount > 0; return item.userNotesCount > 0;
}, },
...@@ -320,6 +336,12 @@ export default { ...@@ -320,6 +336,12 @@ export default {
/> />
</template> </template>
<template #cell(detected)="{ item }">
<time v-gl-tooltip :data-testid="`detected-${item.id}`" :title="formatDateTooltip(item)">
{{ formatDate(item) }}
</time>
</template>
<template #cell(state)="{ item }"> <template #cell(state)="{ item }">
<span class="text-capitalize js-status">{{ item.state.toLowerCase() }}</span> <span class="text-capitalize js-status">{{ item.state.toLowerCase() }}</span>
</template> </template>
......
...@@ -3,6 +3,7 @@ fragment Vulnerability on Vulnerability { ...@@ -3,6 +3,7 @@ fragment Vulnerability on Vulnerability {
title title
state state
severity severity
detectedAt
vulnerabilityPath vulnerabilityPath
resolvedOnDefaultBranch resolvedOnDefaultBranch
userNotesCount userNotesCount
......
---
title: Add detected column with timestamp on security dashboards
merge_request: 41092
author:
type: added
export const generateVulnerabilities = () => [ export const generateVulnerabilities = () => [
{ {
id: 'id_0', id: 'id_0',
detectedAt: '2020-07-29T15:36:54Z',
identifiers: [ identifiers: [
{ {
externalType: 'cve', externalType: 'cve',
...@@ -28,6 +29,7 @@ export const generateVulnerabilities = () => [ ...@@ -28,6 +29,7 @@ export const generateVulnerabilities = () => [
}, },
{ {
id: 'id_1', id: 'id_1',
detectedAt: '2020-07-22T19:31:24Z',
identifiers: [ identifiers: [
{ {
externalType: 'gemnasium', externalType: 'gemnasium',
...@@ -51,6 +53,7 @@ export const generateVulnerabilities = () => [ ...@@ -51,6 +53,7 @@ export const generateVulnerabilities = () => [
}, },
{ {
id: 'id_2', id: 'id_2',
detectedAt: '2020-08-22T20:00:12Z',
identifiers: [], identifiers: [],
title: 'Vulnerability 2', title: 'Vulnerability 2',
severity: 'high', severity: 'high',
......
...@@ -199,6 +199,13 @@ describe('Vulnerability list component', () => { ...@@ -199,6 +199,13 @@ describe('Vulnerability list component', () => {
expect(cellText).toEqual(location.image); expect(cellText).toEqual(location.image);
}); });
it('should display the detected time', () => {
const { id } = newVulnerabilities[1];
const cell = findDataCell(`detected-${id}`);
expect(cell.text()).toEqual(`2020-07-22`);
expect(cell.attributes('title')).toEqual('Jul 22, 2020 7:31pm GMT+0000');
});
it('should display the vulnerability locations for code', () => { it('should display the vulnerability locations for code', () => {
const { id, project, location } = newVulnerabilities[1]; const { id, project, location } = newVulnerabilities[1];
const cellText = findCellText(`location-${id}`); const cellText = findCellText(`location-${id}`);
......
...@@ -27744,6 +27744,9 @@ msgstr "" ...@@ -27744,6 +27744,9 @@ msgstr ""
msgid "Vulnerability|Description" msgid "Vulnerability|Description"
msgstr "" msgstr ""
msgid "Vulnerability|Detected"
msgstr ""
msgid "Vulnerability|Evidence" msgid "Vulnerability|Evidence"
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment