Skip to content

Commit 2fafac7

Browse files
Merge pull request #111 from sekwah41/policy-violations
Policy violations
2 parents 9ec913b + ae3de2d commit 2fafac7

File tree

8 files changed

+188
-54
lines changed

8 files changed

+188
-54
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ yarn-error.log*
2323
*.njsproj
2424
*.sln
2525
*.sw*
26+
27+
# Generates as part of serve
28+
src/version.json

package-lock.json

Lines changed: 83 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424
"@coreui/icons": "0.4.1",
2525
"@coreui/vue": "2.1.2",
2626
"@johmun/vue-tags-input": "2.1.0",
27-
"axios": "0.21.4",
28-
"bootstrap": "4.6.1",
29-
"bootstrap-table": "1.15.5",
30-
"bootstrap-vue": "2.5.0",
27+
"axios": "0.21.1",
28+
"bootstrap": "4.6.0",
29+
"bootstrap-table": "1.19.1",
30+
"bootstrap-vue": "2.21.2",
3131
"chart.js": "2.9.4",
3232
"core-js": "2.6.12",
33-
"css-vars-ponyfill": "2.4.7",
33+
"css-vars-ponyfill": "2.4.3",
3434
"font-awesome": "4.7.0",
35-
"jquery": "3.6.0",
36-
"lodash-es": "4.17.21",
37-
"oidc-client": "1.11.5",
38-
"perfect-scrollbar": "1.5.5",
35+
"jquery": "3.5.1",
36+
"lodash-es": "4.17.20",
37+
"oidc-client": "1.11.3",
38+
"perfect-scrollbar": "1.4.0",
3939
"simple-line-icons": "2.5.5",
40-
"vee-validate": "3.4.14",
41-
"vue": "2.6.14",
40+
"vee-validate": "3.4.5",
41+
"vue": "2.6.12",
4242
"vue-axios": "2.1.5",
4343
"vue-bootstrap-toggle": "1.1.4",
4444
"vue-chartjs": "3.5.1",

src/assets/scss/_custom.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
.severity-unassigned {
2525
color: $severity-unassigned;
2626
}
27+
// Fixes the width for the bootstrap progress bar in tables
28+
.table-progress {
29+
width: 100% !important;
30+
}
2731
.severity-critical-bg, .bg-severity-critical, .bg-CRITICAL {
2832
background: $severity-critical none;
2933
}
@@ -39,6 +43,12 @@
3943
.severity-info-bg, .bg-severity-info, .bg-INFO {
4044
background: $severity-info none;
4145
}
46+
.severity-warn-bg {
47+
background: $severity-medium none;
48+
}
49+
.severity-fail-bg {
50+
background: $severity-critical none;
51+
}
4252
.bg-violation-type {
4353
background: $widget-3;
4454
}

src/i18n/locales/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,10 @@
476476
"policy_violation": {
477477
"fails": "Violation Failures",
478478
"warns": "Violation Warnings",
479-
"infos": "Informational Violations"
479+
"infos": "Informational Violations",
480+
"license": "License Violations",
481+
"operational": "Operational Violations",
482+
"security": "Security Violations"
480483
},
481484
"severity": {
482485
"critical": "Critical",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<span v-if="metrics.policyViolationsTotal === 0" class="progress">
3+
<b-progress class="table-progress" :max="'0'" show-value>
4+
<b-progress-bar class="table-progress" value="0"></b-progress-bar>
5+
</b-progress>
6+
</span>
7+
<span v-else class="progress">
8+
<span :id="'progressbar' + hoverId" class="table-progress">
9+
<b-progress class="table-progress" :max="metrics.policyViolationsTotal" show-value>
10+
<b-progress-bar :value="metrics.policyViolationsInfo" class="severity-info-bg"></b-progress-bar>
11+
<b-progress-bar :value="metrics.policyViolationsWarn" class="severity-warn-bg"></b-progress-bar>
12+
<b-progress-bar :value="metrics.policyViolationsFail" class="severity-fail-bg"></b-progress-bar>
13+
</b-progress>
14+
</span>
15+
<b-tooltip :target="'progressbar' + hoverId" placement="left" noninteractive>
16+
<div style="text-align: left;">
17+
<h5>{{$t('message.type')}}</h5>
18+
<p>
19+
{{$t('policy_violation.license')}}: {{ metrics.policyViolationsLicenseTotal }}<br>
20+
{{$t('policy_violation.operational')}}: {{ metrics.policyViolationsOperationalTotal }}<br>
21+
{{$t('policy_violation.security')}}: {{ metrics.policyViolationsSecurityTotal }}<br>
22+
</p>
23+
<h5>{{ $t('message.violation_state') }}</h5>
24+
<p>
25+
{{$t('policy_violation.infos')}}: {{ metrics.policyViolationsInfo }}<br>
26+
{{$t('policy_violation.warns')}}: {{ metrics.policyViolationsWarn }}<br>
27+
{{$t('policy_violation.fails')}}: {{ metrics.policyViolationsFail }}<br>
28+
</p>
29+
{{$t('message.total')}}: {{ metrics.policyViolationsTotal }}
30+
</div>
31+
</b-tooltip>
32+
</span>
33+
</template>
34+
35+
<script>
36+
export default {
37+
props: {
38+
metrics: Object,
39+
$t: Function,
40+
},
41+
data() {
42+
return {
43+
// Workaround for vue references to the progress-bars. Using the ref targets doesn't seem to work.
44+
hoverId: Math.random().toString(36),
45+
};
46+
},
47+
}
48+
</script>
Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<template>
22
<span v-if="vulnerabilities === 0" class="progress">
3-
<div class="progress-bar" style="width: 100%">0</div>
3+
<b-progress class="table-progress" :max="'0'" show-value>
4+
<b-progress-bar class="table-progress" value="0"></b-progress-bar>
5+
</b-progress>
46
</span>
57
<span v-else class="progress">
6-
<div v-if="critical > 0" class="progress-bar severity-critical-bg" v-bind:style="criticalWidth">{{critical}}</div>
7-
<div v-if="high > 0" class="progress-bar severity-high-bg" v-bind:style="highWidth">{{high}}</div>
8-
<div v-if="medium > 0" class="progress-bar severity-medium-bg" v-bind:style="mediumWidth">{{medium}}</div>
9-
<div v-if="low > 0" class="progress-bar severity-low-bg" v-bind:style="lowWidth">{{low}}</div>
10-
<div v-if="unassigned > 0" class="progress-bar severity-unassigned-bg" v-bind:style="unassignedWidth">{{unassigned}}</div>
8+
<b-progress class="table-progress" :max="vulnerabilities" show-value>
9+
<b-progress-bar :value="critical" class="severity-critical-bg"></b-progress-bar>
10+
<b-progress-bar :value="high" class="severity-high-bg"></b-progress-bar>
11+
<b-progress-bar :value="medium" class="severity-medium-bg"></b-progress-bar>
12+
<b-progress-bar :value="low" class="severity-low-bg"></b-progress-bar>
13+
<b-progress-bar :value="unassigned" class="severity-unassigned-bg"></b-progress-bar>
14+
</b-progress>
1115
</span>
1216
</template>
1317

@@ -20,23 +24,6 @@
2024
medium: Number,
2125
low: Number,
2226
unassigned: Number
23-
},
24-
computed: {
25-
criticalWidth: function () {
26-
return "width:" + (100 * this.critical) / this.vulnerabilities + "%";
27-
},
28-
highWidth: function () {
29-
return "width:" + (100 * this.high) / this.vulnerabilities + "%";
30-
},
31-
mediumWidth: function () {
32-
return "width:" + (100 * this.medium) / this.vulnerabilities + "%";
33-
},
34-
lowWidth: function () {
35-
return "width:" + (100 * this.low) / this.vulnerabilities + "%";
36-
},
37-
unassignedWidth: function () {
38-
return "width:" + (100 * this.unassigned) / this.vulnerabilities + "%";
39-
}
4027
}
4128
}
4229
</script>

src/views/portfolio/projects/ProjectList.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow";
2525
import ProjectCreateProjectModal from "./ProjectCreateProjectModal";
2626
import SeverityProgressBar from "../../components/SeverityProgressBar";
27+
import PolicyViolationProgressBar from "../../components/PolicyViolationProgressBar";
2728
import xssFilters from "xss-filters";
2829
import permissionsMixin from "../../../mixins/permissionsMixin";
2930
@@ -117,6 +118,24 @@
117118
align: "center",
118119
sortable: true
119120
},
121+
{
122+
title: this.$t('message.policy_violations'),
123+
field: "metrics",
124+
formatter: function (metrics) {
125+
if (typeof metrics === "undefined") {
126+
return "-"; // No vulnerability info available
127+
}
128+
let ComponentClass = Vue.extend(PolicyViolationProgressBar);
129+
let progressBar = new ComponentClass({
130+
propsData: {
131+
metrics,
132+
$t: this.$t.bind(this),
133+
}
134+
});
135+
progressBar.$mount();
136+
return progressBar.$el.outerHTML;
137+
}.bind(this)
138+
},
120139
{
121140
title: this.$t('message.vulnerabilities'),
122141
field: "metrics",

0 commit comments

Comments
 (0)