Commit 448dcf9d authored by Phil Hughes's avatar Phil Hughes

Merge branch '45340-sast-all-issues' into 'master'

Resolve SAST report in MR widget is not rendering list of `all` issues

Closes #5664 and gitlab-ce#45352

See merge request gitlab-org/gitlab-ee!5363
parents cf6cfd0a b6166dee
...@@ -34,16 +34,21 @@ export default { ...@@ -34,16 +34,21 @@ export default {
required: false, required: false,
default: () => [], default: () => [],
}, },
isFullReportVisible: {
type: Boolean,
required: false,
default: false,
},
type: { type: {
type: String, type: String,
required: true, required: true,
}, },
}, },
data() {
return {
isFullReportVisible: false,
};
},
methods: {
openFullReport() {
this.isFullReportVisible = true;
},
},
}; };
</script> </script>
<template> <template>
...@@ -81,5 +86,14 @@ export default { ...@@ -81,5 +86,14 @@ export default {
status="success" status="success"
:issues="resolvedIssues" :issues="resolvedIssues"
/> />
<button
v-if="allIssues.length && !isFullReportVisible"
type="button"
class="btn-link btn-blank prepend-left-10 js-expand-full-list break-link"
@click="openFullReport"
>
{{ s__("ciReport|Show complete code vulnerabilities report") }}
</button>
</div> </div>
</template> </template>
...@@ -78,7 +78,6 @@ export default { ...@@ -78,7 +78,6 @@ export default {
return { return {
collapseText: __('Expand'), collapseText: __('Expand'),
isCollapsed: true, isCollapsed: true,
isFullReportVisible: false,
}; };
}, },
...@@ -125,9 +124,6 @@ export default { ...@@ -125,9 +124,6 @@ export default {
const text = this.isCollapsed ? __('Expand') : __('Collapse'); const text = this.isCollapsed ? __('Expand') : __('Collapse');
this.collapseText = text; this.collapseText = text;
}, },
openFullReport() {
this.isFullReportVisible = true;
},
}, },
}; };
</script> </script>
...@@ -182,17 +178,7 @@ export default { ...@@ -182,17 +178,7 @@ export default {
:resolved-issues="resolvedIssues" :resolved-issues="resolvedIssues"
:all-issues="allIssues" :all-issues="allIssues"
:type="type" :type="type"
:is-full-report-visible="isFullReportVisible"
/> />
<button
v-if="allIssues.length && !isFullReportVisible"
type="button"
class="btn-link btn-blank prepend-left-10 js-expand-full-list break-link"
@click="openFullReport"
>
{{ s__("ciReport|Show complete code vulnerabilities report") }}
</button>
</slot> </slot>
</div> </div>
</section> </section>
......
...@@ -189,8 +189,8 @@ ...@@ -189,8 +189,8 @@
/> />
<issues-list <issues-list
class="report-block-group-list" class="js-sast-issue-list report-block-group-list"
v-if="sast.newIssues.length" v-if="sast.newIssues.length || sast.resolvedIssues.length || sast.allIssues.length"
:unresolved-issues="sast.newIssues" :unresolved-issues="sast.newIssues"
:resolved-issues="sast.resolvedIssues" :resolved-issues="sast.resolvedIssues"
:all-issues="sast.allIssues" :all-issues="sast.allIssues"
...@@ -207,8 +207,9 @@ ...@@ -207,8 +207,9 @@
/> />
<issues-list <issues-list
class="report-block-group-list" class="js-dss-issue-list report-block-group-list"
v-if="dependencyScanning.newIssues.length" v-if="dependencyScanning.newIssues.length ||
dependencyScanning.resolvedIssues.length || dependencyScanning.allIssues.length"
:unresolved-issues="dependencyScanning.newIssues" :unresolved-issues="dependencyScanning.newIssues"
:resolved-issues="dependencyScanning.resolvedIssues" :resolved-issues="dependencyScanning.resolvedIssues"
:all-issues="dependencyScanning.allIssues" :all-issues="dependencyScanning.allIssues"
...@@ -226,7 +227,7 @@ ...@@ -226,7 +227,7 @@
<issues-list <issues-list
class="report-block-group-list" class="report-block-group-list"
v-if="sastContainer.newIssues.length" v-if="sastContainer.newIssues.length || sastContainer.resolvedIssues.length"
:unresolved-issues="sastContainer.newIssues" :unresolved-issues="sastContainer.newIssues"
:neutral-issues="sastContainer.resolvedIssues" :neutral-issues="sastContainer.resolvedIssues"
:type="$options.sastContainer" :type="$options.sastContainer"
...@@ -243,7 +244,7 @@ ...@@ -243,7 +244,7 @@
<issues-list <issues-list
class="report-block-group-list" class="report-block-group-list"
v-if="dast.newIssues.length" v-if="dast.newIssues.length || dast.resolvedIssues.length"
:unresolved-issues="dast.newIssues" :unresolved-issues="dast.newIssues"
:resolved-issues="dast.resolvedIssues" :resolved-issues="dast.resolvedIssues"
:type="$options.dast" :type="$options.dast"
......
.split-report-section { .split-report-section {
border-bottom: 1px solid $gray-darker; border-bottom: 1px solid $gray-darker;
.report-block-list { .report-block-container {
max-height: 500px; max-height: 500px;
overflow: auto; overflow: auto;
} }
......
---
title: Render show all report for sast and dependency scanning
merge_request: 5363
author:
type: fixed
...@@ -11,6 +11,8 @@ import { ...@@ -11,6 +11,8 @@ import {
dockerBaseReport, dockerBaseReport,
dast, dast,
dastBase, dastBase,
sastHeadAllIssues,
sastBaseAllIssues,
} from './mock_data'; } from './mock_data';
describe('Grouped security reports app', () => { describe('Grouped security reports app', () => {
...@@ -72,9 +74,15 @@ describe('Grouped security reports app', () => { ...@@ -72,9 +74,15 @@ describe('Grouped security reports app', () => {
); );
expect(vm.$el.querySelector('.js-collapse-btn').textContent.trim()).toEqual('Expand'); expect(vm.$el.querySelector('.js-collapse-btn').textContent.trim()).toEqual('Expand');
expect(removeBreakLine(vm.$el.textContent)).toContain('SAST resulted in error while loading results'); expect(removeBreakLine(vm.$el.textContent)).toContain(
expect(removeBreakLine(vm.$el.textContent)).toContain('Dependency scanning resulted in error while loading results'); 'SAST resulted in error while loading results',
expect(vm.$el.textContent).toContain('Container scanning resulted in error while loading results'); );
expect(removeBreakLine(vm.$el.textContent)).toContain(
'Dependency scanning resulted in error while loading results',
);
expect(vm.$el.textContent).toContain(
'Container scanning resulted in error while loading results',
);
expect(vm.$el.textContent).toContain('DAST resulted in error while loading results'); expect(vm.$el.textContent).toContain('DAST resulted in error while loading results');
done(); done();
}, 0); }, 0);
...@@ -161,12 +169,80 @@ describe('Grouped security reports app', () => { ...@@ -161,12 +169,80 @@ describe('Grouped security reports app', () => {
); );
expect(vm.$el.querySelector('.js-collapse-btn').textContent.trim()).toEqual('Expand'); expect(vm.$el.querySelector('.js-collapse-btn').textContent.trim()).toEqual('Expand');
expect(removeBreakLine(vm.$el.textContent)).toContain('SAST detected 2 new vulnerabilities and 1 fixed vulnerability'); expect(removeBreakLine(vm.$el.textContent)).toContain(
expect(removeBreakLine(vm.$el.textContent)).toContain('Dependency scanning detected 2 new vulnerabilities and 1 fixed vulnerability'); 'SAST detected 2 new vulnerabilities and 1 fixed vulnerability',
);
expect(removeBreakLine(vm.$el.textContent)).toContain(
'Dependency scanning detected 2 new vulnerabilities and 1 fixed vulnerability',
);
expect(vm.$el.textContent).toContain('Container scanning detected 1 new vulnerability'); expect(vm.$el.textContent).toContain('Container scanning detected 1 new vulnerability');
expect(vm.$el.textContent).toContain('DAST detected 1 new vulnerability'); expect(vm.$el.textContent).toContain('DAST detected 1 new vulnerability');
done(); done();
}, 0); }, 0);
}); });
}); });
describe('with all issues for sast and dependency scanning', () => {
beforeEach(() => {
mock.onGet('sast_head.json').reply(200, sastHeadAllIssues);
mock.onGet('sast_base.json').reply(200, sastBaseAllIssues);
mock.onGet('dast_head.json').reply(200, dast);
mock.onGet('dast_base.json').reply(200, dastBase);
mock.onGet('sast_container_head.json').reply(200, dockerReport);
mock.onGet('sast_container_base.json').reply(200, dockerBaseReport);
mock.onGet('dss_head.json').reply(200, sastHeadAllIssues);
mock.onGet('dss_base.json').reply(200, sastBaseAllIssues);
vm = mountComponent(Component, {
headBlobPath: 'path',
baseBlobPath: 'path',
sastHeadPath: 'sast_head.json',
sastBasePath: 'sast_base.json',
dastHeadPath: 'dast_head.json',
dastBasePath: 'dast_base.json',
sastContainerHeadPath: 'sast_container_head.json',
sastContainerBasePath: 'sast_container_base.json',
dependencyScanningHeadPath: 'dss_head.json',
dependencyScanningBasePath: 'dss_base.json',
sastHelpPath: 'path',
sastContainerHelpPath: 'path',
dastHelpPath: 'path',
dependencyScanningHelpPath: 'path',
});
});
it('render show all issues button for sast', done => {
setTimeout(() => {
expect(vm.$el.querySelector('.js-sast-issue-list .js-expand-full-list')).not.toBeNull();
vm.$el.querySelector('.js-sast-issue-list .js-expand-full-list').click();
vm
.$nextTick()
.then(() => {
expect(vm.$el.querySelector('.js-sast-issue-list').textContent).toContain(
sastHeadAllIssues[0].message,
);
})
.then(done)
.catch(done.fail);
}, 0);
});
it('render show all issues button for dependency scanning', done => {
setTimeout(() => {
expect(vm.$el.querySelector('.js-dss-issue-list .js-expand-full-list')).not.toBeNull();
vm.$el.querySelector('.js-dss-issue-list .js-expand-full-list').click();
vm
.$nextTick()
.then(() => {
expect(vm.$el.querySelector('.js-dss-issue-list').textContent).toContain(
sastHeadAllIssues[0].message,
);
})
.then(done)
.catch(done.fail);
}, 0);
});
});
}); });
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