Skip to content

Commit 93f139d

Browse files
Fixed CWE display issue with audit findings
Signed-off-by: Steve Springett <[email protected]>
1 parent 7619019 commit 93f139d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/shared/common.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ $common.formatCweLabel = function formatCweLabel(cweId, cweName) {
8484
}
8585
};
8686

87+
$common.formatCweShortLabel = function formatCweShortLabel(cweId, cweName) {
88+
if (cweId && cweName) {
89+
return "<span data-toggle='tooltip' data-placement='bottom' title='" + cweName + "'>CWE-" + cweId + "</span>";
90+
} else {
91+
return "";
92+
}
93+
};
94+
8795
/**
8896
* Formats and returns a specialized label for a vulnerability analyzer (OSSINDEX_ANALYZER, INTERNAL_ANALYZER, etc).
8997
*/
@@ -338,6 +346,7 @@ module.exports = {
338346
formatSeverityLabel: $common.formatSeverityLabel,
339347
formatViolationStateLabel: $common.formatViolationStateLabel,
340348
formatCweLabel: $common.formatCweLabel,
349+
formatCweShortLabel: $common.formatCweShortLabel,
341350
formatAnalyzerLabel: $common.formatAnalyzerLabel,
342351
makeAnalysisStateLabelFormatter: $common.makeAnalysisStateLabelFormatter,
343352
makeAnalysisJustificationLabelFormatter: $common.makeAnalysisJustificationLabelFormatter,

src/views/portfolio/projects/ProjectFindings.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import permissionsMixin from "../../../mixins/permissionsMixin";
5151
import BootstrapToggle from 'vue-bootstrap-toggle';
5252
import ProjectUploadVexModal from "@/views/portfolio/projects/ProjectUploadVexModal";
53+
import $ from "jquery";
5354
5455
export default {
5556
props: {
@@ -108,13 +109,18 @@
108109
},
109110
{
110111
title: this.$t('message.cwe'),
111-
field: "vulnerability.cweId",
112+
field: "vulnerability.cwe",
112113
sortable: true,
113114
class: "expand-20",
114115
visible: false,
115116
formatter(value, row, index) {
116117
if (typeof value !== 'undefined') {
117-
return common.formatCweLabel(value, row.vulnerability.cweName);
118+
let label = "";
119+
for (let i=0; i<value.length; i++) {
120+
label += common.formatCweShortLabel(value[i].cweId, value[i].name);
121+
if (i < value.length-1) label += ", "
122+
}
123+
return label;
118124
}
119125
}
120126
},
@@ -164,6 +170,7 @@
164170
],
165171
data: [],
166172
options: {
173+
onPostBody: this.initializeTooltips,
167174
search: true,
168175
showColumns: true,
169176
showRefresh: true,
@@ -429,7 +436,10 @@
429436
},
430437
tableLoaded: function(data) {
431438
this.$emit('total', data.total);
432-
}
439+
},
440+
initializeTooltips: function () {
441+
$('[data-toggle="tooltip"]').tooltip();
442+
},
433443
},
434444
watch:{
435445
showSuppressedFindings() {

0 commit comments

Comments
 (0)