khulnasoft commited on
Commit
2bde95f
1 Parent(s): 922104e

Update cvss.js

Browse files
Files changed (1) hide show
  1. cvss.js +18 -5
cvss.js CHANGED
@@ -38,10 +38,10 @@ Usage:
38
  onchange: function() {....} //optional
39
  onsubmit: function() {....} //optional
40
  }
41
-
42
  // set a vector
43
  c.set('AV:L/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:L');
44
-
45
  //get the value
46
  c.get() returns an object like:
47
 
@@ -49,7 +49,7 @@ Usage:
49
  score: 4.3,
50
  vector: 'AV:L/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:L'
51
  }
52
-
53
  */
54
 
55
  var CVSS = function (id, options) {
@@ -179,7 +179,7 @@ var CVSS = function (id, options) {
179
  }
180
  }
181
  };
182
-
183
  this.bme = {};
184
  this.bmgReg = {
185
  AV: 'NALP',
@@ -250,7 +250,17 @@ var CVSS = function (id, options) {
250
  l.appendChild(this.vector = e('a'));
251
  this.vector.className = 'vector';
252
  this.vector.innerHTML = 'CVSS:3.1/AV:_/AC:_/PR:_/UI:_/S:_/C:_/I:_/A:_';
253
-
 
 
 
 
 
 
 
 
 
 
254
  if (options.onsubmit) {
255
  f.appendChild(e('hr'));
256
  this.submitButton = f.appendChild(e('input'));
@@ -462,6 +472,9 @@ CVSS.prototype.update = function(newVec) {
462
  this.severity.className = rating.name + ' severity';
463
  this.severity.innerHTML = rating.name + '<sub>' + rating.bottom + ' - ' + rating.top + '</sub>';
464
  this.severity.title = rating.bottom + ' - ' + rating.top;
 
 
 
465
  if (this.options !== undefined && this.options.onchange !== undefined) {
466
  this.options.onchange();
467
  }
 
38
  onchange: function() {....} //optional
39
  onsubmit: function() {....} //optional
40
  }
41
+
42
  // set a vector
43
  c.set('AV:L/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:L');
44
+
45
  //get the value
46
  c.get() returns an object like:
47
 
 
49
  score: 4.3,
50
  vector: 'AV:L/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:L'
51
  }
52
+
53
  */
54
 
55
  var CVSS = function (id, options) {
 
179
  }
180
  }
181
  };
182
+
183
  this.bme = {};
184
  this.bmgReg = {
185
  AV: 'NALP',
 
250
  l.appendChild(this.vector = e('a'));
251
  this.vector.className = 'vector';
252
  this.vector.innerHTML = 'CVSS:3.1/AV:_/AC:_/PR:_/UI:_/S:_/C:_/I:_/A:_';
253
+ // setup the copy button/icon
254
+ l.appendChild(document.createTextNode(' '));
255
+ l.appendChild(this.copyButton = e('a'))
256
+ this.copyButton.style.visibility = "hidden"
257
+ this.copyButton.className = "copy-button"
258
+ this.copyButton.title = "Copy Vector to Clipboard"
259
+ this.copyButton.innerHTML = 'Copy'
260
+ this.copyButton.onclick = function () {
261
+ navigator.clipboard.writeText(document.querySelector(".vector").innerText)
262
+ }
263
+
264
  if (options.onsubmit) {
265
  f.appendChild(e('hr'));
266
  this.submitButton = f.appendChild(e('input'));
 
472
  this.severity.className = rating.name + ' severity';
473
  this.severity.innerHTML = rating.name + '<sub>' + rating.bottom + ' - ' + rating.top + '</sub>';
474
  this.severity.title = rating.bottom + ' - ' + rating.top;
475
+ if (rating['name'] != '?') {
476
+ this.copyButton.style.visibility = "visible"
477
+ }
478
  if (this.options !== undefined && this.options.onchange !== undefined) {
479
  this.options.onchange();
480
  }