Commit fbb3a6ce authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '196719-rename-sast-container-to-container-scanning' into 'master'

Frontend: Rename Sast Container to Container Scanning

See merge request gitlab-org/gitlab!23814
parents e8c92405 9d9afa0b
......@@ -3,7 +3,7 @@ import CodequalityIssueBody from 'ee/vue_merge_request_widget/components/codequa
import BlockingMergeRequestsBody from 'ee/vue_merge_request_widget/components/blocking_merge_requests/blocking_merge_request_body.vue';
import LicenseIssueBody from 'ee/vue_shared/license_management/components/license_issue_body.vue';
import SastIssueBody from 'ee/vue_shared/security_reports/components/sast_issue_body.vue';
import SastContainerIssueBody from 'ee/vue_shared/security_reports/components/sast_container_issue_body.vue';
import ContainerScanningIssueBody from 'ee/vue_shared/security_reports/components/container_scanning_issue_body.vue';
import DastIssueBody from 'ee/vue_shared/security_reports/components/dast_issue_body.vue';
import MetricsReportsIssueBody from 'ee/vue_shared/metrics_reports/components/metrics_reports_issue_body.vue';
import {
......@@ -16,7 +16,7 @@ export const components = {
PerformanceIssueBody,
CodequalityIssueBody,
LicenseIssueBody,
SastContainerIssueBody,
ContainerScanningIssueBody,
SastIssueBody,
DastIssueBody,
MetricsReportsIssueBody,
......@@ -28,7 +28,7 @@ export const componentNames = {
PerformanceIssueBody: PerformanceIssueBody.name,
CodequalityIssueBody: CodequalityIssueBody.name,
LicenseIssueBody: LicenseIssueBody.name,
SastContainerIssueBody: SastContainerIssueBody.name,
ContainerScanningIssueBody: ContainerScanningIssueBody.name,
SastIssueBody: SastIssueBody.name,
DastIssueBody: DastIssueBody.name,
MetricsReportsIssueBody: MetricsReportsIssueBody.name,
......
......@@ -304,7 +304,7 @@ export default {
:enabled-reports="mr.enabledSecurityReports"
:sast-help-path="mr.sastHelp"
:dast-help-path="mr.dastHelp"
:sast-container-help-path="mr.sastContainerHelp"
:container-scanning-help-path="mr.containerScanningHelp"
:dependency-scanning-help-path="mr.dependencyScanningHelp"
:vulnerability-feedback-path="mr.vulnerabilityFeedbackPath"
:vulnerability-feedback-help-path="mr.vulnerabilityFeedbackHelpPath"
......
......@@ -11,7 +11,7 @@ export default class MergeRequestStore extends CEMergeRequestStore {
this.headBlobPath = blobPath.head_path || '';
this.baseBlobPath = blobPath.base_path || '';
this.sastHelp = data.sast_help_path;
this.sastContainerHelp = data.sast_container_help_path;
this.containerScanningHelp = data.container_scanning_help_path;
this.dastHelp = data.dast_help_path;
this.dependencyScanningHelp = data.dependency_scanning_help_path;
this.vulnerabilityFeedbackPath = data.vulnerability_feedback_path;
......
<script>
/**
* Renders SAST CONTAINER body text
* Renders CONTAINER SCANNING body text
* [priority]: [name] in [link]:[line]
*/
import ModalOpenName from '~/reports/components/modal_open_name.vue';
import { humanize } from '~/lib/utils/text_utility';
export default {
name: 'SastContainerIssueBody',
name: 'ContainerScanningIssueBody',
components: {
ModalOpenName,
},
......
......@@ -51,7 +51,7 @@ export default {
required: false,
default: '',
},
sastContainerHelpPath: {
containerScanningHelpPath: {
type: String,
required: false,
default: '',
......@@ -118,7 +118,7 @@ export default {
computed: {
...mapState([
'sast',
'sastContainer',
'containerScanning',
'dast',
'dependencyScanning',
'summaryCounts',
......@@ -129,10 +129,10 @@ export default {
...mapGetters([
'groupedSummaryText',
'summaryStatus',
'groupedSastContainerText',
'groupedContainerScanningText',
'groupedDastText',
'groupedDependencyText',
'sastContainerStatusIcon',
'containerScanningStatusIcon',
'dastStatusIcon',
'dependencyScanningStatusIcon',
'isBaseSecurityReportOutOfDate',
......@@ -203,8 +203,8 @@ export default {
const containerScanningDiffEndpoint = gl?.mrWidgetData?.container_scanning_comparison_path;
if (containerScanningDiffEndpoint && this.hasContainerScanningReports) {
this.setSastContainerDiffEndpoint(containerScanningDiffEndpoint);
this.fetchSastContainerDiff();
this.setContainerScanningDiffEndpoint(containerScanningDiffEndpoint);
this.fetchContainerScanningDiff();
}
// eslint-disable-next-line camelcase
......@@ -248,8 +248,8 @@ export default {
'deleteDismissalComment',
'showDismissalDeleteButtons',
'hideDismissalDeleteButtons',
'fetchSastContainerDiff',
'setSastContainerDiffEndpoint',
'fetchContainerScanningDiff',
'setContainerScanningDiffEndpoint',
'fetchDependencyScanningDiff',
'setDependencyScanningDiffEndpoint',
'fetchDastDiff',
......@@ -327,18 +327,18 @@ export default {
<template v-if="hasContainerScanningReports">
<summary-row
:summary="groupedSastContainerText"
:status-icon="sastContainerStatusIcon"
:popover-options="sastContainerPopover"
class="js-sast-container"
:summary="groupedContainerScanningText"
:status-icon="containerScanningStatusIcon"
:popover-options="containerScanningPopover"
class="js-container-scanning"
data-qa-selector="container_scan_report"
/>
<issues-list
v-if="sastContainer.newIssues.length || sastContainer.resolvedIssues.length"
:unresolved-issues="sastContainer.newIssues"
:resolved-issues="sastContainer.resolvedIssues"
:component="$options.componentNames.SastContainerIssueBody"
v-if="containerScanning.newIssues.length || containerScanning.resolvedIssues.length"
:unresolved-issues="containerScanning.newIssues"
:resolved-issues="containerScanning.resolvedIssues"
:component="$options.componentNames.ContainerScanningIssueBody"
class="report-block-group-list"
/>
</template>
......
......@@ -25,7 +25,7 @@ export default {
),
};
},
sastContainerPopover() {
containerScanningPopover() {
return {
title: s__(
'ciReport|Container scanning detects known vulnerabilities in your docker images.',
......@@ -33,7 +33,7 @@ export default {
content: sprintf(
s__('ciReport|%{linkStartTag}Learn more about Container Scanning %{linkEndTag}'),
{
linkStartTag: getLinkStartTag(this.sastContainerHelpPath),
linkStartTag: getLinkStartTag(this.containerScanningHelpPath),
linkEndTag,
},
false,
......
......@@ -48,26 +48,26 @@ export const setCanCreateFeedbackPermission = ({ commit }, permission) =>
commit(types.SET_CAN_CREATE_FEEDBACK_PERMISSION, permission);
/**
* SAST CONTAINER
* CONTAINER SCANNING
*/
export const setSastContainerDiffEndpoint = ({ commit }, path) =>
commit(types.SET_SAST_CONTAINER_DIFF_ENDPOINT, path);
export const setContainerScanningDiffEndpoint = ({ commit }, path) =>
commit(types.SET_CONTAINER_SCANNING_DIFF_ENDPOINT, path);
export const requestSastContainerReports = ({ commit }) =>
commit(types.REQUEST_SAST_CONTAINER_REPORTS);
export const requestContainerScanningDiff = ({ commit }) =>
commit(types.REQUEST_CONTAINER_SCANNING_DIFF);
export const receiveSastContainerDiffSuccess = ({ commit }, response) =>
commit(types.RECEIVE_SAST_CONTAINER_DIFF_SUCCESS, response);
export const receiveContainerScanningDiffSuccess = ({ commit }, response) =>
commit(types.RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS, response);
export const receiveSastContainerDiffError = ({ commit }) =>
commit(types.RECEIVE_SAST_CONTAINER_DIFF_ERROR);
export const receiveContainerScanningDiffError = ({ commit }) =>
commit(types.RECEIVE_CONTAINER_SCANNING_DIFF_ERROR);
export const fetchSastContainerDiff = ({ state, dispatch }) => {
dispatch('requestSastContainerReports');
export const fetchContainerScanningDiff = ({ state, dispatch }) => {
dispatch('requestContainerScanningDiff');
return Promise.all([
pollUntilComplete(state.sastContainer.paths.diffEndpoint),
pollUntilComplete(state.containerScanning.paths.diffEndpoint),
axios.get(state.vulnerabilityFeedbackPath, {
params: {
category: 'container_scanning',
......@@ -75,13 +75,13 @@ export const fetchSastContainerDiff = ({ state, dispatch }) => {
}),
])
.then(values => {
dispatch('receiveSastContainerDiffSuccess', {
dispatch('receiveContainerScanningDiffSuccess', {
diff: values[0].data,
enrichData: values[1].data,
});
})
.catch(() => {
dispatch('receiveSastContainerDiffError');
dispatch('receiveContainerScanningDiffError');
});
};
......
......@@ -3,9 +3,9 @@ import { countIssues, groupedTextBuilder, statusIcon, groupedReportText } from '
import { LOADING, ERROR, SUCCESS } from './constants';
import messages from './messages';
export const groupedSastContainerText = ({ sastContainer }) =>
export const groupedContainerScanningText = ({ containerScanning }) =>
groupedReportText(
sastContainer,
containerScanning,
messages.CONTAINER_SCANNING,
messages.CONTAINER_SCANNING_HAS_ERROR,
messages.CONTAINER_SCANNING_IS_LOADING,
......@@ -23,7 +23,7 @@ export const groupedDependencyText = ({ dependencyScanning }) =>
);
export const summaryCounts = state =>
[state.sast, state.sastContainer, state.dast, state.dependencyScanning].reduce(
[state.sast, state.containerScanning, state.dast, state.dependencyScanning].reduce(
(acc, report) => {
const curr = countIssues(report);
acc.added += curr.added;
......@@ -81,8 +81,12 @@ export const summaryStatus = (state, getters) => {
return SUCCESS;
};
export const sastContainerStatusIcon = ({ sastContainer }) =>
statusIcon(sastContainer.isLoading, sastContainer.hasError, sastContainer.newIssues.length);
export const containerScanningStatusIcon = ({ containerScanning }) =>
statusIcon(
containerScanning.isLoading,
containerScanning.hasError,
containerScanning.newIssues.length,
);
export const dastStatusIcon = ({ dast }) =>
statusIcon(dast.isLoading, dast.hasError, dast.newIssues.length);
......@@ -97,43 +101,43 @@ export const dependencyScanningStatusIcon = ({ dependencyScanning }) =>
export const areReportsLoading = state =>
state.sast.isLoading ||
state.dast.isLoading ||
state.sastContainer.isLoading ||
state.containerScanning.isLoading ||
state.dependencyScanning.isLoading;
export const areAllReportsLoading = state =>
state.sast.isLoading &&
state.dast.isLoading &&
state.sastContainer.isLoading &&
state.containerScanning.isLoading &&
state.dependencyScanning.isLoading;
export const allReportsHaveError = state =>
state.sast.hasError &&
state.dast.hasError &&
state.sastContainer.hasError &&
state.containerScanning.hasError &&
state.dependencyScanning.hasError;
export const anyReportHasError = state =>
state.sast.hasError ||
state.dast.hasError ||
state.sastContainer.hasError ||
state.containerScanning.hasError ||
state.dependencyScanning.hasError;
export const noBaseInAllReports = state =>
!state.sast.hasBaseReport &&
!state.dast.hasBaseReport &&
!state.sastContainer.hasBaseReport &&
!state.containerScanning.hasBaseReport &&
!state.dependencyScanning.hasBaseReport;
export const anyReportHasIssues = state =>
state.sast.newIssues.length > 0 ||
state.dast.newIssues.length > 0 ||
state.sastContainer.newIssues.length > 0 ||
state.containerScanning.newIssues.length > 0 ||
state.dependencyScanning.newIssues.length > 0;
export const isBaseSecurityReportOutOfDate = state =>
state.sast.baseReportOutofDate ||
state.dast.baseReportOutofDate ||
state.sastContainer.baseReportOutofDate ||
state.containerScanning.baseReportOutofDate ||
state.dependencyScanning.baseReportOutofDate;
// prevent babel-plugin-rewire from generating an invalid default during karma tests
......
......@@ -13,11 +13,11 @@ export const SET_PIPELINE_ID = 'SET_PIPELINE_ID';
export const SET_CAN_CREATE_ISSUE_PERMISSION = 'SET_CAN_CREATE_ISSUE_PERMISSION';
export const SET_CAN_CREATE_FEEDBACK_PERMISSION = 'SET_CAN_CREATE_FEEDBACK_PERMISSION';
// SAST CONTAINER
export const SET_SAST_CONTAINER_DIFF_ENDPOINT = 'SET_SAST_CONTAINER_DIFF_ENDPOINT';
export const REQUEST_SAST_CONTAINER_REPORTS = 'REQUEST_SAST_CONTAINER_REPORTS';
export const RECEIVE_SAST_CONTAINER_DIFF_SUCCESS = 'RECEIVE_SAST_CONTAINER_DIFF_SUCCESS';
export const RECEIVE_SAST_CONTAINER_DIFF_ERROR = 'RECEIVE_SAST_CONTAINER_DIFF_ERROR';
// CONTAINER SCANNING
export const SET_CONTAINER_SCANNING_DIFF_ENDPOINT = 'SET_CONTAINER_SCANNING_DIFF_ENDPOINT';
export const REQUEST_CONTAINER_SCANNING_DIFF = 'REQUEST_CONTAINER_SCANNING_DIFF';
export const RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS = 'RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS';
export const RECEIVE_CONTAINER_SCANNING_DIFF_ERROR = 'RECEIVE_CONTAINER_SCANNING_DIFF_ERROR';
// DAST
export const SET_DAST_DIFF_ENDPOINT = 'SET_DAST_DIFF_ENDPOINT';
......
......@@ -49,31 +49,31 @@ export default {
state.canCreateFeedbackPermission = permission;
},
// SAST CONTAINER
[types.SET_SAST_CONTAINER_DIFF_ENDPOINT](state, path) {
Vue.set(state.sastContainer.paths, 'diffEndpoint', path);
// CONTAINER SCANNING
[types.SET_CONTAINER_SCANNING_DIFF_ENDPOINT](state, path) {
Vue.set(state.containerScanning.paths, 'diffEndpoint', path);
},
[types.REQUEST_SAST_CONTAINER_REPORTS](state) {
Vue.set(state.sastContainer, 'isLoading', true);
[types.REQUEST_CONTAINER_SCANNING_DIFF](state) {
Vue.set(state.containerScanning, 'isLoading', true);
},
[types.RECEIVE_SAST_CONTAINER_DIFF_SUCCESS](state, { diff, enrichData }) {
[types.RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS](state, { diff, enrichData }) {
const { added, fixed, existing } = parseDiff(diff, enrichData);
const baseReportOutofDate = diff.base_report_out_of_date || false;
const hasBaseReport = Boolean(diff.base_report_created_at);
Vue.set(state.sastContainer, 'isLoading', false);
Vue.set(state.sastContainer, 'newIssues', added);
Vue.set(state.sastContainer, 'resolvedIssues', fixed);
Vue.set(state.sastContainer, 'allIssues', existing);
Vue.set(state.sastContainer, 'baseReportOutofDate', baseReportOutofDate);
Vue.set(state.sastContainer, 'hasBaseReport', hasBaseReport);
Vue.set(state.containerScanning, 'isLoading', false);
Vue.set(state.containerScanning, 'newIssues', added);
Vue.set(state.containerScanning, 'resolvedIssues', fixed);
Vue.set(state.containerScanning, 'allIssues', existing);
Vue.set(state.containerScanning, 'baseReportOutofDate', baseReportOutofDate);
Vue.set(state.containerScanning, 'hasBaseReport', hasBaseReport);
},
[types.RECEIVE_SAST_CONTAINER_DIFF_ERROR](state) {
Vue.set(state.sastContainer, 'isLoading', false);
Vue.set(state.sastContainer, 'hasError', true);
[types.RECEIVE_CONTAINER_SCANNING_DIFF_ERROR](state) {
Vue.set(state.containerScanning, 'isLoading', false);
Vue.set(state.containerScanning, 'hasError', true);
},
// DAST
......@@ -251,15 +251,15 @@ export default {
[types.UPDATE_CONTAINER_SCANNING_ISSUE](state, issue) {
// Find issue in the correct list and update it
const newIssuesIndex = findIssueIndex(state.sastContainer.newIssues, issue);
const newIssuesIndex = findIssueIndex(state.containerScanning.newIssues, issue);
if (newIssuesIndex !== -1) {
state.sastContainer.newIssues.splice(newIssuesIndex, 1, issue);
state.containerScanning.newIssues.splice(newIssuesIndex, 1, issue);
return;
}
const resolvedIssuesIndex = findIssueIndex(state.sastContainer.resolvedIssues, issue);
const resolvedIssuesIndex = findIssueIndex(state.containerScanning.resolvedIssues, issue);
if (resolvedIssuesIndex !== -1) {
state.sastContainer.resolvedIssues.splice(resolvedIssuesIndex, 1, issue);
state.containerScanning.resolvedIssues.splice(resolvedIssuesIndex, 1, issue);
}
},
......
......@@ -16,7 +16,7 @@ export default () => ({
canCreateIssuePermission: false,
canCreateFeedbackPermission: false,
sastContainer: {
containerScanning: {
paths: {
head: null,
base: null,
......
......@@ -10,7 +10,7 @@
window.gl.mrWidgetData.is_geo_secondary_node = '#{Gitlab::Geo.secondary?}' === 'true';
window.gl.mrWidgetData.geo_secondary_help_path = '#{help_page_path("administration/geo/replication/configuration.md")}';
window.gl.mrWidgetData.sast_help_path = '#{help_page_path("user/application_security/sast/index")}';
window.gl.mrWidgetData.sast_container_help_path = '#{help_page_path("user/application_security/container_scanning/index")}';
window.gl.mrWidgetData.container_scanning_help_path = '#{help_page_path("user/application_security/container_scanning/index")}';
window.gl.mrWidgetData.dast_help_path = '#{help_page_path("user/application_security/dast/index")}';
window.gl.mrWidgetData.dependency_scanning_help_path = '#{help_page_path("user/application_security/dependency_scanning/index")}';
window.gl.mrWidgetData.vulnerability_feedback_help_path = '#{help_page_path("user/application_security/index")}';
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Sast Container Issue Body matches snapshot 1`] = `
exports[`Container Scanning Issue Body matches snapshot 1`] = `
<div
class="report-block-list-issue-description prepend-top-5 append-bottom-5"
>
......
import { shallowMount } from '@vue/test-utils';
import SastContainerIssueBody from 'ee/vue_shared/security_reports/components/sast_container_issue_body.vue';
import ContainerScanningIssueBody from 'ee/vue_shared/security_reports/components/container_scanning_issue_body.vue';
describe('Sast Container Issue Body', () => {
describe('Container Scanning Issue Body', () => {
let wrapper;
const createComponent = severity => {
wrapper = shallowMount(SastContainerIssueBody, {
wrapper = shallowMount(ContainerScanningIssueBody, {
propsData: {
issue: {
title: 'CVE-2017-11671',
......
......@@ -31,7 +31,7 @@ describe('Grouped security reports app', () => {
headBlobPath: 'path',
baseBlobPath: 'path',
sastHelpPath: 'path',
sastContainerHelpPath: 'path',
containerScanningHelpPath: 'path',
dastHelpPath: 'path',
dependencyScanningHelpPath: 'path',
vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json',
......@@ -93,7 +93,7 @@ describe('Grouped security reports app', () => {
return Promise.all([
waitForMutation(wrapper.vm.$store, `sast/${sastTypes.RECEIVE_DIFF_ERROR}`),
waitForMutation(wrapper.vm.$store, types.RECEIVE_SAST_CONTAINER_DIFF_ERROR),
waitForMutation(wrapper.vm.$store, types.RECEIVE_CONTAINER_SCANNING_DIFF_ERROR),
waitForMutation(wrapper.vm.$store, types.RECEIVE_DAST_DIFF_ERROR),
waitForMutation(wrapper.vm.$store, types.RECEIVE_DEPENDENCY_SCANNING_DIFF_ERROR),
]);
......@@ -164,7 +164,7 @@ describe('Grouped security reports app', () => {
return Promise.all([
waitForMutation(wrapper.vm.$store, `sast/${sastTypes.RECEIVE_DIFF_SUCCESS}`),
waitForMutation(wrapper.vm.$store, types.RECEIVE_DAST_DIFF_SUCCESS),
waitForMutation(wrapper.vm.$store, types.RECEIVE_SAST_CONTAINER_DIFF_SUCCESS),
waitForMutation(wrapper.vm.$store, types.RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS),
waitForMutation(wrapper.vm.$store, types.RECEIVE_DEPENDENCY_SCANNING_DIFF_SUCCESS),
]);
});
......@@ -220,7 +220,7 @@ describe('Grouped security reports app', () => {
it('has the success icon for fixed vulnerabilities', () => {
const icon = wrapper.vm.$el.querySelector(
'.js-sast-container~.js-plain-element .ic-status_success_borderless',
'.js-container-scanning~.js-plain-element .ic-status_success_borderless',
);
expect(icon).not.toBeNull();
......@@ -260,11 +260,13 @@ describe('Grouped security reports app', () => {
},
});
return waitForMutation(wrapper.vm.$store, types.RECEIVE_SAST_CONTAINER_DIFF_SUCCESS);
return waitForMutation(wrapper.vm.$store, types.RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS);
});
it('should set setSastContainerDiffEndpoint', () => {
expect(wrapper.vm.sastContainer.paths.diffEndpoint).toEqual(CONTAINER_SCANNING_DIFF_ENDPOINT);
it('should set setContainerScanningDiffEndpoint', () => {
expect(wrapper.vm.containerScanning.paths.diffEndpoint).toEqual(
CONTAINER_SCANNING_DIFF_ENDPOINT,
);
});
it('should display the correct numbers of vulnerabilities', () => {
......
......@@ -5,7 +5,7 @@ describe('securityReportMixin', () => {
it.each`
key | link
${'sast'} | ${'http://fake.url/sast/help/path'}
${'sastContainer'} | ${'http://fake.url/sast/container/help/path'}
${'containerScanning'} | ${'http://fake.url/container/scanning/help/path'}
${'dast'} | ${'http://fake.url/dast/help/path'}
${'dependencyScanning'} | ${'http://fake.url/dependency/scanning/help/path'}
`('generates correct external link with icon', ({ key, link }) => {
......
......@@ -7,7 +7,7 @@ import {
setPipelineId,
setCanCreateIssuePermission,
setCanCreateFeedbackPermission,
requestSastContainerReports,
requestContainerScanningDiff,
requestDastDiff,
requestDependencyScanningDiff,
openModal,
......@@ -39,10 +39,10 @@ import {
requestDeleteDismissalComment,
showDismissalDeleteButtons,
hideDismissalDeleteButtons,
setSastContainerDiffEndpoint,
receiveSastContainerDiffSuccess,
receiveSastContainerDiffError,
fetchSastContainerDiff,
setContainerScanningDiffEndpoint,
receiveContainerScanningDiffSuccess,
receiveContainerScanningDiffError,
fetchContainerScanningDiff,
setDependencyScanningDiffEndpoint,
receiveDependencyScanningDiffSuccess,
receiveDependencyScanningDiffError,
......@@ -230,15 +230,15 @@ describe('security reports actions', () => {
});
});
describe('requestSastContainerReports', () => {
describe('requestContainerScanningDiff', () => {
it('should commit request mutation', done => {
testAction(
requestSastContainerReports,
requestContainerScanningDiff,
null,
mockedState,
[
{
type: types.REQUEST_SAST_CONTAINER_REPORTS,
type: types.REQUEST_CONTAINER_SCANNING_DIFF,
},
],
[],
......@@ -1087,17 +1087,17 @@ describe('security reports actions', () => {
});
});
describe('setSastContainerDiffEndpoint', () => {
describe('setContainerScanningDiffEndpoint', () => {
it('should pass down the endpoint to the mutation', done => {
const payload = '/sast_container_endpoint.json';
const payload = '/container_scanning_endpoint.json';
testAction(
setSastContainerDiffEndpoint,
setContainerScanningDiffEndpoint,
payload,
mockedState,
[
{
type: types.SET_SAST_CONTAINER_DIFF_ENDPOINT,
type: types.SET_CONTAINER_SCANNING_DIFF_ENDPOINT,
payload,
},
],
......@@ -1107,17 +1107,17 @@ describe('security reports actions', () => {
});
});
describe('receiveSastContainerDiffSuccess', () => {
describe('receiveContainerScanningDiffSuccess', () => {
it('should pass down the response to the mutation', done => {
const payload = { data: 'Effort yields its own rewards.' };
testAction(
receiveSastContainerDiffSuccess,
receiveContainerScanningDiffSuccess,
payload,
mockedState,
[
{
type: types.RECEIVE_SAST_CONTAINER_DIFF_SUCCESS,
type: types.RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS,
payload,
},
],
......@@ -1127,15 +1127,15 @@ describe('security reports actions', () => {
});
});
describe('receiveSastContainerDiffError', () => {
describe('receiveContainerScanningDiffError', () => {
it('should commit container diff error mutation', done => {
testAction(
receiveSastContainerDiffError,
receiveContainerScanningDiffError,
undefined,
mockedState,
[
{
type: types.RECEIVE_SAST_CONTAINER_DIFF_ERROR,
type: types.RECEIVE_CONTAINER_SCANNING_DIFF_ERROR,
},
],
[],
......@@ -1144,17 +1144,18 @@ describe('security reports actions', () => {
});
});
describe('fetchSastContainerDiff', () => {
describe('fetchContainerScanningDiff', () => {
const diff = { vulnerabilities: [] };
const endpoint = 'container_scanning_diff.json';
beforeEach(() => {
mockedState.vulnerabilityFeedbackPath = 'vulnerabilities_feedback';
mockedState.sastContainer.paths.diffEndpoint = 'sast_container_diff.json';
mockedState.containerScanning.paths.diffEndpoint = endpoint;
});
describe('on success', () => {
it('should dispatch `receiveSastContainerDiffSuccess`', done => {
mock.onGet('sast_container_diff.json').reply(200, diff);
it('should dispatch `receiveContainerScanningDiffSuccess`', done => {
mock.onGet(endpoint).reply(200, diff);
mock
.onGet('vulnerabilities_feedback', {
params: {
......@@ -1164,16 +1165,16 @@ describe('security reports actions', () => {
.reply(200, containerScanningFeedbacks);
testAction(
fetchSastContainerDiff,
fetchContainerScanningDiff,
null,
mockedState,
[],
[
{
type: 'requestSastContainerReports',
type: 'requestContainerScanningDiff',
},
{
type: 'receiveSastContainerDiffSuccess',
type: 'receiveContainerScanningDiffSuccess',
payload: {
diff,
enrichData: containerScanningFeedbacks,
......@@ -1186,8 +1187,8 @@ describe('security reports actions', () => {
});
describe('when vulnerabilities path errors', () => {
it('should dispatch `receiveSastContainerError`', done => {
mock.onGet('sast_container_diff.json').reply(500);
it('should dispatch `receiveContainerScanningError`', done => {
mock.onGet(endpoint).reply(500);
mock
.onGet('vulnerabilities_feedback', {
params: {
......@@ -1197,16 +1198,16 @@ describe('security reports actions', () => {
.reply(200, containerScanningFeedbacks);
testAction(
fetchSastContainerDiff,
fetchContainerScanningDiff,
null,
mockedState,
[],
[
{
type: 'requestSastContainerReports',
type: 'requestContainerScanningDiff',
},
{
type: 'receiveSastContainerDiffError',
type: 'receiveContainerScanningDiffError',
},
],
done,
......@@ -1215,8 +1216,8 @@ describe('security reports actions', () => {
});
describe('when feedback path errors', () => {
it('should dispatch `receiveSastContainerError`', done => {
mock.onGet('sast_container_diff.json').reply(200, diff);
it('should dispatch `receiveContainerScanningError`', done => {
mock.onGet(endpoint).reply(200, diff);
mock
.onGet('vulnerabilities_feedback', {
params: {
......@@ -1226,16 +1227,16 @@ describe('security reports actions', () => {
.reply(500);
testAction(
fetchSastContainerDiff,
fetchContainerScanningDiff,
null,
mockedState,
[],
[
{
type: 'requestSastContainerReports',
type: 'requestContainerScanningDiff',
},
{
type: 'receiveSastContainerDiffError',
type: 'receiveContainerScanningDiffError',
},
],
done,
......
import createState from 'ee/vue_shared/security_reports/store/state';
import createSastState from 'ee/vue_shared/security_reports/store/modules/sast/state';
import {
groupedSastContainerText,
groupedContainerScanningText,
groupedDastText,
groupedDependencyText,
groupedSummaryText,
allReportsHaveError,
noBaseInAllReports,
areReportsLoading,
sastContainerStatusIcon,
containerScanningStatusIcon,
dastStatusIcon,
dependencyScanningStatusIcon,
anyReportHasError,
......@@ -31,13 +31,13 @@ describe('Security reports getters', () => {
state.sast = createSastState();
});
describe('groupedSastContainerText', () => {
describe('groupedContainerScanningText', () => {
describe('with no issues', () => {
it('returns no issues text', () => {
state.sastContainer.paths.head = HEAD_PATH;
state.sastContainer.paths.base = BASE_PATH;
state.containerScanning.paths.head = HEAD_PATH;
state.containerScanning.paths.base = BASE_PATH;
expect(groupedSastContainerText(state)).toEqual(
expect(groupedContainerScanningText(state)).toEqual(
'Container scanning detected no vulnerabilities',
);
});
......@@ -45,10 +45,10 @@ describe('Security reports getters', () => {
describe('with new issues and without base', () => {
it('returns unable to compare text', () => {
state.sastContainer.paths.head = HEAD_PATH;
state.sastContainer.newIssues = [{}];
state.containerScanning.paths.head = HEAD_PATH;
state.containerScanning.newIssues = [{}];
expect(groupedSastContainerText(state)).toEqual(
expect(groupedContainerScanningText(state)).toEqual(
'Container scanning detected 1 vulnerability for the source branch only',
);
});
......@@ -57,11 +57,11 @@ describe('Security reports getters', () => {
describe('with base and head', () => {
describe('with only new issues', () => {
it('returns new issues text', () => {
state.sastContainer.paths.head = HEAD_PATH;
state.sastContainer.paths.base = BASE_PATH;
state.sastContainer.newIssues = [{}];
state.containerScanning.paths.head = HEAD_PATH;
state.containerScanning.paths.base = BASE_PATH;
state.containerScanning.newIssues = [{}];
expect(groupedSastContainerText(state)).toEqual(
expect(groupedContainerScanningText(state)).toEqual(
'Container scanning detected 1 new vulnerability',
);
});
......@@ -69,11 +69,11 @@ describe('Security reports getters', () => {
describe('with only dismissed issues', () => {
it('returns dismissed issues text', () => {
state.sastContainer.paths.head = HEAD_PATH;
state.sastContainer.paths.base = BASE_PATH;
state.sastContainer.newIssues = [{ isDismissed: true }];
state.containerScanning.paths.head = HEAD_PATH;
state.containerScanning.paths.base = BASE_PATH;
state.containerScanning.newIssues = [{ isDismissed: true }];
expect(groupedSastContainerText(state)).toEqual(
expect(groupedContainerScanningText(state)).toEqual(
'Container scanning detected 1 dismissed vulnerability',
);
});
......@@ -81,12 +81,12 @@ describe('Security reports getters', () => {
describe('with new and resolved issues', () => {
it('returns new and fixed issues text', () => {
state.sastContainer.paths.head = HEAD_PATH;
state.sastContainer.paths.base = BASE_PATH;
state.sastContainer.newIssues = [{}];
state.sastContainer.resolvedIssues = [{}];
state.containerScanning.paths.head = HEAD_PATH;
state.containerScanning.paths.base = BASE_PATH;
state.containerScanning.newIssues = [{}];
state.containerScanning.resolvedIssues = [{}];
expect(removeBreakLine(groupedSastContainerText(state))).toEqual(
expect(removeBreakLine(groupedContainerScanningText(state))).toEqual(
'Container scanning detected 1 new, and 1 fixed vulnerabilities',
);
});
......@@ -94,11 +94,11 @@ describe('Security reports getters', () => {
describe('with only resolved issues', () => {
it('returns fixed issues text', () => {
state.sastContainer.paths.head = HEAD_PATH;
state.sastContainer.paths.base = BASE_PATH;
state.sastContainer.resolvedIssues = [{}];
state.containerScanning.paths.head = HEAD_PATH;
state.containerScanning.paths.base = BASE_PATH;
state.containerScanning.resolvedIssues = [{}];
expect(groupedSastContainerText(state)).toEqual(
expect(groupedContainerScanningText(state)).toEqual(
'Container scanning detected 1 fixed vulnerability',
);
});
......@@ -261,7 +261,7 @@ describe('Security reports getters', () => {
describe('combines all reports', () => {
it('of the same type', () => {
state.sastContainer.resolvedIssues = [{}];
state.containerScanning.resolvedIssues = [{}];
state.dast.resolvedIssues = [{}];
state.dependencyScanning.resolvedIssues = [{}];
......@@ -274,7 +274,7 @@ describe('Security reports getters', () => {
});
it('of the different types', () => {
state.sastContainer.resolvedIssues = [{}];
state.containerScanning.resolvedIssues = [{}];
state.dast.allIssues = [{}];
state.dast.newIssues = [{ isDismissed: true }];
state.dependencyScanning.newIssues = [{ isDismissed: false }];
......@@ -437,21 +437,21 @@ describe('Security reports getters', () => {
});
});
describe('sastContainerStatusIcon', () => {
describe('containerScanningStatusIcon', () => {
it('returns warning with new issues', () => {
state.sastContainer.newIssues = [{}];
state.containerScanning.newIssues = [{}];
expect(sastContainerStatusIcon(state)).toEqual('warning');
expect(containerScanningStatusIcon(state)).toEqual('warning');
});
it('returns warning with failed report', () => {
state.sastContainer.hasError = true;
state.containerScanning.hasError = true;
expect(sastContainerStatusIcon(state)).toEqual('warning');
expect(containerScanningStatusIcon(state)).toEqual('warning');
});
it('returns success with no new issues or failed report', () => {
expect(sastContainerStatusIcon(state)).toEqual('success');
expect(containerScanningStatusIcon(state)).toEqual('success');
});
});
......@@ -489,7 +489,7 @@ describe('Security reports getters', () => {
it('returns true when all reports have error', () => {
state.sast.hasError = true;
state.dast.hasError = true;
state.sastContainer.hasError = true;
state.containerScanning.hasError = true;
state.dependencyScanning.hasError = true;
expect(allReportsHaveError(state)).toEqual(true);
......@@ -501,7 +501,7 @@ describe('Security reports getters', () => {
it('returns false when one of the reports does not have error', () => {
state.dast.hasError = false;
state.sastContainer.hasError = true;
state.containerScanning.hasError = true;
state.dependencyScanning.hasError = true;
expect(allReportsHaveError(state)).toEqual(false);
......
......@@ -71,11 +71,11 @@ describe('security reports mutations', () => {
});
});
describe('REQUEST_SAST_CONTAINER_REPORTS', () => {
it('should set sast container loading flag to true', () => {
mutations[types.REQUEST_SAST_CONTAINER_REPORTS](stateCopy);
describe('REQUEST_CONTAINER_SCANNING_DIFF', () => {
it('should set container scanning loading flag to true', () => {
mutations[types.REQUEST_CONTAINER_SCANNING_DIFF](stateCopy);
expect(stateCopy.sastContainer.isLoading).toEqual(true);
expect(stateCopy.containerScanning.isLoading).toEqual(true);
});
});
......@@ -516,8 +516,8 @@ describe('security reports mutations', () => {
describe('UPDATE_CONTAINER_SCANNING_ISSUE', () => {
it('updates issue in the new issues list', () => {
stateCopy.sastContainer.newIssues = mockFindings;
stateCopy.sastContainer.resolvedIssues = [];
stateCopy.containerScanning.newIssues = mockFindings;
stateCopy.containerScanning.resolvedIssues = [];
const updatedIssue = {
...mockFindings[0],
foo: 'bar',
......@@ -525,12 +525,12 @@ describe('security reports mutations', () => {
mutations[types.UPDATE_CONTAINER_SCANNING_ISSUE](stateCopy, updatedIssue);
expect(stateCopy.sastContainer.newIssues[0]).toEqual(updatedIssue);
expect(stateCopy.containerScanning.newIssues[0]).toEqual(updatedIssue);
});
it('updates issue in the resolved issues list', () => {
stateCopy.sastContainer.newIssues = [];
stateCopy.sastContainer.resolvedIssues = mockFindings;
stateCopy.containerScanning.newIssues = [];
stateCopy.containerScanning.resolvedIssues = mockFindings;
const updatedIssue = {
...mockFindings[0],
foo: 'bar',
......@@ -538,7 +538,7 @@ describe('security reports mutations', () => {
mutations[types.UPDATE_CONTAINER_SCANNING_ISSUE](stateCopy, updatedIssue);
expect(stateCopy.sastContainer.resolvedIssues[0]).toEqual(updatedIssue);
expect(stateCopy.containerScanning.resolvedIssues[0]).toEqual(updatedIssue);
});
});
......@@ -570,19 +570,19 @@ describe('security reports mutations', () => {
});
});
describe('SET_SAST_CONTAINER_DIFF_ENDPOINT', () => {
const endpoint = 'sast_container_diff_endpoint.json';
describe('SET_CONTAINER_SCANNING_DIFF_ENDPOINT', () => {
const endpoint = 'container_scanning_diff_endpoint.json';
beforeEach(() => {
mutations[types.SET_SAST_CONTAINER_DIFF_ENDPOINT](stateCopy, endpoint);
mutations[types.SET_CONTAINER_SCANNING_DIFF_ENDPOINT](stateCopy, endpoint);
});
it('should set the correct endpoint', () => {
expect(stateCopy.sastContainer.paths.diffEndpoint).toEqual(endpoint);
expect(stateCopy.containerScanning.paths.diffEndpoint).toEqual(endpoint);
});
});
describe('RECEIVE_SAST_CONTAINER_DIFF_SUCCESS', () => {
describe('RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS', () => {
const reports = {
diff: {
added: [
......@@ -595,20 +595,20 @@ describe('security reports mutations', () => {
};
beforeEach(() => {
mutations[types.RECEIVE_SAST_CONTAINER_DIFF_SUCCESS](stateCopy, reports);
mutations[types.RECEIVE_CONTAINER_SCANNING_DIFF_SUCCESS](stateCopy, reports);
});
it('should set isLoading to false', () => {
expect(stateCopy.sastContainer.isLoading).toBe(false);
expect(stateCopy.containerScanning.isLoading).toBe(false);
});
it('should set baseReportOutofDate to true', () => {
expect(stateCopy.sastContainer.baseReportOutofDate).toBe(true);
expect(stateCopy.containerScanning.baseReportOutofDate).toBe(true);
});
it('should parse and set the added vulnerabilities', () => {
reports.diff.added.forEach((vuln, i) => {
expect(stateCopy.sastContainer.newIssues[i]).toEqual(
expect(stateCopy.containerScanning.newIssues[i]).toEqual(
expect.objectContaining({
name: vuln.name,
title: vuln.name,
......@@ -620,7 +620,7 @@ describe('security reports mutations', () => {
it('should parse and set the fixed vulnerabilities', () => {
reports.diff.fixed.forEach((vuln, i) => {
expect(stateCopy.sastContainer.resolvedIssues[i]).toEqual(
expect(stateCopy.containerScanning.resolvedIssues[i]).toEqual(
expect.objectContaining({
name: vuln.name,
title: vuln.name,
......@@ -631,12 +631,12 @@ describe('security reports mutations', () => {
});
});
describe('RECEIVE_SAST_CONTAINER_DIFF_ERROR', () => {
it('should set sast container loading flag to false and error flag to true', () => {
mutations[types.RECEIVE_SAST_CONTAINER_DIFF_ERROR](stateCopy);
describe('RECEIVE_CONTAINER_SCANNING_DIFF_ERROR', () => {
it('should set container scanning loading flag to false and error flag to true', () => {
mutations[types.RECEIVE_CONTAINER_SCANNING_DIFF_ERROR](stateCopy);
expect(stateCopy.sastContainer.isLoading).toEqual(false);
expect(stateCopy.sastContainer.hasError).toEqual(true);
expect(stateCopy.containerScanning.isLoading).toEqual(false);
expect(stateCopy.containerScanning.hasError).toEqual(true);
});
});
......
......@@ -29,7 +29,7 @@ import {
const SAST_SELECTOR = '.js-sast-widget';
const DAST_SELECTOR = '.js-dast-widget';
const DEPENDENCY_SCANNING_SELECTOR = '.js-dependency-scanning-widget';
const CONTAINER_SCANNING_SELECTOR = '.js-sast-container';
const CONTAINER_SCANNING_SELECTOR = '.js-container-scanning';
describe('ee merge request widget options', () => {
let vm;
......
......@@ -90,7 +90,7 @@ describe('Report issues', () => {
beforeEach(() => {
vm = mountComponent(ReportIssues, {
issue: dockerReportParsed.unapproved[0],
component: componentNames.SastContainerIssueBody,
component: componentNames.ContainerScanningIssueBody,
status: STATUS_FAILED,
});
});
......
......@@ -90,7 +90,7 @@ describe('Report issue', () => {
beforeEach(() => {
vm = mountComponent(ReportIssue, {
issue: dockerReportParsed.unapproved[0],
component: componentNames.SastContainerIssueBody,
component: componentNames.ContainerScanningIssueBody,
status: STATUS_FAILED,
});
});
......
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