Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-04 12:10:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-04 12:10:04 +0300
commitef863c1f85c474c13fd1bb9d84b00ad53f649ed0 (patch)
tree764540e309f62228bc0d268164be69d8a0efa03e /app/assets/javascripts/vue_shared/security_reports
parent24d3d06181fa5cd89cfa506fd2a61fcea156a97f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared/security_reports')
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/constants.js9
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/utils.js39
2 files changed, 39 insertions, 9 deletions
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/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;