Skip to content

Commit

Permalink
Merge pull request #203 from Progress1/cvss_number
Browse files Browse the repository at this point in the history
Allow store CVSS as number (quick need for reporting, #163 replacement)
  • Loading branch information
Progress1 authored Mar 7, 2024
2 parents 8c2d9a5 + 298a541 commit d666b45
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/gui/src/components/common/attribute/AttributeCVSS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
status: "",
rules: {
vector: value => {
const pattern = /^CVSS:3\.1\/((AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]|E:[XUPFH]|RL:[XOTWU]|RC:[XURC]|[CIA]R:[XLMH]|MAV:[XNALP]|MAC:[XLH]|MPR:[XUNLH]|MUI:[XNR]|MS:[XUC]|M[CIA]:[XNLH])\/)*(AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]|E:[XUPFH]|RL:[XOTWU]|RC:[XURC]|[CIA]R:[XLMH]|MAV:[XNALP]|MAC:[XLH]|MPR:[XUNLH]|MUI:[XNR]|MS:[XUC]|M[CIA]:[XNLH])$/
const pattern = /(^CVSS:3\.1\/((AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]|E:[XUPFH]|RL:[XOTWU]|RC:[XURC]|[CIA]R:[XLMH]|MAV:[XNALP]|MAC:[XLH]|MPR:[XUNLH]|MUI:[XNR]|MS:[XUC]|M[CIA]:[XNLH])\/)*(AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]|E:[XUPFH]|RL:[XOTWU]|RC:[XURC]|[CIA]R:[XLMH]|MAV:[XNALP]|MAC:[XLH]|MPR:[XUNLH]|MUI:[XNR]|MS:[XUC]|M[CIA]:[XNLH])$)|(^(10(\.0)?|[0-9](\.[0-9])?)$)/
return value == '' || pattern.test(value) || 'Invalid or Incomplete Vector String'
}
}
Expand All @@ -136,29 +136,40 @@
methods: {
updateValue(e) {
this.calcValue = e;
this.score = this.clc.calculateCVSSFromVector(this.calcValue);
setTimeout(()=>{
const value = parseFloat(e);
if (value >= 0 && value <= 10) {
// OK
} else {
this.score = this.clc.calculateCVSSFromVector(this.calcValue);
}
setTimeout(() => {
this.values[0].value = e;
this.onEdit(0);
},200);
}, 200);
},
report(e) {
this.status = e;
},
directValueChange() {
let vsReport = this.clc.calculateCVSSFromVector(this.calcValue);
if(vsReport.success) {
this.score = vsReport;
const value = parseFloat(this.calcValue);
if (value >= 0 && value <= 10) {
this.values[0].value = this.calcValue;
this.onKeyUp(0);
} else {
let vsReport = this.clc.calculateCVSSFromVector(this.calcValue);
if (vsReport.success) {
this.score = vsReport;
this.values[0].value = this.calcValue;
this.onKeyUp(0);
}
}
}
},
mounted(){
if( this.values[0].value !== "" ) {
mounted() {
const value = parseFloat(this.values[0].value);
if (value >= 0 && value <= 10) {
this.calcValue = this.values[0].value;
} else if (this.values[0].value !== "") {
this.calcValue = this.values[0].value;
this.score = this.clc.calculateCVSSFromVector(this.calcValue);
} else {
Expand Down

0 comments on commit d666b45

Please sign in to comment.