From e2df250c92fe894dfc34624bd29062a77b68d3a0 Mon Sep 17 00:00:00 2001 From: samdbeckham Date: Wed, 14 Aug 2019 17:44:03 +0100 Subject: [PATCH 1/4] Moves container scanning logic to the backend - Uses the baceng API to parse container scanning logic on the MR page. - Maps the slightly misaligned data in the vulnerabilities - Uses polling because the end point is a polling one - Adds an action for storing the endpoint in vuex - Adds a new action for calling the endpoint - Puts all the above behind a feature flag - Adds action tests - Adds mutation tests - Adds component tests - Fixes issues the tests brought up - - Text generation failed without a head or base path - - Report visibilty failed without a head or base path --- .../grouped_security_reports_app.vue | 21 ++- .../security_reports/store/actions.js | 50 ++++++ .../security_reports/store/mutation_types.js | 2 + .../security_reports/store/mutations.js | 21 +++ .../security_reports/store/state.js | 1 + .../security_reports/store/utils.js | 4 +- .../security_reports/store/mutations_spec.js | 46 ++++++ .../grouped_security_reports_app_spec.js | 48 ++++++ .../security_reports/store/actions_spec.js | 143 ++++++++++++++++++ 9 files changed, 332 insertions(+), 4 deletions(-) diff --git a/ee/app/assets/javascripts/vue_shared/security_reports/grouped_security_reports_app.vue b/ee/app/assets/javascripts/vue_shared/security_reports/grouped_security_reports_app.vue index 5ed3a99b3c6d0d..114f2f69ca39a2 100644 --- a/ee/app/assets/javascripts/vue_shared/security_reports/grouped_security_reports_app.vue +++ b/ee/app/assets/javascripts/vue_shared/security_reports/grouped_security_reports_app.vue @@ -168,6 +168,11 @@ export default { securityTab() { return `${this.pipelinePath}/security`; }, + shouldRenderSastContainer() { + const { head, diffEndpoint } = this.sastContainer.paths; + + return head || diffEndpoint; + }, }, created() { @@ -196,7 +201,17 @@ export default { this.fetchSastReports(); } - if (this.sastContainerHeadPath) { + const sastContainerDiffEndpoint = + gl && gl.mrWidgetData && gl.mrWidgetData.container_scanning_comparsion_path; + + if ( + gon.features && + gon.features.containerScanningMergeRequestReportApi && + sastContainerDiffEndpoint + ) { + this.setSastContainerDiffEndpoint(sastContainerDiffEndpoint); + this.fetchSastContainerDiff(); + } else if (this.sastContainerHeadPath) { this.setSastContainerHeadPath(this.sastContainerHeadPath); if (this.sastContainerBasePath) { @@ -257,6 +272,8 @@ export default { 'deleteDismissalComment', 'showDismissalDeleteButtons', 'hideDismissalDeleteButtons', + 'fetchSastContainerDiff', + 'setSastContainerDiffEndpoint', ]), ...mapActions('sast', { setSastHeadPath: 'setHeadPath', @@ -322,7 +339,7 @@ export default { /> -