Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): add vuln / non-vuln footer to projects and components cards #714

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(dashboard): add vuln / non-vuln footer to projects and component…
…s cards

Signed-off-by: Adam Setch <[email protected]>
  • Loading branch information
setchy committed Jan 29, 2024
commit 2b4b4f2c4e805943132bf17d3a4a8bd7908d3507
2 changes: 2 additions & 0 deletions src/assets/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $severity-label-bg: $grey-900 !default;
$notification-fail: $red;
$notification-warn: $yellow;
$notification-info: $blue;
$notification-pass: $green;
$notification-note: #777777;

// Components
Expand Down Expand Up @@ -232,6 +233,7 @@ $recessed: $grey-850;
--notification-fail: #{$notification-fail};
--notification-warn: #{$notification-warn};
--notification-info: #{$notification-info};
--notification-pass: #{$notification-pass};
--notification-note: #{$notification-note};

--component-active-color: #{$component-active-color};
Expand Down
8 changes: 4 additions & 4 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<b-row class="text-center">
<b-col class="mb-sm-2 mb-0">
<div class="text-muted">{{ $t('message.vulnerable_projects') }}</div>
<strong>{{vulnerableProjects}} ({{vulnerableProjectPercent}}%)</strong>
<b-progress height={} class="progress-xs mt-2 status-passed" :precision="1" v-bind:value="vulnerableProjectPercent"></b-progress>
<strong>{{vulnerableProjects}} ({{vulnerableProjectsPercent}}%)</strong>
<b-progress height={} class="progress-xs mt-2 status-passed" :precision="1" v-bind:value="vulnerableProjectsPercent"></b-progress>
</b-col>
<b-col class="mb-sm-2 mb-0 d-md-down-none">
<div class="text-muted">{{ $t('message.violations_audited') }}</div>
Expand All @@ -27,8 +27,8 @@
</b-col>
<b-col class="mb-sm-2 mb-0">
<div class="text-muted">{{ $t('message.vulnerable_components') }}</div>
<strong>{{vulnerableComponents}} ({{vulnerableComponentPercent}}%)</strong>
<b-progress height={} class="progress-xs mt-2 status-warning" :precision="1" v-bind:value="vulnerableComponentPercent"></b-progress>
<strong>{{vulnerableComponents}} ({{vulnerableComponentsPercent}}%)</strong>
<b-progress height={} class="progress-xs mt-2 status-warning" :precision="1" v-bind:value="vulnerableComponentsPercent"></b-progress>
</b-col>
<b-col class="mb-sm-2 mb-0">
<div class="text-muted">{{ $t('message.findings_audited') }}</div>
Expand Down
11 changes: 11 additions & 0 deletions src/views/dashboard/ChartComponentVulnerabilities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@
render: function(metrics) {
const totalStyle = getStyle('--notification-note');
const affectedStyle = getStyle('--notification-warn');
const nonAffectedStyle = getStyle('--notification-pass');

let labels = [];
let totalData = [];
let affectedData = [];
let nonAffectedData = [];

for (let i = 0; i < metrics.length; i++) {
labels.push(common.formatTimestamp(metrics[i].firstOccurrence));
totalData.push(metrics[i].components);
affectedData.push(metrics[i].vulnerableComponents);
nonAffectedData.push(metrics[i].components - metrics[i].vulnerableComponents)

if (i === metrics.length - 1) {
labels.push(common.formatTimestamp(metrics[i].lastOccurrence));
totalData.push(metrics[i].components);
affectedData.push(metrics[i].vulnerableComponents);
nonAffectedData.push(metrics[i].components - metrics[i].vulnerableComponents)
}
}

Expand All @@ -40,6 +44,13 @@
pointHoverBackgroundColor: '#fff',
data: totalData
},
{
label: this.$t('message.non_vulnerable'),
backgroundColor: hexToRgba(nonAffectedStyle, 10),
borderColor: nonAffectedStyle,
pointHoverBackgroundColor: '#fff',
data: nonAffectedData
},
{
label: this.$t('message.vulnerable'),
backgroundColor: hexToRgba(affectedStyle, 10),
Expand Down
11 changes: 11 additions & 0 deletions src/views/dashboard/ChartProjectVulnerabilities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@
render: function(metrics) {
const totalStyle = getStyle('--notification-note');
const affectedStyle = getStyle('--notification-warn');
const nonAffectedStyle = getStyle('--notification-pass');

let labels = [];
let totalData = [];
let affectedData = [];
let nonAffectedData = [];

for (let i = 0; i < metrics.length; i++) {
labels.push(common.formatTimestamp(metrics[i].firstOccurrence));
totalData.push(metrics[i].projects);
affectedData.push(metrics[i].vulnerableProjects);
nonAffectedData.push(metrics[i].projects - metrics[i].vulnerableProjects)

if (i === metrics.length - 1) {
labels.push(common.formatTimestamp(metrics[i].lastOccurrence));
totalData.push(metrics[i].projects);
affectedData.push(metrics[i].vulnerableProjects);
nonAffectedData.push(metrics[i].projects - metrics[i].vulnerableProjects)
}
}

Expand All @@ -40,6 +44,13 @@
pointHoverBackgroundColor: '#fff',
data: totalData
},
{
label: this.$t('message.non_vulnerable'),
backgroundColor: hexToRgba(nonAffectedStyle, 10),
borderColor: nonAffectedStyle,
pointHoverBackgroundColor: '#fff',
data: nonAffectedData
},
{
label: this.$t('message.vulnerable'),
backgroundColor: hexToRgba(affectedStyle, 10),
Expand Down