Commit 7b38e53d authored by David Pisek's avatar David Pisek Committed by Vitaly Slobodin

Refactor vulnerability count query

* Refactor graphql query to support different scopes
* Change severity count component to accept `scope` and `fullPath`
parent 651e8d4b
...@@ -249,7 +249,7 @@ to configure daily security scans. ...@@ -249,7 +249,7 @@ to configure daily security scans.
Each vulnerability report contains vulnerabilities from the latest scans that were merged Each vulnerability report contains vulnerabilities from the latest scans that were merged
into the default branch. into the default branch.
![Vulnerability Report](img/group_vulnerability_report_v13_4.png) ![Vulnerability Report](img/group_vulnerability_report_v13_7.png)
You can filter which vulnerabilities the vulnerability report displays by: You can filter which vulnerabilities the vulnerability report displays by:
......
...@@ -6,6 +6,8 @@ import Filters from 'ee/security_dashboard/components/first_class_vulnerability_ ...@@ -6,6 +6,8 @@ import Filters from 'ee/security_dashboard/components/first_class_vulnerability_
import CsvExportButton from './csv_export_button.vue'; import CsvExportButton from './csv_export_button.vue';
import vulnerableProjectsQuery from '../graphql/vulnerable_projects.query.graphql'; import vulnerableProjectsQuery from '../graphql/vulnerable_projects.query.graphql';
import DashboardNotConfigured from './empty_states/group_dashboard_not_configured.vue'; import DashboardNotConfigured from './empty_states/group_dashboard_not_configured.vue';
import VulnerabilitiesCountList from './vulnerability_count_list.vue';
import { vulnerabilitiesSeverityCountScopes } from '../constants';
export default { export default {
components: { components: {
...@@ -15,6 +17,7 @@ export default { ...@@ -15,6 +17,7 @@ export default {
CsvExportButton, CsvExportButton,
DashboardNotConfigured, DashboardNotConfigured,
GlLoadingIcon, GlLoadingIcon,
VulnerabilitiesCountList,
}, },
props: { props: {
groupFullPath: { groupFullPath: {
...@@ -60,6 +63,7 @@ export default { ...@@ -60,6 +63,7 @@ export default {
this.filters = filters; this.filters = filters;
}, },
}, },
vulnerabilitiesSeverityCountScopes,
}; };
</script> </script>
...@@ -69,12 +73,19 @@ export default { ...@@ -69,12 +73,19 @@ export default {
<dashboard-not-configured v-if="isNotYetConfigured" /> <dashboard-not-configured v-if="isNotYetConfigured" />
<security-dashboard-layout v-else :class="{ 'gl-display-none': !projectsWereFetched }"> <security-dashboard-layout v-else :class="{ 'gl-display-none': !projectsWereFetched }">
<template #header> <template #header>
<header class="page-title-holder flex-fill d-flex align-items-center"> <div>
<h2 class="page-title flex-grow"> <header class="gl-my-6 gl-display-flex gl-align-items-center">
<h2 class="gl-flex-grow-1 gl-my-0">
{{ s__('SecurityReports|Vulnerability Report') }} {{ s__('SecurityReports|Vulnerability Report') }}
</h2> </h2>
<csv-export-button :vulnerabilities-export-endpoint="vulnerabilitiesExportEndpoint" /> <csv-export-button :vulnerabilities-export-endpoint="vulnerabilitiesExportEndpoint" />
</header> </header>
<vulnerabilities-count-list
:scope="$options.vulnerabilitiesSeverityCountScopes.group"
:full-path="groupFullPath"
:filters="filters"
/>
</div>
</template> </template>
<template #sticky> <template #sticky>
<filters :projects="projects" @filterChange="handleFilterChange" /> <filters :projects="projects" @filterChange="handleFilterChange" />
......
---
title: Add vulnerability severities count to group report
merge_request: 47861
author:
type: added
...@@ -6,6 +6,7 @@ import FirstClassGroupDashboard from 'ee/security_dashboard/components/first_cla ...@@ -6,6 +6,7 @@ import FirstClassGroupDashboard from 'ee/security_dashboard/components/first_cla
import FirstClassGroupVulnerabilities from 'ee/security_dashboard/components/first_class_group_security_dashboard_vulnerabilities.vue'; import FirstClassGroupVulnerabilities from 'ee/security_dashboard/components/first_class_group_security_dashboard_vulnerabilities.vue';
import Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue'; import Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue';
import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue'; import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue';
import VulnerabilitiesCountList from 'ee/security_dashboard/components/vulnerability_count_list.vue';
describe('First Class Group Dashboard Component', () => { describe('First Class Group Dashboard Component', () => {
let wrapper; let wrapper;
...@@ -21,6 +22,7 @@ describe('First Class Group Dashboard Component', () => { ...@@ -21,6 +22,7 @@ describe('First Class Group Dashboard Component', () => {
const findFilters = () => wrapper.find(Filters); const findFilters = () => wrapper.find(Filters);
const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const findLoadingIcon = () => wrapper.find(GlLoadingIcon);
const findEmptyState = () => wrapper.find(DashboardNotConfigured); const findEmptyState = () => wrapper.find(DashboardNotConfigured);
const findVulnerabilitiesCountList = () => wrapper.find(VulnerabilitiesCountList);
const createWrapper = ({ data } = {}) => { const createWrapper = ({ data } = {}) => {
return shallowMount(FirstClassGroupDashboard, { return shallowMount(FirstClassGroupDashboard, {
...@@ -108,6 +110,14 @@ describe('First Class Group Dashboard Component', () => { ...@@ -108,6 +110,14 @@ describe('First Class Group Dashboard Component', () => {
it('should not display the dashboard not configured component', () => { it('should not display the dashboard not configured component', () => {
expect(findEmptyState().exists()).toBe(false); expect(findEmptyState().exists()).toBe(false);
}); });
it('should display the vulnerability count list with the correct data', () => {
expect(findVulnerabilitiesCountList().props()).toMatchObject({
scope: 'group',
fullPath: groupFullPath,
filters: wrapper.vm.filters,
});
});
}); });
describe('when has no projects', () => { describe('when has no projects', () => {
......
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