summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/security_reports
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/vue_shared/security_reports')
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/components/security_summary.vue4
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/constants.js9
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/security_reports_app.vue4
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/store/getters.js22
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/store/modules/sast/actions.js2
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/store/modules/secret_detection/actions.js2
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/store/utils.js4
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/utils.js39
8 files changed, 58 insertions, 28 deletions
diff --git a/app/assets/javascripts/vue_shared/security_reports/components/security_summary.vue b/app/assets/javascripts/vue_shared/security_reports/components/security_summary.vue
index babb9fddcf6..e3aa25a294e 100644
--- a/app/assets/javascripts/vue_shared/security_reports/components/security_summary.vue
+++ b/app/assets/javascripts/vue_shared/security_reports/components/security_summary.vue
@@ -34,13 +34,13 @@ export default {
<template>
<span>
<gl-sprintf :message="message.message">
- <template #total="{content}">
+ <template #total="{ content }">
<strong>{{ content }}</strong>
</template>
</gl-sprintf>
<span v-if="shouldShowCountMessage" class="gl-font-sm">
<gl-sprintf :message="message.countMessage">
- <template v-for="slotName in $options.slotNames" #[slotName]="{content}">
+ <template v-for="slotName in $options.slotNames" #[slotName]="{ content }">
<span :key="slotName">
<strong
v-if="message[slotName] > 0"
diff --git a/app/assets/javascripts/vue_shared/security_reports/constants.js b/app/assets/javascripts/vue_shared/security_reports/constants.js
index 68241a8c5be..dd591f7bba3 100644
--- a/app/assets/javascripts/vue_shared/security_reports/constants.js
+++ b/app/assets/javascripts/vue_shared/security_reports/constants.js
@@ -5,6 +5,15 @@ export const FEEDBACK_TYPE_ISSUE = 'issue';
export const FEEDBACK_TYPE_MERGE_REQUEST = 'merge_request';
/**
+ * Security artifact file types
+ */
+export const REPORT_FILE_TYPES = {
+ ARCHIVE: 'ARCHIVE',
+ TRACE: 'TRACE',
+ METADATA: 'METADATA',
+};
+
+/**
* Security scan report types, as provided by the backend.
*/
export const REPORT_TYPE_SAST = 'sast';
diff --git a/app/assets/javascripts/vue_shared/security_reports/security_reports_app.vue b/app/assets/javascripts/vue_shared/security_reports/security_reports_app.vue
index bdbf9957ad4..a6c7b59aa71 100644
--- a/app/assets/javascripts/vue_shared/security_reports/security_reports_app.vue
+++ b/app/assets/javascripts/vue_shared/security_reports/security_reports_app.vue
@@ -97,7 +97,7 @@ export default {
projectPath: this.targetProjectFullPath,
iid: String(this.mrIid),
reportTypes: this.$options.reportTypes.map(
- reportType => reportTypeToSecurityReportTypeEnum[reportType],
+ (reportType) => reportTypeToSecurityReportTypeEnum[reportType],
),
};
},
@@ -151,7 +151,7 @@ export default {
created() {
if (!this.canShowDownloads) {
this.checkAvailableSecurityReports(this.$options.reportTypes)
- .then(availableSecurityReports => {
+ .then((availableSecurityReports) => {
this.onCheckingAvailableSecurityReports(Array.from(availableSecurityReports));
})
.catch(this.showError);
diff --git a/app/assets/javascripts/vue_shared/security_reports/store/getters.js b/app/assets/javascripts/vue_shared/security_reports/store/getters.js
index 1e5a60c32fd..443255b0e6a 100644
--- a/app/assets/javascripts/vue_shared/security_reports/store/getters.js
+++ b/app/assets/javascripts/vue_shared/security_reports/store/getters.js
@@ -3,7 +3,7 @@ import { countVulnerabilities, groupedTextBuilder } from './utils';
import { LOADING, ERROR, SUCCESS } from '~/reports/constants';
import { TRANSLATION_IS_LOADING } from './messages';
-export const summaryCounts = state =>
+export const summaryCounts = (state) =>
countVulnerabilities(
state.reportTypes.reduce((acc, reportType) => {
acc.push(...state[reportType].newIssues);
@@ -50,17 +50,17 @@ export const summaryStatus = (state, getters) => {
return SUCCESS;
};
-export const areReportsLoading = state =>
- state.reportTypes.some(reportType => state[reportType].isLoading);
+export const areReportsLoading = (state) =>
+ state.reportTypes.some((reportType) => state[reportType].isLoading);
-export const areAllReportsLoading = state =>
- state.reportTypes.every(reportType => state[reportType].isLoading);
+export const areAllReportsLoading = (state) =>
+ state.reportTypes.every((reportType) => state[reportType].isLoading);
-export const allReportsHaveError = state =>
- state.reportTypes.every(reportType => state[reportType].hasError);
+export const allReportsHaveError = (state) =>
+ state.reportTypes.every((reportType) => state[reportType].hasError);
-export const anyReportHasError = state =>
- state.reportTypes.some(reportType => state[reportType].hasError);
+export const anyReportHasError = (state) =>
+ state.reportTypes.some((reportType) => state[reportType].hasError);
-export const anyReportHasIssues = state =>
- state.reportTypes.some(reportType => state[reportType].newIssues.length > 0);
+export const anyReportHasIssues = (state) =>
+ state.reportTypes.some((reportType) => state[reportType].newIssues.length > 0);
diff --git a/app/assets/javascripts/vue_shared/security_reports/store/modules/sast/actions.js b/app/assets/javascripts/vue_shared/security_reports/store/modules/sast/actions.js
index 22a45341c51..0f26e3c30ef 100644
--- a/app/assets/javascripts/vue_shared/security_reports/store/modules/sast/actions.js
+++ b/app/assets/javascripts/vue_shared/security_reports/store/modules/sast/actions.js
@@ -15,7 +15,7 @@ export const fetchDiff = ({ state, rootState, dispatch }) => {
dispatch('requestDiff');
return fetchDiffData(rootState, state.paths.diffEndpoint, 'sast')
- .then(data => {
+ .then((data) => {
dispatch('receiveDiffSuccess', data);
})
.catch(() => {
diff --git a/app/assets/javascripts/vue_shared/security_reports/store/modules/secret_detection/actions.js b/app/assets/javascripts/vue_shared/security_reports/store/modules/secret_detection/actions.js
index c9da824613d..e3ae5435f5d 100644
--- a/app/assets/javascripts/vue_shared/security_reports/store/modules/secret_detection/actions.js
+++ b/app/assets/javascripts/vue_shared/security_reports/store/modules/secret_detection/actions.js
@@ -15,7 +15,7 @@ export const fetchDiff = ({ state, rootState, dispatch }) => {
dispatch('requestDiff');
return fetchDiffData(rootState, state.paths.diffEndpoint, 'secret_detection')
- .then(data => {
+ .then((data) => {
dispatch('receiveDiffSuccess', data);
})
.catch(() => {
diff --git a/app/assets/javascripts/vue_shared/security_reports/store/utils.js b/app/assets/javascripts/vue_shared/security_reports/store/utils.js
index c5e786c92b1..fd6613ae11c 100644
--- a/app/assets/javascripts/vue_shared/security_reports/store/utils.js
+++ b/app/assets/javascripts/vue_shared/security_reports/store/utils.js
@@ -29,7 +29,7 @@ export const fetchDiffData = (state, endpoint, category) => {
*/
export const enrichVulnerabilityWithFeedback = (vulnerability, feedback = []) =>
feedback
- .filter(fb => fb.project_fingerprint === vulnerability.project_fingerprint)
+ .filter((fb) => fb.project_fingerprint === vulnerability.project_fingerprint)
.reduce((vuln, fb) => {
if (fb.feedback_type === FEEDBACK_TYPE_DISMISSAL) {
return {
@@ -63,7 +63,7 @@ export const enrichVulnerabilityWithFeedback = (vulnerability, feedback = []) =>
* @returns {Object}
*/
export const parseDiff = (diff, enrichData) => {
- const enrichVulnerability = vulnerability => ({
+ const enrichVulnerability = (vulnerability) => ({
...enrichVulnerabilityWithFeedback(vulnerability, enrichData),
category: vulnerability.report_type,
title: vulnerability.message || vulnerability.name,
diff --git a/app/assets/javascripts/vue_shared/security_reports/utils.js b/app/assets/javascripts/vue_shared/security_reports/utils.js
index 827a87f9aaf..ad819bf7081 100644
--- a/app/assets/javascripts/vue_shared/security_reports/utils.js
+++ b/app/assets/javascripts/vue_shared/security_reports/utils.js
@@ -1,4 +1,18 @@
-import { securityReportTypeEnumToReportType } from './constants';
+import { capitalize } from 'lodash';
+import {
+ securityReportTypeEnumToReportType,
+ REPORT_FILE_TYPES,
+} from 'ee_else_ce/vue_shared/security_reports/constants';
+
+const addReportTypeIfExists = (acc, reportTypes, reportType, getName, downloadPath) => {
+ if (reportTypes && reportTypes.includes(reportType)) {
+ acc.push({
+ reportType,
+ name: getName(reportType),
+ path: downloadPath,
+ });
+ }
+};
export const extractSecurityReportArtifacts = (reportTypes, data) => {
const jobs = data.project?.mergeRequest?.headPipeline?.jobs?.nodes ?? [];
@@ -7,14 +21,21 @@ export const extractSecurityReportArtifacts = (reportTypes, data) => {
const artifacts = job.artifacts?.nodes ?? [];
artifacts.forEach(({ downloadPath, fileType }) => {
- const reportType = securityReportTypeEnumToReportType[fileType];
- if (reportType && reportTypes.includes(reportType)) {
- acc.push({
- name: job.name,
- reportType,
- path: downloadPath,
- });
- }
+ addReportTypeIfExists(
+ acc,
+ reportTypes,
+ securityReportTypeEnumToReportType[fileType],
+ () => job.name,
+ downloadPath,
+ );
+
+ addReportTypeIfExists(
+ acc,
+ reportTypes,
+ REPORT_FILE_TYPES[fileType],
+ (reportType) => `${job.name} ${capitalize(reportType)}`,
+ downloadPath,
+ );
});
return acc;